Hi, I am trying to use the excellent application from osgworks - osgwbvv to draw bounding spheres around any particular selected node in the scene graph.
The function used to draw the bounding sphere is below: Code: void OsgViewerWindow::drawBoundingSphere(osg::ref_ptr<osg::Node> &node) { osg::MatrixList matrixList = node->getWorldMatrices(); osg::ref_ptr<osg::MatrixTransform> boundingBoxMt = new osg::MatrixTransform(); osg::ref_ptr<osg::Geode> boundingBoxGeode = new osg::Geode(); osg::StateSet* ss = boundingBoxGeode->getOrCreateStateSet(); ss->setAttributeAndModes( new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE ) ); ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); const osg::BoundingSphere bs( node->getBound() ); boundingBoxMt->postMult(osg::Matrix::rotate(matrixList[0].getRotate())* osg::Matrix::translate(bs._center + matrixList[0].getTrans()) ); //add drawable to the geode boundingBoxGeode->addDrawable( osgwTools::makeGeodesicSphere( bs._radius, 1 ) ); //add geode under Mt boundingBoxMt->addChild(boundingBoxGeode); //get the parent matrix transform of the node and add bounding sphere to it node->getParent(0)->addChild(boundingBoxGeode); return; } While this works fine when there are translations applied to the MatrixTransforms above the nodes, the bounding spheres do not enclose the geometry when rotations are added to the mix. Actually, rendering the bounding sphere clearly showed that something was wrong. I tried following some of the threads as there was some mention of rotations in transforms leading to incorrect results. I thought I was doing ok but haven't had much success. Hence I wanted to ask what is the correct approach to get the bounding sphere for a particular node which may have rotations in addition to translation and scale. Thanks Sincerely, Sanat. ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42174#42174 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org