|
Hi all users, i am stuck in a puzzling problem. I want to check if any of my geometries lye within a frustum. In order to achieve this, in a reasonably fast way, I am building the frustum via six planes, and then check it vs the bounding spheres of the
geometries. Here is my code: // build the 6 planes for the frustum osg::Plane
nearPlane = osg::Plane (pntTopLeftNear,pntTopRightNear,pntBottomLeftNear); osg::Plane
farPlane = osg::Plane (pntTopLeftFar,pntTopRightFar,pntBottomLeftFar); osg::Plane
leftPlane = osg::Plane (from, pntTopLeftFar,pntBottomLeftFar); osg::Plane
rightPlane = osg::Plane (from, pntTopRightFar,pntBottomRightFar); osg::Plane
topPlane = osg::Plane (from, pntTopLeftFar, pntTopRightFar); osg::Plane
bottomPlane = osg::Plane(from, pntBottomLeftFar, pntBottomRightFar); // that's the frustum osg::FrustumVolume frustum =
osg::FrustumVolume
(nearPlane,farPlane,leftPlane,rightPlane,topPlane,bottomPlane); // build bounding
sphere Pnt3f min, max,
center; float range; this_node->getVolume(true).getBounds( min, max ); center = (min +
max) * 0.5; range =
osg::Vec3f ( center - max ).length(); std::cout
<< "center " << center << " range "
<< range << std::endl; osg::SphereVolume
this_volume = osg::SphereVolume(center,range); bool intersect =
frustum.intersect (this_volume); printf ("volume %d intersecato %d\n",i,(int)intersect); The problem is that intersect is always false, even
if I am pretty sure that the frustum actually crosses the geometry. Am I doing something
terribly wrong? Thanks for the advices, E. |
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
