Jean-Sébastien Guay wrote:
Hi Daniele, Alberto,

Assuming that no transformation nodes exist in the graph describing your
node, you can write a node visitor that joins all the bounding boxes of
every geode.

Else you'll need to modify every bounding box by its parent transforms
in order to join them.

Actually you don't need to write this, it's so common that it exists in OSG already: osg::ComputeBoundsVisitor. And it does the right thing with transforms.

osg::ComputeBoundsVisitor cbbv;
node->accept(cbbv);
osg::BoundingBox bb = cbbv.getBoundingBox();
osg::Vec3 size = bb._max - bb._min;

// Then size contains the size in X, Y and Z.

For purposes of analyzing models, it's often useful to have access to this information from the command line. The osgWorks project (osgworks.googlecode.com) contains the osgwbvv application to display bounding volume information, either as a sphere or (using ComputeBoundsVisitor) as a box.

  >osgwbvv cow.osg
  Sphere:
        Center  0.776125 -0.43866 0
        Radius  6.35558

  >osgwbvv --box cow.osg
  Box:
        Center  0.776125 -0.43866 0
        Radius  6.35558
        Extents 10.4439 3.40282 6.39676

The bounding volume (sphere or box) is also displayed graphically as line geometry around the model.

--
  -Paul Martz      Skew Matrix Software
                   http://www.skew-matrix.com/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to