[osg-users] Volume of .obj model
OpenSceneGraph Users
osg-users at lists.openscenegraph.org
Tue Nov 10 06:28:32 PST 2020
Hi,
I'm currently trying to understand which is the occupation volume of an
.obj file loaded in the node:
osg::ref_ptr<osg::Node> boat = osgDB::readNodeFile("file.obj");
Then, the problem is that I need to understand the real length, width and
height of the node.
I found a solution, but I think that the value it isn't correct:
osg::ref_ptr<osg::ComputeBoundsVisitor> cbv = new
osg::ComputeBoundsVisitor();
osg::ref_ptr<osg::MatrixTransform> boundingBoxMt = new
osg::MatrixTransform();
osg::ref_ptr<osg::Geode> boundingBoxGeode = new osg::Geode();
osg::BoundingBox geodeBoundingBox;
boat->accept(*cbv);
osg::BoundingBox bb(cbv->getBoundingBox());
boundingBoxMt->setMatrix(osg::Matrix::translate(geodeBoundingBox.center()));
osg::Vec3 ext(bb._max - bb._min);
cout << ext.x() << " " << ext.y() << " " << ext.z() << endl;
Is there a better solution make a correct result?
Thanks
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/ae9cf774-39db-441d-997a-95f86e217cabn%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20201110/57481852/attachment.html>
More information about the osg-users
mailing list