Danny Lesnik wrote:
I'm trying to use intersect for primitive collision detection. I load one 3DS file into my scene and test whether this object has any intersections. The problem is following: Although ,there is only one object in my scene, I can clearly see that this object intersects with something.
This is the code I'm using:

tankNode = osgDB::readNodeFile("c:\\3.3DS");
osg::Vec3d intersection;
osg::BoundingSphere bs = tankNode->getBound();
osg::Vec3 start = bs.center() + osg::Vec3d(bs.radius(),0.0,0.0);
osg::Vec3 end = bs.center() ;
osg::ref_ptr<osgUtil::LineSegmentIntersector> lsi = new 
osgUtil::LineSegmentIntersector(start,end);
osgUtil::IntersectionVisitor iv(lsi.get());

tankNode->accept(iv);

      if (lsi->containsIntersections())
       {
intersection = lsi->getIntersections().begin()->getWorldIntersectPoint();
       }


While I'm running this code in debugger,the values are following:

bs.center = (0,0,0);
bs.radius = 43.0

start = (43.0,0.0,0.0)

end= (0,0,0)

intersects = (12.5,0,0) and this is weird. Am I missing somthing?
It's not an unexpected result, actually. You shoot a line along the X axis, so any intersection you're going to find is going to be (value, 0, 0) in this case. Note that the bounding sphere is usually not very tight in OSG, so your model might easily be intersected at X=12.5.

Paul
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to