OpenSceneGraph 3.6.5
RayIntersector
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_RAYINTERSECTOR
15#define OSGUTIL_RAYINTERSECTOR 1
16
18
19namespace osgUtil
20{
21
33{
34 public:
35
40
43 RayIntersector(const osg::Vec3d& start, const osg::Vec3d& direction);
44
46 RayIntersector(CoordinateFrame cf, const osg::Vec3d& start, const osg::Vec3d& direction, RayIntersector* parent = NULL,
48
53 RayIntersector(CoordinateFrame cf, double x, double y);
54
85
86 typedef std::multiset<Intersection> Intersections;
87
88 inline void insertIntersection(const Intersection& intersection) { getIntersections().insert(intersection); }
89 inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
90 inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
91
92 virtual void setStart(const osg::Vec3d& start) { _start = start; }
93 inline const osg::Vec3d& getStart() const { return _start; }
94
95 virtual void setDirection(const osg::Vec3d& dir) { _direction = dir; }
96 inline const osg::Vec3d& getDirection() const { return _direction; }
97
98 public:
99
101
102 virtual bool enter(const osg::Node& node);
103
104 virtual void leave();
105
107
108 virtual void reset();
109
110 virtual bool containsIntersections() { return !getIntersections().empty(); }
111
112 protected:
113
114 virtual bool intersects(const osg::BoundingSphere& bs);
116
118
121
123
124};
125
126}
127
128#endif
Vec3f Vec3
Definition Vec3:21
BoundingBoxd BoundingBox
Definition BoundingBox:257
BoundingSphered BoundingSphere
Definition BoundingSphere:308
std::vector< Node * > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant.
Definition Node:47
The osgUtil library provides general purpose utility classes such as update, cull and draw traverses,...
Definition NodeVisitor:25
Pure virtual base class for drawable geometry.
Definition Drawable:89
static Vec3f transform3x3(const Vec3f &v, const Matrixd &m)
apply a 3x3 transform of v*M[0..2,0..2].
Definition Matrixd:665
static Matrixd inverse(const Matrixd &matrix)
Definition Matrixd:536
Base class for all internal nodes in the scene graph.
Definition Node:72
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Texture pure virtual base class that encapsulates OpenGL texture functionality common to the various ...
Definition Texture:422
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
IntersectionLimit
Definition IntersectionVisitor:46
@ NO_LIMIT
Definition IntersectionVisitor:47
CoordinateFrame
Definition IntersectionVisitor:38
@ MODEL
Definition IntersectionVisitor:42
Intersector(CoordinateFrame cf=MODEL, IntersectionLimit il=NO_LIMIT)
Definition IntersectionVisitor:53
IntersectionVisitor is used to testing for intersections with the scene, traversing the scene using g...
Definition IntersectionVisitor:152
RayIntersector(const osg::Vec3d &start, const osg::Vec3d &direction)
Construct a RayIntersector that runs from start point in specified direction to the infinity.
virtual void setStart(const osg::Vec3d &start)
Definition RayIntersector:92
virtual bool enter(const osg::Node &node)
bool intersectAndClip(osg::Vec3d &s, const osg::Vec3d &d, osg::Vec3d &e, const osg::BoundingBox &bb)
virtual void reset()
const osg::Vec3d & getDirection() const
Definition RayIntersector:96
osg::Vec3d _start
Definition RayIntersector:119
Intersection getFirstIntersection()
Definition RayIntersector:90
osg::Vec3d _direction
Definition RayIntersector:120
virtual void setDirection(const osg::Vec3d &dir)
Definition RayIntersector:95
Intersections _intersections
Definition RayIntersector:122
RayIntersector * _parent
Definition RayIntersector:117
void insertIntersection(const Intersection &intersection)
Definition RayIntersector:88
RayIntersector(CoordinateFrame cf, double x, double y)
Convenience constructor for supporting picking in WINDOW and PROJECTION coordinates.
RayIntersector(CoordinateFrame cf=MODEL, RayIntersector *parent=NULL, osgUtil::Intersector::IntersectionLimit intersectionLimit=osgUtil::Intersector::NO_LIMIT)
Construct a RayIntersector.
RayIntersector(CoordinateFrame cf, const osg::Vec3d &start, const osg::Vec3d &direction, RayIntersector *parent=NULL, osgUtil::Intersector::IntersectionLimit intersectionLimit=osgUtil::Intersector::NO_LIMIT)
Construct a RayIntersector the runs from start point in specified direction to the infinity in the sp...
std::multiset< Intersection > Intersections
Definition RayIntersector:86
virtual Intersector * clone(osgUtil::IntersectionVisitor &iv)
virtual void intersect(osgUtil::IntersectionVisitor &iv, osg::Drawable *drawable)
virtual void leave()
Intersections & getIntersections()
Definition RayIntersector:89
virtual bool containsIntersections()
Definition RayIntersector:110
virtual bool intersects(const osg::BoundingSphere &bs)
const osg::Vec3d & getStart() const
Definition RayIntersector:93
Definition RayIntersector:56
osg::ref_ptr< osg::RefMatrix > matrix
Definition RayIntersector:67
osg::Vec3d getWorldIntersectPoint() const
Definition RayIntersector:75
std::vector< double > RatioList
Definition RayIntersector:62
double distance
Definition RayIntersector:64
osg::Vec3d localIntersectionPoint
Definition RayIntersector:68
RatioList ratioList
Definition RayIntersector:71
osg::NodePath nodePath
Definition RayIntersector:65
const osg::Vec3 & getLocalIntersectNormal() const
Definition RayIntersector:77
IndexList indexList
Definition RayIntersector:70
osg::Texture * getTextureLookUp(osg::Vec3 &tc) const
Convenience function for mapping the intersection point to any textures assigned to the objects inter...
osg::ref_ptr< osg::Drawable > drawable
Definition RayIntersector:66
osg::Vec3 getWorldIntersectNormal() const
Definition RayIntersector:78
const osg::Vec3d & getLocalIntersectPoint() const
Definition RayIntersector:74
std::vector< unsigned int > IndexList
Definition RayIntersector:61
unsigned int primitiveIndex
Definition RayIntersector:72
osg::Vec3 localIntersectionNormal
Definition RayIntersector:69
Intersection()
Definition RayIntersector:57
#define NULL
Definition Export:55
#define OSGUTIL_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.