Ah. The OP didn't specify "axis-aligned" in the initial post (or if it was
mentioned, I somehow missed it... Either way) my apologies.

The task appears to be under-specified. You need to answer this question: Do
you want something fast and (possibly) inaccurate, or do you want accurate?

The fast method would be to compute the eight corners, transform them, and
create a new BB that contains the eight transformed points.

The accurate way would be to transform all the coordinates that comprise the
geometry and build a BB that contains them all.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Jean-Sébastien Guay
Sent: Thursday, May 14, 2009 8:13 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] World space bounding box

Hi Paul,

>     const osg::MatrixList& m = node->getWorldMatrices();
>     osg::ComputeBoundsVisitor cbv;
>     node->accept( cbv );
>     osg::BoundingBox bb = cbv.getBoundingBox();
>     osg::Vec3 minV = bb._min * m.front();
>     osg::Vec3 maxV = bb._max * m.front();
>     osg::notify( osg::ALWAYS ) << minV << std::endl << maxV << 
> std::endl;

This method does not result in an AABB if the matrix contained a rotation.
The bounding box is no longer axis-aligned.

You need to do as the OP suggested, transform the 8 corners of the box and
then rebuild an AABB from those. Though I think the code could be simplified
and cleaned up.

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

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to