Hello Renan,
As Robert mentioned, you really need to learn how to read the API
documentation (doxygen-generated) and click links on it to find out
how to connect things together.
For your current situation, take a look at the osgpick example. The
PickHandler::handle() method calls PickHandler::pick(), which looks
like this:
void PickHandler::pick(osgViewer::Viewer* viewer,
const osgGA::GUIEventAdapter& ea)
{
osgUtil::LineSegmentIntersector::Intersections intersections;
std::string gdlist="";
if (viewer->computeIntersections(ea.getX(),ea.getY(),intersections))
{
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr =
intersections.begin();
hitr != intersections.end();
++hitr)
{
std::ostringstream os;
if (!hitr->nodePath.empty() &&
!(hitr->nodePath.back()->getName().empty()))
{
// HERE YOU HAVE THE NODE THAT WAS PICKED
}
else if (hitr->drawable.valid())
{
// HERE YOU HAVE THE DRAWABLE THAT WAS PICKED!
// This is what you want, so you can probably remove the
// above if statement...
// Insert the code you want here... For example:
osg::ShapeDrawable* shapeDrawable =
dynamic_cast<osg::ShapeDrawable*>(hitr->drawable);
if (shapeDrawable)
{
shapeDrawable->setColor(osg::Vec4(1,0,0,1)); // Red
}
}
// ...
}
}
// ...
}
As you can see, the OSG examples are a great source of hints on how to
do things. Also, looking at the doxygen would have helped you.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay [EMAIL PROTECTED]
http://whitestar02.webhop.org/
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org