Changeset 1917 for OpenSceneGraph/trunk/examples/osgpick/osgpick.cpp
- Timestamp:
- 04/25/03 15:47:33 (10 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/examples/osgpick/osgpick.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgpick/osgpick.cpp
r1885 r1917 29 29 #include <osgText/Text> 30 30 31 #include <sstream> 31 32 32 33 // class to handle events with a pick … … 81 82 ++hitr) 82 83 { 83 //osg::Vec3 ip = hitr->getLocalIntersectPoint(); 84 //osg::Vec3 in = hitr->getLocalIntersectNormal(); 85 osg::Geode* geode = hitr->_geode.get(); 86 // the geodes are identified by name. 87 if (geode) 84 std::ostringstream os; 85 if (hitr->_geode.valid() && !hitr->_geode->getName().empty()) 88 86 { 89 if (!geode->getName().empty()) 90 { 91 gdlist=gdlist+" "+geode->getName(); 92 } 93 else 94 { 95 gdlist=gdlist+" geode"; 96 } 97 } 87 // the geodes are identified by name. 88 os<<"Object \""<<hitr->_geode->getName()<<"\""<<std::endl; 89 } 90 else if (hitr->_drawable.valid()) 91 { 92 os<<"Object \""<<hitr->_drawable->className()<<"\""<<std::endl; 93 } 94 95 os<<" local coords vertex("<< hitr->getLocalIntersectPoint()<<")"<<" normal("<<hitr->getLocalIntersectNormal()<<")"<<std::endl; 96 os<<" world coords vertex("<< hitr->getWorldIntersectPoint()<<")"<<" normal("<<hitr->getWorldIntersectNormal()<<")"<<std::endl; 97 osgUtil::Hit::VecIndexList& vil = hitr->_vecIndexList; 98 for(unsigned int i=0;i<vil.size();++i) 99 { 100 os<<" vertex indices ["<<i<<"] = "<<vil[i]<<std::endl; 101 } 102 103 gdlist += os.str(); 98 104 } 99 105 } … … 178 184 stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 179 185 stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 180 geode->setName(" whatis");186 geode->setName("The text label"); 181 187 geode->addDrawable( updateText ); 182 188 modelview_abs->addChild(geode); 183 189 190 updateText->setCharacterSize(20.0f); 184 191 updateText->setFont(timesFont); 185 updateText->setText("whatis will tell you what is under the mouse"); 192 updateText->setColor(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); 193 updateText->setText(""); 186 194 updateText->setPosition(position); 187 195
