SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLAnimation.h
Go to the documentation of this file.
1 /**
2  * \file SLAnimation.h
3  * \date Autumn 2014
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Marc Wacker, Marcus Hudritsch
7  * \copyright http://opensource.org/licenses/GPL-3.0
8 */
9 
10 #ifndef SLANIMATION_H
11 #define SLANIMATION_H
12 
13 #include <SLAnimTrack.h>
14 #include <SLEnums.h>
15 #include <SLJoint.h>
16 
17 class SLAnimSkeleton;
18 
19 //-----------------------------------------------------------------------------
20 //! SLAnimation is the base container for all animation data.
21 /*!
22 SLAnimation is a container for multiple SLAnimTrack that build an animation.
23 E.g. a walk animation would consist of all the SLAnimTrack that make a
24 SLAnimSkeleton walk. It also knows the length of the animation.
25 
26 An animation for a SLAnimSkeleton with n joints must consist of 1 to n
27 SLNodeAnimTrack. The SLAnimation class keeps a map with index -> SLNodeAnimTrack
28 pairs, the index for the SLNodeAnimTrack must match the index of a bone in the
29 target SLAnimSkeleton. This method allows us to animate multiple identical, or similar
30 SLSkeletons with the same SLAnimation.
31 */
33 {
34 public:
35  SLAnimation(const SLstring& name, SLfloat duration);
36  ~SLAnimation();
37 
40  SLbool affectsNode(SLNode* node);
41  void apply(SLfloat time,
42  SLfloat weight = 1.0f,
43  SLfloat scale = 1.0f);
44  void applyToNode(SLNode* node,
45  SLfloat time,
46  SLfloat weight = 1.0f,
47  SLfloat scale = 1.0f);
48  void apply(SLAnimSkeleton* skel,
49  SLfloat time,
50  SLfloat weight = 1.0f,
51  SLfloat scale = 1.0f);
52  void resetNodes();
54 
55  // track creators
59  SLNodeAnimTrack* createNodeAnimTrackForRotation(SLNode* target, SLfloat angleDeg1, const SLVec3f& axis);
60  SLNodeAnimTrack* createNodeAnimTrackForRotation2(SLNode* target, SLfloat angleDeg0, SLfloat angleDeg1, const SLVec3f& axis);
61  SLNodeAnimTrack* createNodeAnimTrackForRotation3(SLNode* target, SLfloat angleDeg0, SLfloat angleDeg1, SLfloat angleDeg2, const SLVec3f& axis);
62  SLNodeAnimTrack* createNodeAnimTrackForRotation4(SLNode* target, SLfloat angleDeg0, SLfloat angleDeg1, SLfloat angleDeg2, SLfloat angleDeg3, const SLVec3f& axis);
66  SLfloat radiusA,
67  SLAxis axisA,
68  SLfloat radiusB,
69  SLAxis axisB);
70  // Getters
71  const SLstring& name() { return _name; }
72  SLfloat lengthSec() const { return _lengthSec; }
73 
74  // Setters
75  void name(const SLstring& name) { _name = name; }
77 
78 protected:
79  SLstring _name; //!< name of the animation
80  SLfloat _lengthSec; //!< duration of the animation in seconds
81  SLMNodeAnimTrack _nodeAnimTracks; //!< map of all the node tracks in this animation
82 };
83 //-----------------------------------------------------------------------------
84 typedef vector<SLAnimation*> SLVAnimation;
85 typedef std::map<SLstring, SLAnimation*> SLMAnimation;
86 //-----------------------------------------------------------------------------
87 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
std::map< SLuint, SLNodeAnimTrack * > SLMNodeAnimTrack
Definition: SLAnimTrack.h:94
vector< SLAnimation * > SLVAnimation
Definition: SLAnimation.h:84
std::map< SLstring, SLAnimation * > SLMAnimation
Definition: SLAnimation.h:85
SLAxis
Coordinate axis enumeration.
Definition: SLEnums.h:79
SLAnimSkeleton keeps track of a skeletons joints and animations.
SLAnimation is the base container for all animation data.
Definition: SLAnimation.h:33
SLNodeAnimTrack * createNodeAnimTrackForRotation(SLNode *target, SLfloat angleDeg1, const SLVec3f &axis)
void drawNodeVisuals(SLSceneView *sv)
SLAnimation(const SLstring &name, SLfloat duration)
Definition: SLAnimation.cpp:16
SLNodeAnimTrack * createNodeAnimTrackForRotation360(SLNode *target, const SLVec3f &axis)
SLMNodeAnimTrack _nodeAnimTracks
map of all the node tracks in this animation
Definition: SLAnimation.h:81
SLNodeAnimTrack * createNodeAnimTrack()
Definition: SLAnimation.cpp:94
SLfloat _lengthSec
duration of the animation in seconds
Definition: SLAnimation.h:80
void name(const SLstring &name)
Definition: SLAnimation.h:75
SLfloat lengthSec() const
Definition: SLAnimation.h:72
SLfloat prevKeyframeTime(SLfloat time)
Definition: SLAnimation.cpp:57
SLstring _name
name of the animation
Definition: SLAnimation.h:79
SLNodeAnimTrack * createNodeAnimTrackForRotation3(SLNode *target, SLfloat angleDeg0, SLfloat angleDeg1, SLfloat angleDeg2, const SLVec3f &axis)
SLbool affectsNode(SLNode *node)
Definition: SLAnimation.cpp:83
SLNodeAnimTrack * createNodeAnimTrackForTranslation(SLNode *target, const SLVec3f &endPos)
SLNodeAnimTrack * createNodeAnimTrackForRotation4(SLNode *target, SLfloat angleDeg0, SLfloat angleDeg1, SLfloat angleDeg2, SLfloat angleDeg3, const SLVec3f &axis)
const SLstring & name()
Definition: SLAnimation.h:71
void resetNodes()
SLNodeAnimTrack * createNodeAnimTrackForScaling(SLNode *target, const SLVec3f &endScale)
void apply(SLfloat time, SLfloat weight=1.0f, SLfloat scale=1.0f)
SLfloat nextKeyframeTime(SLfloat time)
Definition: SLAnimation.cpp:38
void applyToNode(SLNode *node, SLfloat time, SLfloat weight=1.0f, SLfloat scale=1.0f)
SLNodeAnimTrack * createNodeAnimTrackForEllipse(SLNode *target, SLfloat radiusA, SLAxis axisA, SLfloat radiusB, SLAxis axisB)
SLNodeAnimTrack * createNodeAnimTrackForRotation2(SLNode *target, SLfloat angleDeg0, SLfloat angleDeg1, const SLVec3f &axis)
Specialized animation track for node animations.
Definition: SLAnimTrack.h:66
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69