OpenSceneGraph 3.6.5
Projector
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//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
14
15#ifndef OSGMANIPULATOR_PROJECTOR
16#define OSGMANIPULATOR_PROJECTOR 1
17
18#include <osgManipulator/Export>
19
20#include <osg/LineSegment>
21#include <osgUtil/SceneView>
22
24
25namespace osgManipulator {
26
31{
32 public:
33
35
43 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const = 0;
44
49 void setLocalToWorld(const osg::Matrix& localToWorld)
50 {
51 _localToWorld = localToWorld;
52 _worldToLocalDirty = true;
53 }
54
59 inline const osg::Matrix& getLocalToWorld() const { return _localToWorld; }
60
65 inline const osg::Matrix& getWorldToLocal() const
66 {
68 {
70 _worldToLocalDirty = false;
71 }
72 return _worldToLocal;
73 }
74
75 protected:
76
77 virtual ~Projector();
78
81
82 mutable bool _worldToLocalDirty;
83};
84
85
90{
91 public:
92
94
96
97 inline void setLine(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e) { _line->start() = s; _line->end() = e; }
98
99 inline const osg::LineSegment::vec_type& getLineStart() const { return _line->start(); }
100 inline osg::LineSegment::vec_type& getLineStart() { return _line->start(); }
101
102 inline const osg::LineSegment::vec_type& getLineEnd() const { return _line->end(); }
103 inline osg::LineSegment::vec_type& getLineEnd() { return _line->end(); }
104
110 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
111
112 protected:
113
114 virtual ~LineProjector();
115
117};
118
123{
124 public:
125
127
129
130 inline void setPlane(const osg::Plane& plane) { _plane = plane; }
131 inline const osg::Plane& getPlane() const { return _plane; }
132
138 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
139
140 protected:
141
143
145};
146
151{
152 public:
153
155
157
158 inline void setSphere(osg::Sphere* sphere) { _sphere = sphere; }
159 inline const osg::Sphere* getSphere() const { return _sphere.get(); }
160
166 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
167
172 bool isPointInFront(const PointerInfo& pi, const osg::Matrix& localToWorld) const;
173
174 void setFront(bool front) { _front = front; }
175
176 protected:
177
179
181 bool _front;
182};
183
189{
190 public:
191
193
195
201 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
202
207 bool isProjectionOnSphere() const { return _onSphere; }
208
209 osg::Quat getRotation(const osg::Vec3d& p1, bool p1OnSphere,
210 const osg::Vec3d& p2, bool p2OnSphere,
211 float radialFactor = 0.0f) const;
212
213 protected:
214
216
218 mutable bool _onSphere;
219};
220
225{
226 public:
227
229
231
232 inline void setCylinder(osg::Cylinder* cylinder)
233 {
234 _cylinder = cylinder;
235 _cylinderAxis = osg::Vec3d(0.0,0.0,1.0) * osg::Matrix(cylinder->getRotation());
236 _cylinderAxis.normalize();
237 }
238 inline const osg::Cylinder* getCylinder() const { return _cylinder.get(); }
239
245 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
246
247
252 bool isPointInFront(const PointerInfo& pi, const osg::Matrix& localToWorld) const;
253
254 void setFront(bool front) { _front = front; }
255
256 protected:
257
259
262 bool _front;
263};
264
273{
274 public:
275
277
279
288 virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
289
297 osg::Quat getRotation(const osg::Vec3d& p1, const osg::Vec3d& p2) const;
298
299 protected:
300
302
305 mutable bool _parallelPlane;
306};
307
308}
309
310#endif
Matrixd Matrix
Definition Matrix:27
The osgManipulator library is a NodeKit that extends the core scene graph to support 3D interactive m...
Definition AntiSquish:23
Vec3d vec_type
Definition LineSegment:28
A plane class.
Definition Plane:34
A quaternion class.
Definition Quat:30
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Definition Shape:147
Definition Shape:304
const Quat & getRotation() const
Definition Shape:345
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Definition Dragger:84
const osg::Matrix & getWorldToLocal() const
Gets the matrix for transforming the world/object coordinate system to the command's local coordinate...
Definition Projector:65
const osg::Matrix & getLocalToWorld() const
Gets the matrix for transforming the projector's local coordinate system to the world/object coordina...
Definition Projector:59
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const =0
Calculates the object/world coordinates (projectedPoint) of a window coordinate (pointToProject) when...
bool _worldToLocalDirty
Definition Projector:82
void setLocalToWorld(const osg::Matrix &localToWorld)
Sets the matrix for transforming the projector's local coordinate system to the world/object coordina...
Definition Projector:49
osg::Matrix _worldToLocal
Definition Projector:80
osg::Matrix _localToWorld
Definition Projector:79
osg::ref_ptr< osg::LineSegment > _line
Definition Projector:116
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
const osg::LineSegment::vec_type & getLineEnd() const
Definition Projector:102
osg::LineSegment::vec_type & getLineStart()
Definition Projector:100
const osg::LineSegment::vec_type & getLineStart() const
Definition Projector:99
void setLine(const osg::LineSegment::vec_type &s, const osg::LineSegment::vec_type &e)
Definition Projector:97
osg::LineSegment::vec_type & getLineEnd()
Definition Projector:103
LineProjector(const osg::LineSegment::vec_type &s, const osg::LineSegment::vec_type &e)
void setPlane(const osg::Plane &plane)
Definition Projector:130
const osg::Plane & getPlane() const
Definition Projector:131
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
osg::Plane _plane
Definition Projector:144
PlaneProjector(const osg::Plane &plane)
void setFront(bool front)
Definition Projector:174
const osg::Sphere * getSphere() const
Definition Projector:159
SphereProjector(osg::Sphere *sphere)
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
void setSphere(osg::Sphere *sphere)
Definition Projector:158
osg::ref_ptr< osg::Sphere > _sphere
Definition Projector:180
bool isPointInFront(const PointerInfo &pi, const osg::Matrix &localToWorld) const
Returns true is the point is in front of the cylinder given the eye direction.
bool _front
Definition Projector:181
osg::Plane _plane
Definition Projector:217
bool isProjectionOnSphere() const
Returns true if the previous projection was on the sphere and false if the projection was on the plan...
Definition Projector:207
osg::Quat getRotation(const osg::Vec3d &p1, bool p1OnSphere, const osg::Vec3d &p2, bool p2OnSphere, float radialFactor=0.0f) const
bool _onSphere
Definition Projector:218
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
SpherePlaneProjector(osg::Sphere *sphere)
osg::ref_ptr< osg::Cylinder > _cylinder
Definition Projector:260
bool _front
Definition Projector:262
const osg::Cylinder * getCylinder() const
Definition Projector:238
bool isPointInFront(const PointerInfo &pi, const osg::Matrix &localToWorld) const
Returns true is the point is in front of the cylinder given the eye direction.
CylinderProjector(osg::Cylinder *cylinder)
void setCylinder(osg::Cylinder *cylinder)
Definition Projector:232
osg::Vec3d _cylinderAxis
Definition Projector:261
void setFront(bool front)
Definition Projector:254
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
osg::Plane _plane
Definition Projector:303
osg::Vec3d _planeLineStart
Definition Projector:304
osg::Quat getRotation(const osg::Vec3d &p1, const osg::Vec3d &p2) const
Generates a rotation about the cylinder axis based upon the incoming projected points on the plane co...
bool _parallelPlane
Definition Projector:305
osg::Vec3d _planeLineEnd
Definition Projector:304
CylinderPlaneProjector(osg::Cylinder *cylinder)
virtual bool project(const PointerInfo &pi, osg::Vec3d &projectedPoint) const
Calculates the object coordinates (projectedPoint) of a window coordinate (pointToProject) when proje...
#define OSGMANIPULATOR_EXPORT
Definition Export:27

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