OpenSceneGraph 3.6.5
SphericalManipulator
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 __SphericalManipulator_h__
15#define __SphericalManipulator_h__
16
18#include <osg/Math>
19#include <osg/Quat>
20
21namespace osgGA
22{
23
25{
26 public:
28
29 virtual const char* className() const { return "Spherical Manipulator"; }
30
32 virtual void setByMatrix(const osg::Matrixd& matrix);
33
35 virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
36
38 virtual osg::Matrixd getMatrix() const;
39
42
45
47 virtual float getFusionDistanceValue() const { return _distance; }
48
53 virtual void setNode(osg::Node*);
54
56 virtual const osg::Node* getNode() const;
57
59 virtual osg::Node* getNode();
60
64 virtual void home(double);
65
68
69 void zoomOn(const osg::BoundingSphere& bound);
70
73
75 virtual void computeHomePosition();
76
77 void computeViewPosition(const osg::BoundingSphere& bound,double& scale,double& distance,osg::Vec3d& center);
78
79 void setCenter(const osg::Vec3d& center) {_center=center;}
80 const osg::Vec3d& getCenter() const {return _center;}
81
82 bool setDistance(double distance);
83 double getDistance() const { return _distance; }
84
85 double getHomeDistance() const { return _homeDistance; }
86
87 void setHeading(double azimuth) { _heading = azimuth; }
88 double getHeading() const {return _heading;}
89
90 void setElevation(double elevation) { _elevation = elevation; }
91 double getElevtion() const {return _elevation;}
92
93
95 double getMinimumZoomScale() const { return _minimumZoomScale; }
96
99 void setMinimumZoomScale(double minimumZoomScale) {_minimumZoomScale=minimumZoomScale;}
100
101
104 void setScroolWheelZoomDelta(double zoomDelta) { _zoomDelta = zoomDelta; }
105
107 double getScroolWheelZoomDelta() const { return _zoomDelta; }
108
109
111 virtual void getUsage(osg::ApplicationUsage& usage) const;
112
120
123
125 bool getAllowThrow() const { return _allowThrow; }
127 void setAllowThrow(bool allowThrow) { _allowThrow = allowThrow; }
128
129 protected:
130
132
137
141
145
146 // Internal event stack comprising last two mouse events.
149
151
154
157
163
168
171 double _distance;
172 double _heading; // angle from x axis in xy plane
173 double _elevation; // angle from xy plane, positive upwards towards the z axis
176};
177}
178#endif
BoundingSphered BoundingSphere
Definition BoundingSphere:308
The 'GA' in osgGA stands for 'GUI Abstraction'; the osgGA namespace provides facilities to help devel...
Definition Callback:21
Definition ApplicationUsage:26
Definition Matrixd:27
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 observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Definition GUIActionAdapter:62
Event class for storing Keyboard, mouse and window events.
Definition GUIEventAdapter:82
double getDistance() const
Definition SphericalManipulator:83
double getElevtion() const
Definition SphericalManipulator:91
void setAllowThrow(bool allowThrow)
Set the 'allow throw' flag.
Definition SphericalManipulator:127
virtual void init(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Start/restart the manipulator.
virtual void home(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Move the camera to the default position.
double _homeDistance
Definition SphericalManipulator:174
bool calcMovement()
For the give mouse movement calculate the movement of the camera.
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t1
Definition SphericalManipulator:147
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
Get the FusionDistanceMode.
Definition SphericalManipulator:44
void computeViewPosition(const osg::BoundingSphere &bound, double &scale, double &distance, osg::Vec3d &center)
virtual void home(double)
Move the camera to the default position.
void zoomOn(const osg::BoundingSphere &bound)
double _modelScale
Definition SphericalManipulator:152
double _elevation
Definition SphericalManipulator:173
double _minimumZoomScale
Definition SphericalManipulator:153
virtual void setNode(osg::Node *)
Attach a node to the manipulator.
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
handle events, return true if handled, false otherwise.
void setElevation(double elevation)
Definition SphericalManipulator:90
void flushMouseEventStack()
Reset the internal GUIEvent stack.
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
set the position of the matrix manipulator using a 4x4 Matrix.
Definition SphericalManipulator:35
double _last_frame_time
The time the last frame started.
Definition SphericalManipulator:167
double _distance
Definition SphericalManipulator:171
virtual osg::Matrixd getInverseMatrix() const
get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...
RotationMode getRotationMode() const
Definition SphericalManipulator:121
double _delta_frame_time
The approximate amount of time it is currently taking to draw a frame.
Definition SphericalManipulator:162
void setMinimumZoomScale(double minimumZoomScale)
set the minimum distance (as ratio) the eye point can be zoomed in towards the center before the cent...
Definition SphericalManipulator:99
const osg::Vec3d & getCenter() const
Definition SphericalManipulator:80
virtual const char * className() const
return the name of the object's class type.
Definition SphericalManipulator:29
void setCenter(const osg::Vec3d &center)
Definition SphericalManipulator:79
void setHeading(double azimuth)
Definition SphericalManipulator:87
void setRotationMode(RotationMode mode)
double getMinimumZoomScale() const
get the minimum distance (as ratio) the eye point can be zoomed in
Definition SphericalManipulator:95
virtual void setByMatrix(const osg::Matrixd &matrix)
set the position of the matrix manipulator using a 4x4 Matrix.
void setScroolWheelZoomDelta(double zoomDelta)
set the mouse scroll wheel zoom delta.
Definition SphericalManipulator:104
bool getAllowThrow() const
Returns true if the camera can be thrown, false otherwise.
Definition SphericalManipulator:125
osg::Vec3d _center
Definition SphericalManipulator:170
virtual const osg::Node * getNode() const
Return node if attached.
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t0
Definition SphericalManipulator:148
RotationMode
Definition SphericalManipulator:114
@ ELEVATION_HEADING
Definition SphericalManipulator:115
@ HEADING
Definition SphericalManipulator:116
@ ELEVATION
Definition SphericalManipulator:117
@ MAP
Definition SphericalManipulator:118
RotationMode _rotationMode
Definition SphericalManipulator:169
bool _thrown
Definition SphericalManipulator:155
double getScroolWheelZoomDelta() const
get the mouse scroll wheel zoom delta.
Definition SphericalManipulator:107
double _heading
Definition SphericalManipulator:172
virtual osg::Matrixd getMatrix() const
get the position of the manipulator as 4x4 Matrix.
virtual void getUsage(osg::ApplicationUsage &usage) const
Get the keyboard and mouse usage of this manipulator.
virtual float getFusionDistanceValue() const
Get the FusionDistanceValue.
Definition SphericalManipulator:47
double getHeading() const
Definition SphericalManipulator:88
virtual osg::Node * getNode()
Return node if attached.
void addMouseEvent(const osgGA::GUIEventAdapter &ea)
Add the current mouse GUIEvent to internal stack.
bool isMouseMoving()
Check the speed at which the mouse is moving.
virtual void computeHomePosition()
Compute the home position.
bool setDistance(double distance)
osg::observer_ptr< osg::Node > _node
Definition SphericalManipulator:150
double _zoomDelta
Definition SphericalManipulator:175
double getHomeDistance() const
Definition SphericalManipulator:85
bool _allowThrow
Definition SphericalManipulator:156
FusionDistanceMode
FusionDistanceMode is used only when working in stereo.
Definition SceneView:339
@ USE_FUSION_DISTANCE_VALUE
Use fusion distance from the value set on the SceneView.
Definition SceneView:341
#define OSGGA_EXPORT
Definition Export:40

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