You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB
C++

#ifndef XJXJLineIntersector_H
#define XJXJLineIntersector_H
#include <vector>
#include <osgUtil/LineSegmentIntersector>
/*! \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<unsigned int> m_hitIndices;
osg::Matrix m_MVPW;
};
#endif // XJLineIntersector_H