- Timestamp:
- 10/07/08 16:01:14 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgparticleeffects/osgparticleeffects.cpp
r7964 r8998 29 29 30 30 #include <osgUtil/Optimizer> 31 #include <osgUtil/IntersectVisitor>32 31 33 32 #include <osgDB/ReadFile> … … 134 133 osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y) 135 134 { 136 osgUtil::IntersectVisitor iv;137 osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;138 139 135 const osg::BoundingSphere& bs = subgraph->getBound(); 140 136 float zMax = bs.center().z()+bs.radius(); 141 137 float zMin = bs.center().z()-bs.radius(); 142 138 143 segDown->set(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax)); 144 iv.addLineSegment(segDown.get()); 139 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = 140 new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax)); 141 142 osgUtil::IntersectionVisitor iv(intersector.get()); 145 143 146 144 subgraph->accept(iv); 147 145 148 if (iv.hits()) 149 { 150 osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get()); 151 if (!hitList.empty()) 152 { 153 osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); 154 return ip; 155 } 146 if (intersector->containsIntersections()) 147 { 148 return intersector->getFirstIntersection().getWorldIntersectPoint(); 156 149 } 157 150
