openscenegraph
AnimationPathManipulator
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 OSGGA_ANIMATION_PATH_MANIPULATOR
15#define OSGGA_ANIMATION_PATH_MANIPULATOR 1
16
17#include <osg/AnimationPath>
18#include <osg/Notify>
20
21namespace osgGA{
22
23//
24// The AnimationPathManipulator is a Matrix Manipulator that reads an
25// animation path from a file and plays it back. The file is expected
26// to be ascii and a succession of lines with 8 floating point values
27// per line. The succession of values are:
28// time px py pz ax ay az aw
29// where:
30// time = elapsed time in seconds from the beginning of the animation
31// px py pz = World position in cartesian coordinates
32// ax ay az aw = Orientation (attitude) defined as a quaternion
33
35{
36 public:
37
39
40 AnimationPathManipulator( const std::string& filename );
41
42 virtual const char* className() const { return "AnimationPath"; }
43
44 void setTimeScale(double s) { _timeScale = s; }
45 double getTimeScale() const { return _timeScale; }
46
47 void setTimeOffset(double o) { _timeOffset = o; }
48 double getTimeOffset() const { return _timeOffset; }
49
51 {
52 virtual void completed(const AnimationPathManipulator* apm) = 0;
53 };
54
55 void setAnimationCompletedCallback(AnimationCompletedCallback* acc) { _animationCompletedCallback = acc; }
56 AnimationCompletedCallback* getAnimationCompletedCallback() { return _animationCompletedCallback.get(); }
57 const AnimationCompletedCallback* getAnimationCompletedCallback() const { return _animationCompletedCallback.get(); }
58
59 void setPrintOutTimingInfo(bool printOutTimingInfo) { _printOutTimingInfo=printOutTimingInfo; }
60 bool getPrintOutTimingInfo() const { return _printOutTimingInfo; }
61
63 virtual void setByMatrix(const osg::Matrixd& matrix) { _matrix = matrix; }
64
66 virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _matrix.invert(matrix); }
67
69 virtual osg::Matrixd getMatrix() const { return _matrix; }
70
72 virtual osg::Matrixd getInverseMatrix() const { return osg::Matrixd::inverse(_matrix); }
73
74
75 void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
76
77 osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
78
79 const osg::AnimationPath* getAnimationPath() const { return _animationPath.get(); }
80
81 bool valid() const { return _animationPath.valid(); }
82
84
86 void home(double currentTime);
87
88 virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
89
91 virtual void getUsage(osg::ApplicationUsage& usage) const;
92
93 protected:
94
95 bool _valid;
96
98
99 void handleFrame( double time );
100
102
105
107
110
114
116
117};
118
119}
120
121#endif
Definition AnimationPathManipulator:35
bool valid() const
Definition AnimationPathManipulator:81
void setTimeOffset(double o)
Definition AnimationPathManipulator:47
AnimationPathManipulator(const std::string &filename)
osg::Matrixd _matrix
Definition AnimationPathManipulator:115
void setAnimationPath(osg::AnimationPath *animationPath)
Definition AnimationPathManipulator:75
AnimationCompletedCallback * getAnimationCompletedCallback()
Definition AnimationPathManipulator:56
void home(const GUIEventAdapter &ea, GUIActionAdapter &us)
double _timeScale
Definition AnimationPathManipulator:104
double getTimeOffset() const
Definition AnimationPathManipulator:48
virtual const char * className() const
Definition AnimationPathManipulator:42
osg::ref_ptr< osg::AnimationPath > _animationPath
Definition AnimationPathManipulator:101
void setPrintOutTimingInfo(bool printOutTimingInfo)
Definition AnimationPathManipulator:59
double _pauseTime
Definition AnimationPathManipulator:108
bool _valid
Definition AnimationPathManipulator:95
double _realStartOfTimedPeriod
Definition AnimationPathManipulator:111
AnimationPathManipulator(osg::AnimationPath *animationPath=0)
bool getPrintOutTimingInfo() const
Definition AnimationPathManipulator:60
void setTimeScale(double s)
Definition AnimationPathManipulator:44
virtual bool handle(const GUIEventAdapter &ea, GUIActionAdapter &us)
const AnimationCompletedCallback * getAnimationCompletedCallback() const
Definition AnimationPathManipulator:57
bool _printOutTimingInfo
Definition AnimationPathManipulator:97
double getTimeScale() const
Definition AnimationPathManipulator:45
void setAnimationCompletedCallback(AnimationCompletedCallback *acc)
Definition AnimationPathManipulator:55
double _timeOffset
Definition AnimationPathManipulator:103
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Definition AnimationPathManipulator:66
bool _isPaused
Definition AnimationPathManipulator:109
osg::ref_ptr< AnimationCompletedCallback > _animationCompletedCallback
Definition AnimationPathManipulator:106
void home(double currentTime)
virtual void getUsage(osg::ApplicationUsage &usage) const
virtual void setByMatrix(const osg::Matrixd &matrix)
Definition AnimationPathManipulator:63
osg::AnimationPath * getAnimationPath()
Definition AnimationPathManipulator:77
const osg::AnimationPath * getAnimationPath() const
Definition AnimationPathManipulator:79
double _animStartOfTimedPeriod
Definition AnimationPathManipulator:112
virtual osg::Matrixd getInverseMatrix() const
Definition AnimationPathManipulator:72
virtual osg::Matrixd getMatrix() const
Definition AnimationPathManipulator:69
void init(const GUIEventAdapter &ea, GUIActionAdapter &us)
int _numOfFramesSinceStartOfTimedPeriod
Definition AnimationPathManipulator:113
Definition CameraManipulator:40
Definition GUIActionAdapter:62
Definition GUIEventAdapter:82
Definition AnimationPath:34
Definition ApplicationUsage:26
Definition Matrixd:27
static Matrixd inverse(const Matrixd &matrix)
Definition Matrixd:536
Definition Referenced:44
Definition ref_ptr:32
Definition Callback:21
#define OSGGA_EXPORT
Definition osgGA/Export:40
virtual void completed(const AnimationPathManipulator *apm)=0