Hi,
On 10/30/07, Carsten Neumann <[EMAIL PROTECTED]> wrote:
> Hello Josef,
>
> Josef Grunig wrote:
> > Hi,
> >
> > I'm computing bounding boxes on nodes in this way:
> >
> > Pnt3f min, max;
> > DynamicVolume volume;
> > node->getWorldVolume(volume);
> > volume.getBounds( min, max );
> >
> > then building 6 planes using min and max; The resulting BoundingBox
> > geometry is attached to the root node (I've a valid reason for not
> > attaching it as a child of the bounded node)
>
> the BoxVolume (which is inside the DynamicVolume) returned by
> getWorldVolume is axis aligned in world coordinates; it is not just the
> local box transformed to world coordinates, which seems to be what you
> are looking for, right ?
>
> > Boxes are OK as long as I set translations and scaling. when applying
> > a rotation boxes stretch and look like as they get scaled... any
> > reason for that? Am I computing the box volume correctly?
>
> The volume you compute has to accommodate the rotated object and still
> be axis aligned, therefore it has to grow when the rotates.
> To transform the local volume to world coordinates, construct your
> planes with the bounds of the getVolume() volume and then transform them
> to world coordinates by applying the getToWorld() matrix.
thanyou for the hint;
Here is what I'm doing now:
for a given node I compute
Pnt3f min, max;
node->getVolume(true).getBounds( min, max );
osg::NodePtr bbox <-- /// build here the bboxe given min max
OSG::Matrix m = node->getParent()->getToWorld();
TransformPtr trans;
NodePtr bBoxRoot= makeCoredNode<Transform>(&trans);
beginEditCP(trans);
trans->setMatrix(m);
endEditCP(trans);
beginEditCP( bBoxRoot);
bBoxRoot->addChild( bbox );
endEditCP( bBoxRoot);
and add the bBoxRoot to my scene root, without parent transforms...
This way it works great as long I create the boxes around a geometry
Node, but if I create them on a Transform node (for example the parent
of the previous cited geometry node) the bounding boxes are again
wrong (bigger than what they should be...)
Probably the getVolume of the transform node is computed on the
rotated volume (and not geometry) of the child object, which is not
what we really want.
Thank you for your help,
Josef
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users