[osg-users] shape, shape drawable and geode modification

0 views
Skip to first unread message

Miguel Lokida

unread,
Sep 14, 2009, 11:26:25 AM9/14/09
to osg-...@lists.openscenegraph.org
Hi,

Here 's my problem. I have a cylinder shape that I have added to my scenegraph. here a sample code:

I have declared instances in the headers. And I can display the cylinder.

Code:

rp_cylinder = new osg::Cylinder();

rp_cylinder->setHeight(1.0f);
rp_cylinder->setRadius(100.0f);
rp_cylinder->setRotation(osg::Quat( (M_PI / 2.0f),osg::Vec3(0.0f, 1.0f, 0.0f)) );

rp_CylinderDrawable = new osg::ShapeDrawable(rp_cylinder.get());

rp_cylinderGeode = new osg::Geode();

rp_cylinderGeode->addDrawable(rp_CylinderDrawableDebFen.get());

rp_position->addChild(rp_cylinderGeode.get());

But, I would like to modify the radius and height of the cylinder. So, I do:


Code:
osg::Cylinder * cylinder = static_cast<osg::Cylinder *>(rp_cylinderGeode->getDrawable(0)->getShape());
cylinder->setHeight(2.0f);


But the problem is that nothing happen. No modification of the geometry.
The address of the pointer is always the same so it is the same object.

What 's wrong with my implementation ?


Thank you![/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=17347#17347

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Sep 14, 2009, 11:38:49 AM9/14/09
to osg-...@lists.openscenegraph.org
Hi Miguel,

By default the OSG creates display lists for drawables, including the ShapeDrawable, and this won't automatically update unless you tell the drawable it needs to recompile the display list which you can do via drawable->dirtyDisplayList().  If you plan to modify the shape regularily then it's best to just disable display lists outright via drawable->setUseDisplayList(false) as the compilation is relatively expensive.

Robert.

Miguel Lokida

unread,
Sep 15, 2009, 7:26:29 AM9/15/09
to osg-...@lists.openscenegraph.org
Thanks a lot. That works !

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=17371#17371

Reply all
Reply to author
Forward
0 new messages