Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool normalAndHot(const osg::Vec3d& position, osgViewer::CompositeViewer& viewer, osg::Vec3& normal, osg::Vec3d& hot)
- {
- osgSim::LineOfSight los;
- osg::Vec3d s = position + osg::Vec3d(0, 0, 10000);
- osg::Vec3d e = position - osg::Vec3d(0, 0, 10000);
- los.addLOS(s, e);
- if (viewer.getView(0)->getSceneData())
- {
- osg::ref_ptr<osgUtil::IntersectorGroup> intersectorGroup = new osgUtil::IntersectorGroup();
- osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(s, e);
- intersectorGroup->addIntersector(intersector.get());
- osgUtil::IntersectionVisitor intersectVisitor(intersectorGroup.get());
- viewer.getView(0)->getSceneData()->accept(intersectVisitor);
- if (intersectorGroup->containsIntersections())
- {
- osgUtil::IntersectorGroup::Intersectors& intersectors = intersectorGroup->getIntersectors();
- for (osgUtil::IntersectorGroup::Intersectors::iterator intersector_itr = intersectors.begin();
- intersector_itr != intersectors.end();
- ++intersector_itr)
- {
- osgUtil::LineSegmentIntersector* lsi = dynamic_cast<osgUtil::LineSegmentIntersector*>(intersector_itr->get());
- if (lsi)
- {
- osgUtil::LineSegmentIntersector::Intersections& intersections = lsi->getIntersections();
- for (osgUtil::LineSegmentIntersector::Intersections::iterator itr = intersections.begin();
- itr != intersections.end();
- ++itr)
- {
- const osgUtil::LineSegmentIntersector::Intersection& intersection = *itr;
- normal = intersection.getWorldIntersectNormal();
- hot = intersection.getWorldIntersectPoint();
- std::cout << "HOT: " << hot << std::endl;
- }
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement