[osg-users] Resize a shape?

Patrick Maier maierp at gmx.net
Tue Oct 23 15:47:43 PDT 2007


Hi,
I'm new to this list and to openscenegraph and I've a question regarding a  
problem and I don't know how to solve it.
It should be really trivial, but I don't get it managed, and google or  
other searches could not help me.

I've a cylinder, and while showing the scene, I want to change the size  
(height) of the cylinder.
I tried it that way, but only the first call of setting the height is a  
success (so the height of the cylinder stays at 0.1):

===
osg::Geode* possible_binding = new osg::Geode();
osg::Cylinder* possible_binding_shape = new  
osg::Cylinder(osg::Vec3(0,0,0), 0.4, 1.0);
osg::ShapeDrawable* possible_binding_drawable = new  
osg::ShapeDrawable(possible_binding_shape);
possible_binding->addDrawable(possible_binding_drawable);

[...]

viewer.realize();
float i = 0;
while(!viewer.done()){
	i += 0.1f;
	((osg::Cylinder*)(possible_binding->getDrawable(0)->getShape()))->setHeight(i);
	std::cout << "Main: " <<  
((osg::Cylinder*)(possible_binding->getDrawable(0)->getShape()))->getHeight()  
<< std::endl;
	viewer.frame();
}
===

What am I doing wrong?
Sorry if this should be a trivial question, but I don't know the answer.

Thanks a lot!
Patrick




More information about the osg-users mailing list