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