Hi,
   I am trying to get the bounding sphere at a node but the return value is 
the same as the initial bounding sphere although I've transformed the Node 
using a MatrixTransform. Here is the code I'm using, could anyone please 
tell me how to get the transformed bounding sphere. Thanks in advance.

Pawan Harish

int main(int argc, char **argv)
{
         osgViewer::Viewer viewer;
         osg::Group *group = new osg::Group;
         osg::MatrixTransform *mat1 = new osg::MatrixTransform;
         osg::MatrixTransform *mat2 = new osg::MatrixTransform;
         
mat1->setMatrix(osg::Matrix::translate(-50,0,0)*osg::Matrix::scale(0.2,0.2,0.2));
         
mat2->setMatrix(osg::Matrix::translate(-25,0,30)*osg::Matrix::scale(0.2,0.2,0.2));
         osg::Node* glider = osgDB::readNodeFile("glider.osg");

         osg::Node* cow = osgDB::readNodeFile("cow.osg");

         osg::Vec3 center_orig = cow->getBound().center();
         double radius_orig = cow->getBound().radius();
         printf("center_orig: %lf %lf %lf radius_orig: %lf\n",
        center_orig[0],center_orig[1],center_orig[2],radius_orig);

         osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
         glider->setName("Glider");
         cessna->setName("Cessna");
         cow->setName("Cow");
         mat1->setName("Matrix1_Cow");
         mat2->setName("Matrix2_Cessna");
         group->addChild(glider);
         mat1->addChild(cow);
         mat2->addChild(cessna);
         group->addChild(mat1);
         group->addChild(mat2);
         group->setName("PawansExpt");
         viewer.setSceneData(group);

         osg::BoundingSphere bs = cow->getBound();

        //These values are same as the ones printed above

         osg::Vec3 center_new = bs.center();
         double radius_new = bs.radius();
         printf("center_new: %lf %lf %lf radius_new: %lf\n",
        center_new[0],center_new[1],center_new[2],radius_new);

         return viewer.run();
}



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to