Hi,
I tried the following code:
Code:
//BoundingSphere using computeBound()
osg::BoundingSphere bh1Sphere = backhoe1Group->computeBound();
osg::BoundingSphere bh1PATSphere = backhoe1PAT->computeBound();
//BoundingSpere using computeBound():
osg::BoundingSphere bh2Sphere = backhoe2Group->computeBound();
osg::BoundingSphere bh2PATSphere = backhoe2PAT->computeBound();
..................
float x1, x2, y1, y2, distance;
if(bh1Sphere.intersects(bh2Sphere))
{
std::cout << "The backhoes are colliding !!"
<< std::endl;
x1 = bh1Sphere.center().x();
x2 = bh2Sphere.center().x();
y1 = bh1Sphere.center().y();
y2 = bh2Sphere.center().y();
distance = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
std::cout << "distance = " << distance;
std::cout << std::endl;
}
else
{
x1 = bh1Sphere.center().x();
x2 = bh2Sphere.center().x();
y1 = bh1Sphere.center().y();
y2 = bh2Sphere.center().y();
distance = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
std::cout << "distance = " << distance;
std::cout << std::endl;
}
However, both the spheres (1 and 2) have the same centre coordinates. When I
try the same thing using spheres that are bounds for the top-most PATNodes, I
again get the same result (i.e. centre coordinates are the same).
I find this confusing as both the nodes have different positions. Is this a
sensible approach to take though ?
Cheers,
Sanat
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30880#30880
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org