Hi Bruce,
I'm doing something similar to you, where I want to be able to click in a scene
and add objects at that point. I do it as JS suggests, using an event adapter
to get the mouse coordinates, a line segment intersector using Window
coordinates, and an intersection visitor. If you want, you can use node masks
to determine which objects in the scene the intersector will find. From the
intersector you can get Vec3s of position and normal vector of the surface that
was found. The normal can be used to orient an object you place on terrain,
for example.
Code:
osg::ref_ptr<osgUtil::LineSegmentIntersector> lsi = new
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(),
ea.getY());
osgUtil::IntersectionVisitor iv(lsi.get());
iv.setTraversalMask(MY_MASK);
_camera->accept(iv);
osg::Vec3 position, normal;
if(lsi->containsIntersections())
{
position = mlsi->getFirstIntersection().getWorldIntersectPoint();
normal = mlsi->getFirstIntersection().getWorldIntersectNormal();
}
Good luck getting it working!
Cheers,
Tom
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29808#29808
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org