Added beginnings of osgUtil::PlaneIntersector and osgSim::ElevationSlice
This commit is contained in:
@@ -215,6 +215,67 @@ class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
|
||||
};
|
||||
|
||||
/** Concrent class for implementing polytope intersections with the scene graph.
|
||||
* To be used in conjunction with IntersectionVisitor. */
|
||||
class OSGUTIL_EXPORT PlaneIntersector : public Intersector
|
||||
{
|
||||
public:
|
||||
|
||||
/** Construct a PolytopeIntersector using speified polytope in MODEL coordinates.*/
|
||||
PlaneIntersector(const osg::Plane& plane, const osg::Polytope& boundingPolytope=osg::Polytope());
|
||||
|
||||
/** Construct a PolytopeIntersector using speified polytope in specified coordinate frame.*/
|
||||
PlaneIntersector(CoordinateFrame cf, const osg::Plane& plane, const osg::Polytope& boundingPolytope=osg::Polytope());
|
||||
|
||||
struct Intersection
|
||||
{
|
||||
Intersection() {}
|
||||
|
||||
bool operator < (const Intersection& rhs) const
|
||||
{
|
||||
if (nodePath < rhs.nodePath) return true;
|
||||
if (rhs.nodePath < nodePath ) return false;
|
||||
return (drawable < rhs.drawable);
|
||||
}
|
||||
|
||||
osg::NodePath nodePath;
|
||||
osg::ref_ptr<osg::Drawable> drawable;
|
||||
};
|
||||
|
||||
typedef std::set<Intersection> Intersections;
|
||||
|
||||
inline void insertIntersection(const Intersection& intersection) { getIntersections().insert(intersection); }
|
||||
|
||||
inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
|
||||
|
||||
inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
|
||||
|
||||
public:
|
||||
|
||||
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);
|
||||
|
||||
virtual bool enter(const osg::Node& node);
|
||||
|
||||
virtual void leave();
|
||||
|
||||
virtual void intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual bool containsIntersections() { return !_intersections.empty(); }
|
||||
|
||||
protected:
|
||||
|
||||
PlaneIntersector* _parent;
|
||||
|
||||
osg::Plane _plane;
|
||||
osg::Polytope _polytope;
|
||||
|
||||
Intersections _intersections;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** Concrent class for passing multiple intersectors through the scene graph.
|
||||
* To be used in conjunction with IntersectionVisitor. */
|
||||
class OSGUTIL_EXPORT IntersectorGroup : public Intersector
|
||||
|
||||
Reference in New Issue
Block a user