#ifndef XJXJLineIntersector_H #define XJXJLineIntersector_H #include #include /*! \class XJLineIntersector * \brief A class that allows to catch intersections with line loops and lines OpenGL types. * It uses shortest distance between the cast ray and the geometry line which is calculated * as a distance between skew lines. * In addition, it filters out the geometries whose primitive sets are different than line-types. */ class XJLineIntersector : public osgUtil::LineSegmentIntersector { public: XJLineIntersector(); XJLineIntersector(const osg::Vec3& start, const osg::Vec3& end); XJLineIntersector(CoordinateFrame cf, double x, double y); XJLineIntersector(CoordinateFrame cf, const osg::Vec3d& start, const osg::Vec3d& end); void setOffset(float offset); float getOffset() const; void getHitIndices(int& first, int& last) const; virtual Intersector* clone( osgUtil::IntersectionVisitor& iv ); virtual void intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable); bool isVirtualIntersector() const; protected: double getSkewLinesDistance(const osg::Vec3d &r1, const osg::Vec3d &r2, const osg::Vec3d &v1, const osg::Vec3d &v2); virtual bool isRightPrimitive(const osg::Geometry* geometry); float m_offset; std::vector m_hitIndices; osg::Matrix m_MVPW; }; #endif // XJLineIntersector_H