Atoms Crowd  7.0.0
AnimationClipLooper.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/Globals.h>
11 #include <Atoms/AnimationClip.h>
12 #include <algorithm>
13 #include <cassert>
14 
15 namespace Atoms
16 {
17  class AnimationClipLooper;
18 
20 
22 
24 
26  class ATOMS_EXPORT AnimationClipLooper
27  {
28  public:
29 
32 
34 
38 
41 
43  inline bool isValid() const;
44 
46  inline const AnimationClipCPtr animationClip() const;
47 
49 
52  void setAnimationClip(AnimationClipCPtr animationClip);
53 
55 
58  inline int numJoints() const;
59 
61 
64  inline unsigned int numberBlendFrames() const;
65 
67 
70  inline void setNumberBlendFrames(unsigned int value);
71 
73 
76  inline void setLoopStartFrame(unsigned int value);
77 
79 
82  inline unsigned int loopStartFrame() const;
83 
85 
88  inline void setLoopEndFrame(unsigned int value);
89 
91 
94  inline unsigned int loopEndFrame() const;
95 
97 
104  AtomsCore::Vector3 getTranslation(const unsigned int jointId, const double time, const int offset = 0) const;
105 
107 
114  AtomsCore::Quaternion getRotation(const unsigned int jointId, const double time, const int offset = 0) const;
115 
117 
124  AtomsCore::Vector3 getScale(const unsigned int jointId, const double time, const int offset = 0) const;
125 
127 
136  void getTransformValues(const unsigned int jointId, const double time, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale, const int offset = 0) const;
137 
139 
148  void getTransformValuesAtFrame(const unsigned int jointId, const unsigned frame, const double reminder, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale) const;
149 
151 
158  AtomsCore::Vector3 getTranslationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
159 
161 
168  AtomsCore::Vector3 getTranslationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
169 
171 
178  AtomsCore::Quaternion getRotationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
179 
181 
188  AtomsCore::Quaternion getRotationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
189 
191 
198  AtomsCore::Vector3 getScaleAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
199 
201 
208  AtomsCore::Vector3 getScaleAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
209 
211 
215  inline std::vector<std::string> metadataNames(const unsigned int jointId) const;
216 
218 
225  AtomsPtr<AtomsCore::Metadata> getMetadata(const unsigned int jointId, const std::string &metadataName, const double time, const int offset = 0) const;
226 
228 
235  bool getMetadataInPlace(const unsigned int jointId, const std::string& metadataName, const double time, AtomsPtr<AtomsCore::Metadata>& outMeta, const int offset = 0) const;
236 
237 
239 
247  AtomsPtr<AtomsCore::Metadata> getMetadataAtFrame(const unsigned int jointId, const std::string &metadataName, const unsigned frame, const double reminder) const;
248 
250 
258  void getMetadataAtFrameInPlace(const unsigned int jointId, const std::string& metadataName, const unsigned frame, const double reminder, AtomsPtr<AtomsCore::Metadata>& OutMeta) const;
259 
261 
265  inline std::vector<std::string> staticMetadataNames(const unsigned int jointId) const;
266 
268 
272  inline AtomsPtr<const AtomsCore::Metadata> getStaticMetadata(const unsigned int jointId, const std::string &metadataName) const;
273 
275 
279  inline const AtomsCore::MapMetadata& staticMetadata(const unsigned int jointId) const;
280  inline const std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& metadata(const unsigned int jointId) const;
281 
282  inline const std::vector<std::string>& animatedMetadata(const unsigned int jointId) const;
283 
284  inline unsigned int mapTimeToFrame(const double time, double &reminder, unsigned int &nextFrame, int offset = 0) const;
285  inline unsigned int mapFrameToFrame(const unsigned frame, unsigned int &nextFrame) const;
286 
288  inline unsigned int numFrames() const;
289 
290  double getFactorFromFrame(unsigned int frame, unsigned int nextFrame, double reminder, unsigned int &loopedFrame, unsigned int &loopedNextFrame) const;
291 
292  private:
293 
295  AnimationClipCPtr m_animationClip;
296 
298  unsigned int m_numBlendFrames;
299 
301  unsigned int m_loopStart;
302 
304  unsigned int m_loopEnd;
305  };
306 }
307 
308 
309 #include "AnimationClipLooper.impl.h"
Animation clip looper.
Definition: AnimationClipLooper.h:27
AtomsCore::Quaternion getRotationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint rotation at frame.
void setAnimationClip(AnimationClipCPtr animationClip)
Sets the animation clips.
AnimationClipLooper(AnimationClipCPtr animationClip)
Constructor.
void getTransformValuesAtFrame(const unsigned int jointId, const unsigned frame, const double reminder, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale) const
Gets joint transform at frame.
~AnimationClipLooper()
Destructor.
Definition: AnimationClipLooper.h:40
bool getMetadataInPlace(const unsigned int jointId, const std::string &metadataName, const double time, AtomsPtr< AtomsCore::Metadata > &outMeta, const int offset=0) const
Gets joint metadata value at time.
AtomsPtr< AtomsCore::Metadata > getMetadata(const unsigned int jointId, const std::string &metadataName, const double time, const int offset=0) const
Gets joint metadata value at time.
AtomsCore::Quaternion getRotationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint rotation at frame.
AtomsCore::Vector3 getScaleAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint scale at frame.
void getMetadataAtFrameInPlace(const unsigned int jointId, const std::string &metadataName, const unsigned frame, const double reminder, AtomsPtr< AtomsCore::Metadata > &OutMeta) const
Gets joint metadata value at frame.
AtomsCore::Vector3 getTranslationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint translation at frame.
AtomsCore::Vector3 getTranslationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint translation at frame.
AtomsCore::Vector3 getTranslation(const unsigned int jointId, const double time, const int offset=0) const
Gets the joint translation.
AtomsCore::Vector3 getScaleAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint scale at frame.
void getTransformValues(const unsigned int jointId, const double time, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale, const int offset=0) const
Gets joint transform.
AtomsCore::Quaternion getRotation(const unsigned int jointId, const double time, const int offset=0) const
Gets joint rotation.
AtomsPtr< AtomsCore::Metadata > getMetadataAtFrame(const unsigned int jointId, const std::string &metadataName, const unsigned frame, const double reminder) const
Gets joint metadata value at frame.
AtomsCore::Vector3 getScale(const unsigned int jointId, const double time, const int offset=0) const
Gets joint scale.
AnimationClipLooper()
Constructor.
MapMetadata class.
Definition: MapMetadata.h:24
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
Atoms namespace.
Definition: Agent.h:29
AnimationClipLooper * AnimationClipLooperPtr
animation clip looper pointer
Definition: AnimationClipLooper.h:17
const AnimationClipLooper * AnimationClipLooperCPtr
animation clip looper const pointer
Definition: AnimationClipLooper.h:21
AtomsPtr< const AnimationClip > AnimationClipCPtr
animation clip const pointer
Definition: AnimationClip.h:32