Hello
I have trouble using the localIntersectionPoint of osgUtil::PolytopeIntersector
I want to return the exact position of the mouse when I slide on a Node to
calculate the area of the node I slide on.
So I get the node and then if it is the good node (name= “piece”) I return the
position.
The problem is that if the mouse is too close to the position 0 in x or y
osgUtil::PolytopeIntersector.getFirstIntersection().nodePath does not pick up
the node (it does not appear in the nodepath).
Does someone know from where this problem could come ?
Thank you
My function :
Code:
/*
*return the exacte position of the intersection or NULL if no intersection
*/
osg::Vec3d * CSceneEventHandler::GetIntersectPos(const double x, const double
y, osgViewer::View* viewer, std::string type )
{
if(!viewer->getSceneData()) return false; // nothing to pick
double w(.05), h(.05);
osgUtil::PolytopeIntersector* picker =
new osgUtil::PolytopeIntersector(
osgUtil::Intersector::PROJECTION, x-w, y-h, x+w, y+h);
osgUtil::IntersectionVisitor iv( picker );
viewer->getCamera()->accept( iv );
if( picker->containsIntersections())
{
const osg::NodePath& nodePath =
picker->getFirstIntersection().nodePath;
unsigned int idx = nodePath.size();
osg::Node* Node;
while(idx--)
{
// get and check node
Node = nodePath[ idx ];
int nP = Node->getNumParents()-1;
// if it is the good node
if( Node->getName() != type ){ Node = NULL; continue;}
osg::PositionAttitudeTransform* Npos =
dynamic_cast<osg::PositionAttitudeTransform*>(
Node->getParent(nP) );
if( Npos == NULL) { Node = NULL; continue;}
// as long as we don't have the good node
osg::Vec3d * pos = //new osg::Vec3d(
firstHit.getWorldIntersectPoint() );
new osg::Vec3d(
picker->getFirstIntersection().localIntersectionPoint );
return pos;
}
}
return NULL;
}
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=23853#23853
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org