Dear All I implemented a Picking function... In order to debug the picking function I simply print in monitor the id of the picked drawable.
The problem is that the picking function is called two time for each mouse click. Does anyone know why it happens? This in my handler: class PickHandler : public osgGA::GUIEventHandler { public: PickHandler(osgProducer::Viewer* viewer, Player* player): _viewer(viewer), _player(player){} ~PickHandler() {} bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us); virtual void pick(const osgGA::GUIEventAdapter& ea); protected: osgProducer::Viewer* _viewer; Player* _player; }; bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) { if( ea.getEventType() == osgGA::GUIEventAdapter::PUSH ) { if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ) pick(ea); if( ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON ) _player->MoveToNextUpLevel(); } return false; } void PickHandler::pick(const osgGA::GUIEventAdapter& ea) { osgUtil::IntersectVisitor::HitList hlist; if (_viewer->computeIntersections(ea.getX(),ea.getY(),hlist)) { for(osgUtil::IntersectVisitor::HitList::iterator hitr=hlist.begin(); hitr!=hlist.end(); ++hitr) { std::ostringstream os; if (hitr->_geode.valid() && !hitr->_geode->getName().empty()) { // the geodes are identified by name. osg::ref_ptr<NodeInfo> cellInfo = dynamic_cast<NodeInfo*> (hitr->_geode->getParent(0)->getParent(0)->getParent(0)->getUserData() ); int id_time = cellInfo->GetTime(); std::string id_cell = cellInfo->GetCellID(); _player->CellPicked(id_cell, id_time); } else if (hitr->_drawable.valid()) { os<<"Object \""<<hitr->_drawable->className()<<"\""<<std::endl; } } } } .....and this add it to the viewer viewer->getEventHandlerList().push_front(new PickHandler(viewer.get(), this)); Thanks!!!! ------------------------------------------------------ Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada _______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/