Hi,
Im using code based on the osgpick example, im clipping a model so some of is
it is invisible on screen. But I can pick the part with the mouse pointer even
though that part of the model is invisible, is there an easy way for the pick
code to ignore cliped parts?
heres my code, my PWidgetBase class is inhereted from osg::Group class
[code]
PWidgetBase* PWidgetHandler::pick(osg::ref_ptr<osgViewer::View> view, const
osgGA::GUIEventAdapter& ea)
{
osgUtil::LineSegmentIntersector::Intersections intersections;
std::string gdlist="";
float x = ea.getX();
float y = ea.getY();
#if 0
osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view->getCamera()->accept(iv);
if (picker->containsIntersections())
{
intersections = picker->getIntersections();
#else
if (view->computeIntersections(x,y,intersections))
{
#endif
for
(osgUtil::LineSegmentIntersector::Intersections::iterator hitr =
intersections.begin();
hitr != intersections.end();
++hitr)
{
if (!hitr->nodePath.empty())
{
osg::Node* node = hitr->nodePath.back();
if (node && node->getNumParents() > 0)
{
node = node->getParent(0);
while (node != NULL)
{
if (node &&
strcmp(node->className(), "PWidgetBase") == 0)
{
PWidgetBase*
obj = (PWidgetBase*)node;
if (obj)
{
return
obj;
}
}
if
(node->getNumParents() > 0)
node =
node->getParent(0);
else
break;
}
}
}
else if (hitr->drawable.valid())
{
return NULL;
}
}
}
return NULL;
};
[/code]
...
Thank you!
Cheers,
Paul
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12680#12680
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org