OpenSceneGraph 3.6.5
StandardManipulator
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 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 * StandardManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
14 * while some pieces of code were taken from OSG.
15 * Thanks to company Cadwork (www.cadwork.ch) and
16 * Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
17*/
18
19#ifndef OSGGA_CAMERA_MANIPULATOR
20#define OSGGA_CAMERA_MANIPULATOR 1
21
23
24
25namespace osgGA {
26
27
31{
32 typedef CameraManipulator inherited;
33
34 public:
35
36 // flags
45
48 const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
49
50 // We are not using META_Object as this is abstract class.
51 // Use META_Object(osgGA,YourManipulator); in your descendant non-abstract classes.
52 virtual const char* className() const { return "StandardManipulator"; }
53
55 virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation ) = 0;
56
58 virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up ) = 0;
59
61 virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const = 0;
62
64 virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const = 0;
65
66 virtual void setNode( osg::Node* );
67 virtual const osg::Node* getNode() const;
68 virtual osg::Node* getNode();
69
70 virtual void setVerticalAxisFixed( bool value );
71 inline bool getVerticalAxisFixed() const;
72 inline bool getAllowThrow() const;
73 virtual void setAllowThrow( bool allowThrow );
74
75 virtual void setAnimationTime( const double t );
76 double getAnimationTime() const;
77 bool isAnimating() const;
78 virtual void finishAnimation();
79
80 virtual void home( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
81 virtual void home( double );
82
83 virtual void init( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
85 virtual void getUsage( osg::ApplicationUsage& usage ) const;
86
87 protected:
88
99
100 virtual bool performMovement();
101 virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
102 virtual bool performMovementMiddleMouseButton( const double eventTimeDelta, const double dx, const double dy );
103 virtual bool performMovementRightMouseButton( const double eventTimeDelta, const double dx, const double dy );
104 virtual bool performMouseDeltaMovement( const float dx, const float dy );
106 virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
107
110 virtual bool isMouseMoving() const;
111 float getThrowScale( const double eventTimeDelta ) const;
113
114 static void rotateYawPitch( osg::Quat& rotation, const double yaw, const double pitch,
115 const osg::Vec3d& localUp = osg::Vec3d( 0.,0.,0.) );
116 static void fixVerticalAxis( osg::Quat& rotation, const osg::Vec3d& localUp, bool disallowFlipOver );
117 void fixVerticalAxis( osg::Vec3d& eye, osg::Quat& rotation, bool disallowFlipOver );
118 static void fixVerticalAxis( const osg::Vec3d& forward, const osg::Vec3d& up, osg::Vec3d& newUp,
119 const osg::Vec3d& localUp, bool disallowFlipOver );
122
123 // mouse state
127
128 // internal event stack comprising last two mouse events.
131
137
142
143 // scene data
147
148 // animation stuff
150 public:
154 double _phase;
155
157 void start( const double startTime );
158 };
161
162 // flags
164
165 // flags indicating that a value is relative to model size
167 inline bool getRelativeFlag( int index ) const;
168 inline void setRelativeFlag( int index, bool value );
171};
172
173
174//
175// inline methods
176//
177
178inline bool StandardManipulator::getRelativeFlag( int index ) const
179{
180 return ( _relativeFlags & (0x01 << index) ) != 0;
181}
182
183inline void StandardManipulator::setRelativeFlag( int index, bool value )
184{
185 if( value ) _relativeFlags |= (0x01 << index);
186 else _relativeFlags &= ~(0x01 << index);
187}
188
191{
192 return _verticalAxisFixed;
193}
194
197{
198 return _allowThrow;
199}
200
201
202}
203
204#endif /* OSGGA_CAMERA_MANIPULATOR */
The 'GA' in osgGA stands for 'GUI Abstraction'; the osgGA namespace provides facilities to help devel...
Definition Callback:21
Definition ApplicationUsage:26
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Base class for all internal nodes in the scene graph.
Definition Node:72
A quaternion class.
Definition Quat:30
Base class for providing reference counted objects.
Definition Referenced:44
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 _last_frame_time
The time the last frame started.
Definition StandardManipulator:141
StandardManipulator(const StandardManipulator &m, const osg::CopyOp &copyOp=osg::CopyOp::SHALLOW_COPY)
virtual const char * className() const
return the name of the object's class type.
Definition StandardManipulator:52
virtual bool handleMouseRelease(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
double _delta_frame_time
The approximate amount of time it is currently taking to draw a frame.
Definition StandardManipulator:136
virtual void getTransformation(osg::Vec3d &eye, osg::Vec3d &center, osg::Vec3d &up) const =0
Gets manipulator's focal center, eye position, and up vector.
virtual void getTransformation(osg::Vec3d &eye, osg::Quat &rotation) const =0
Gets manipulator's eye position and eye orientation.
virtual void setTransformation(const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up)=0
Sets manipulator by eye position, center of rotation, and up vector.
StandardManipulator(int flags=DEFAULT_SETTINGS)
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t0
Definition StandardManipulator:130
virtual void init(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Start/restart the manipulator.
static int numRelativeFlagsAllocated
Definition StandardManipulator:169
virtual bool handleKeyUp(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
static void rotateYawPitch(osg::Quat &rotation, const double yaw, const double pitch, const osg::Vec3d &localUp=osg::Vec3d(0., 0., 0.))
virtual bool performMovementLeftMouseButton(const double eventTimeDelta, const double dx, const double dy)
virtual void applyAnimationStep(const double currentProgress, const double prevProgress)
virtual bool handleMouseMove(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
bool getVerticalAxisFixed() const
Returns whether manipulator preserves camera's "UP" vector.
Definition StandardManipulator:190
virtual bool handleFrame(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual const osg::Node * getNode() const
Return const node if attached.
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Handle events, return true if handled, false otherwise.
virtual bool performMovement()
virtual void home(double)
Move the camera to the default position.
bool _thrown
Definition StandardManipulator:124
static int allocateRelativeFlag()
virtual void getUsage(osg::ApplicationUsage &usage) const
Get the user interface usage of this event handler, i.e.
virtual bool performAnimationMovement(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual bool isMouseMoving() const
virtual bool performMouseDeltaMovement(const float dx, const float dy)
virtual bool handleMousePush(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual bool startAnimationByMousePointerIntersection(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual void setAnimationTime(const double t)
double _modelSize
Definition StandardManipulator:145
bool getRelativeFlag(int index) const
Definition StandardManipulator:178
virtual void setTransformation(const osg::Vec3d &eye, const osg::Quat &rotation)=0
Sets manipulator by eye position and eye orientation.
virtual bool handleMouseDeltaMovement(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual bool performMovementRightMouseButton(const double eventTimeDelta, const double dx, const double dy)
UserInteractionFlags
Definition StandardManipulator:38
@ COMPUTE_HOME_USING_BBOX
Definition StandardManipulator:40
@ PROCESS_MOUSE_WHEEL
Definition StandardManipulator:41
@ UPDATE_MODEL_SIZE
Definition StandardManipulator:39
@ DEFAULT_SETTINGS
Definition StandardManipulator:43
@ SET_CENTER_ON_WHEEL_FORWARD_MOVEMENT
Definition StandardManipulator:42
virtual bool setCenterByMousePointerIntersection(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
float _mouseCenterX
Definition StandardManipulator:126
int _relativeFlags
Definition StandardManipulator:166
virtual osg::Node * getNode()
Return node if attached.
virtual bool handleMouseWheel(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual void home(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
Move the camera to the default position.
virtual void finishAnimation()
finish any active manipulator animations.
virtual void setVerticalAxisFixed(bool value)
float getThrowScale(const double eventTimeDelta) const
void setRelativeFlag(int index, bool value)
Definition StandardManipulator:183
virtual bool performMovementMiddleMouseButton(const double eventTimeDelta, const double dx, const double dy)
virtual void setNode(osg::Node *)
Attach a node to the manipulator, automatically detaching any previously attached node.
double getAnimationTime() const
virtual bool handleMouseDrag(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osg::ref_ptr< AnimationData > _animationData
Definition StandardManipulator:159
int _flags
Definition StandardManipulator:163
virtual void centerMousePointer(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
static void fixVerticalAxis(osg::Quat &rotation, const osg::Vec3d &localUp, bool disallowFlipOver)
bool _verticalAxisFixed
Definition StandardManipulator:146
void fixVerticalAxis(osg::Vec3d &eye, osg::Quat &rotation, bool disallowFlipOver)
osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t1
Definition StandardManipulator:129
virtual bool handleKeyDown(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
virtual void setAllowThrow(bool allowThrow)
float _mouseCenterY
Definition StandardManipulator:126
virtual bool handleResize(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
static void fixVerticalAxis(const osg::Vec3d &forward, const osg::Vec3d &up, osg::Vec3d &newUp, const osg::Vec3d &localUp, bool disallowFlipOver)
virtual void allocAnimationData()
Definition StandardManipulator:160
bool getAllowThrow() const
Returns true if the camera can be thrown, false otherwise. It defaults to true.
Definition StandardManipulator:196
void addMouseEvent(const osgGA::GUIEventAdapter &ea)
osg::ref_ptr< osg::Node > _node
Definition StandardManipulator:144
bool _allowThrow
Definition StandardManipulator:125
Definition StandardManipulator:149
double _animationTime
Definition StandardManipulator:151
bool _isAnimating
Definition StandardManipulator:152
void start(const double startTime)
double _startTime
Definition StandardManipulator:153
double _phase
Definition StandardManipulator:154
#define OSGGA_EXPORT
Definition Export:40

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