Jean-Sébastien Guay wrote: > Hi all, > >> Any ideas? > > Anyone? > > J-S > > (previous message below in case you don't know what I'm talking about) > > Jean-Sébastien Guay wrote: >> Hi Paul, >> >>> Hi J-S -- I recently wrote my own visitor to flatten transforms. To >>> do this, >>> I use osg::computeLocalToWorld(osg::NodePath&) to get the >>> local-to-world >>> matrix, and transform all vertices by that matrix. >> >> Yes, I've done that in the past too, and after fiddling for a while >> with the order of operations and how to transform vectors properly >> (as opposed to points/vertices) I got it to work too. >> >>> This works great for me, >>> and what you are doing sounds like an equivalent operation, so I'm >>> not sure >>> why it's not working for you. Can you provide more details on the >>> failure? >> >> Well, say I have this (pseudo code) >> >> osg::BoundingBox combinedWorldBB; >> foreach node in selectedNodes >> add node's BB (world-space) to combinedWorldBB >> end >> >> The result I get is that when the root transform of my group of nodes >> is identity, I get a bounding box of: >> >> _min = ( -1.4047172 , -0.94869113 , -1.9402435 ) >> _max = ( 2.7989883 , 0.95002991 , 0.33612174 ) >> >> which is a bounding box of approximate size (4, 2, 2.3) centered >> approximately at (0.6, 0, -0.8). >> >> If I translate the root of those nodes by -5 in Z (and they look >> correctly transformed), I get this bounding box: >> >> _min = ( -1.4047172 , -0.94869113 , -11.940244 ) >> _max = ( 2.7989883 , 0.95002991 , -5.3083067 ) Interestingly enough min xseems to have been decremented by twice -5... won't help you, but just an observation :)
Paul >> >> which is a bounding box of approximate size (4, 2, 6.6) centered >> approximately at (0.6, 0, -8.6). >> >> So you can see, the bounding box changes much more than a simple >> translation by -5 in Z... >> >> >> My code is: >> >> void getWorldBounds(osg::Node* node, osg::BoundingBox& bb) >> { >> GetWorldCoordOfNodeVisitor worldVisitor; >> node->accept(worldVisitor); >> osg::Matrix localToWorld = worldVisitor.getMatrix(); >> >> osg::ComputeBoundsVisitor cbbv; >> node->accept(cbbv); >> osg::BoundingBox localBB = cbbv.getBoundingBox(); >> >> for (unsigned int i = 0; i < 8; i++) >> { >> bb.expandBy(localBB.corner(i) * localToWorld); >> } >> } >> >> // ... Then in a method: >> >> osg::BoundingBox bb; >> foreach (osg::Node* node, selectedNodes) >> { >> getWorldBounds(node, bb); >> } >> >> // Results inspected at this point in the debugger. >> >> >> Any ideas? >> >> Thanks in advance, >> >> J-S > > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org