Volume of .obj model

25 views
Skip to first unread message

marco....@elmansrl.eu

unread,
Nov 10, 2020, 9:28:32 AM11/10/20
to OpenSceneGraph Users
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

OpenSceneGraph Users

unread,
Nov 10, 2020, 10:15:24 AM11/10/20
to OpenSceneGraph Users
When you saying volume what do you actually mean?

The models that are loadable from .obj can be totally unconstrained open meshes where a volume isn't normally applicable without extra constraints.

Do you know your models are manifold geometries?
Reply all
Reply to author
Forward
0 new messages