Hi Deepu,
In addition to writing a node visitor to traverse the scene graph and
move from node to node accumulating transforms, one thing I have done in
the past to get the geometry information once the visitor reaches a
scene graph leaf is extending osg::PrimitiveFunctor or
osg::PrimitiveIndexFunctor to get geometry information from the
drawable. This also follows the visitor pattern, allowing the geometry
to describe itself to you. From these classes you can store the
geometry to whatever data structure you need for your physics model. I
believe the osg::TriangleIndexFunctor template class provides a nice
implementation of the PrimitiveIndexFunctor methods for triangle based
geometry and allows you to specify the processing function via a functor
object (struct with overloaded operator()). Hope this helps.
Will
Jean-Sébastien Guay wrote:
Hello Deepu,
I am working on a simulation project in which I have to
define an OSG node in the physics world (Bullet Physics). Can any one
guide me towards a method by which I can convert an OSG node to a
mesh so that I can define it in the physics world.
In general, you would write a node visitor that given your node, would
extract the vertices and triangles. Then you would give those to your
physics engine. You'll have to figure out the particular format of the
mesh the physics engine expects, of course. We can't help you with that.
There is some code in the OBJ writer
(src/osgPlugins/obj/OBJWriterNodeVisitor.{cpp|h}) which you could use
as an example of how to extract vertices and triangles from a geometry
object.
Hope this helps,
J-S
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org