void OccluderEventHandler::endOccluder() { if (_convexPlanarOccluder.valid()) { if (_convexPlanarOccluder->getOccluder().getVertexList().size()>=3) { osg::OccluderNode* occluderNode = new osg::OccluderNode; occluderNode->setOccluder(_convexPlanarOccluder.get()); if (!_occluders.valid()) { _occluders = new osg::Group; if (rootNode()) rootNode()->addChild(_occluders.get()); } _occluders->addChild(occluderNode); std::cout<<"created occluder"<<std::endl; } else { std::cout<<"Occluder requires at least 3 points to create occluder."<<std::endl; } } else { std::cout<<"No occluder points to create occluder with."<<std::endl; } // reset current occluder. _convexPlanarOccluder = NULL; }
void OccluderEventHandler::addPoint(const osg::Vec3& pos) { std::cout<<"add point "<<pos<<std::endl; if (!_convexPlanarOccluder.valid()) _convexPlanarOccluder = new osg::ConvexPlanarOccluder; osg::ConvexPlanarPolygon& occluder = _convexPlanarOccluder->getOccluder(); occluder.add(pos); // // osg::BoundingSphere bs = rootNode()->getBound(); // // osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(pos,bs.radius()*0.001f)); // osg::Geode* geode = new osg::Geode; // geode->addDrawable(sd); // // rootNode()->addChild(geode); // }