[osg-users] Retrieve a vertexs list of a Node
robert.osfield at gmail.com
Wed Mar 4 03:29:58 PST 2009
On Wed, Mar 4, 2009 at 10:00 AM, Diallo <osgforum at tevs.eu> wrote:
> I need to access to all vertexs of a 3d object loaded as node from a ac3D file.
> I am working on FlightGear Project and we need to integrate a collision system, so we need to access to every vertex (or triangles) of a given model.
Vertex and primitive data is stored in osg::Geometry leaves on the
scene graph, and one model loaded from a format such as ac3d may well
have a whole subgraph containing many leaves, including under
transforms. This means a single node doesn't directly have vertices
or primitives, rather its the root of graph containing leaves that
contain the vertices and geometry.
To go find the geometry leaves you'll need first to write a custom
NodeVisitor, and then once you have located the Geode's that contain
the Drawables (Geometry subclasses from Drawable) you either
dynamic_cast to Geometry and then access the vertex and primitive
data, or use functors to access the data. The use of functors work
with all Drawables and enable the automatically decomposition of
polygon primitives into triangles making it easier to deal with
different types of primitive data. An example of this in action is in
the src/osgUtil/IntersectionVisitor.cpp and
More information about the osg-users