Hi Sanat,

I am working on an application that is currently using a Cylinder Drawable 
object.

You probably mean ShapeDrawable, since Drawable is the base class for all drawable objects (including osg::Geometry).

How Can I go from using a Drawable to actual geometry ?

You have to calculate the vertex positions and then build triangles using those vertices.

If you look on the net you'll surely find lots of example code for creating cylinder geometry.

Another option is to look at the code in OSG where osg::ShapeDrawable creates a cylinder. See src/osg/ShapeDrawable.cpp, look for drawCylinderBody(...) and apply(const Cylinder& cylinder). If you convert that code to create a vertex array and three primitivesets (one QUAD_STRIP for the body and two TRIANGLE_FANs for the top and bottom) you'll have a cylinder in an osg::Geometry.

But if you don't have too many ShapeDrawables then it doesn't matter that much. If you're just thinking ahead, wanting to convert to osg::Geometry because it *might* become a performance problem sometime in the future, then I would say don't do it until you prove it's an actual performance problem.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to