Atoms Crowd  4.1.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 
103  AtomsCore::Vector3 getTranslation(const unsigned int jointId, const double time) const;
104 
106 
112  AtomsCore::Quaternion getRotation(const unsigned int jointId, const double time) const;
113 
115 
121  AtomsCore::Vector3 getScale(const unsigned int jointId, const double time) const;
122 
124 
132  void getTransformValues(const unsigned int jointId, const double time, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale) const;
133 
135 
144  void getTransformValuesAtFrame(const unsigned int jointId, const unsigned frame, const double reminder, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale) const;
145 
147 
154  AtomsCore::Vector3 getTranslationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
155 
157 
164  AtomsCore::Vector3 getTranslationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
165 
167 
174  AtomsCore::Quaternion getRotationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
175 
177 
184  AtomsCore::Quaternion getRotationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
185 
187 
194  AtomsCore::Vector3 getScaleAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
195 
197 
204  AtomsCore::Vector3 getScaleAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const;
205 
207 
211  inline std::vector<std::string> metadataNames(const unsigned int jointId) const;
212 
214 
220  AtomsPtr<AtomsCore::Metadata> getMetadata(const unsigned int jointId, const std::string &metadataName, const double time) const;
221 
223 
229  bool getMetadataInPlace(const unsigned int jointId, const std::string& metadataName, const double time, AtomsPtr<AtomsCore::Metadata>& outMeta) const;
230 
231 
233 
241  AtomsPtr<AtomsCore::Metadata> getMetadataAtFrame(const unsigned int jointId, const std::string &metadataName, const unsigned frame, const double reminder) const;
242 
244 
252  void getMetadataAtFrameInPlace(const unsigned int jointId, const std::string& metadataName, const unsigned frame, const double reminder, AtomsPtr<AtomsCore::Metadata>& OutMeta) const;
253 
255 
259  inline std::vector<std::string> staticMetadataNames(const unsigned int jointId) const;
260 
262 
266  inline AtomsPtr<const AtomsCore::Metadata> getStaticMetadata(const unsigned int jointId, const std::string &metadataName) const;
267 
269 
273  inline const AtomsCore::MapMetadata& staticMetadata(const unsigned int jointId) const;
274  inline const std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& metadata(const unsigned int jointId) const;
275 
276  inline const std::vector<std::string>& animatedMetadata(const unsigned int jointId) const;
277 
278  inline unsigned int mapTimeToFrame(const double time, double &reminder, unsigned int &nextFrame) const;
279  inline unsigned int mapFrameToFrame(const unsigned frame, unsigned int &nextFrame) const;
280 
282  inline unsigned int numFrames() const;
283 
284  double getFactorFromFrame(unsigned int frame, unsigned int nextFrame, double reminder, unsigned int &loopedFrame, unsigned int &loopedNextFrame) const;
285 
286  private:
287 
289  AnimationClipCPtr m_animationClip;
290 
292  unsigned int m_numBlendFrames;
293 
295  unsigned int m_loopStart;
296 
298  unsigned int m_loopEnd;
299  };
300 }
301 
302 
303 #include "AnimationClipLooper.impl.h"
Atoms::AnimationClipLooper::getRotation
AtomsCore::Quaternion getRotation(const unsigned int jointId, const double time) const
Gets joint rotation.
Atoms::AnimationClipLooperPtr
AnimationClipLooper * AnimationClipLooperPtr
animation clip looper pointer
Definition: AnimationClipLooper.h:17
Atoms::AnimationClipLooper::AnimationClipLooper
AnimationClipLooper(AnimationClipCPtr animationClip)
Constructor.
Atoms::AnimationClipLooper::getRotationAtGlobalFrame
AtomsCore::Quaternion getRotationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint rotation at frame.
Atoms::AnimationClipLooper::AnimationClipLooper
AnimationClipLooper()
Constructor.
Atoms::AnimationClipLooper::getScaleAtFrame
AtomsCore::Vector3 getScaleAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint scale at frame.
AtomsCore::Quaternion
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
Atoms::AnimationClipLooper::getMetadataInPlace
bool getMetadataInPlace(const unsigned int jointId, const std::string &metadataName, const double time, AtomsPtr< AtomsCore::Metadata > &outMeta) const
Gets joint metadata value at time.
Atoms::AnimationClipLooper::getTranslation
AtomsCore::Vector3 getTranslation(const unsigned int jointId, const double time) const
Gets the joint translation.
Atoms::AnimationClipLooper::getRotationAtFrame
AtomsCore::Quaternion getRotationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint rotation at frame.
Atoms::AnimationClipLooper::getTranslationAtFrame
AtomsCore::Vector3 getTranslationAtFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint translation at frame.
Atoms::AnimationClipLooper::getTransformValues
void getTransformValues(const unsigned int jointId, const double time, AtomsCore::Vector3 &translation, AtomsCore::Quaternion &rotation, AtomsCore::Vector3 &scale) const
Gets joint transform.
Atoms::AnimationClipLooper::getMetadataAtFrameInPlace
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.
Atoms::AnimationClipLooperCPtr
const AnimationClipLooper * AnimationClipLooperCPtr
animation clip looper const pointer
Definition: AnimationClipLooper.h:21
Atoms::AnimationClipLooper::getTransformValuesAtFrame
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.
Atoms::AnimationClipLooper::getMetadata
AtomsPtr< AtomsCore::Metadata > getMetadata(const unsigned int jointId, const std::string &metadataName, const double time) const
Gets joint metadata value at time.
Atoms::AnimationClipLooper::getMetadataAtFrame
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
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
Atoms::AnimationClipLooper::setAnimationClip
void setAnimationClip(AnimationClipCPtr animationClip)
Sets the animation clips.
Atoms::AnimationClipCPtr
AtomsPtr< const AnimationClip > AnimationClipCPtr
animation clip const pointer
Definition: AnimationClip.h:31
Atoms
Atoms namespace.
Definition: Agent.h:28
AtomsCore::MapMetadata
MapMetadata class.
Definition: MapMetadata.h:24
Atoms::AnimationClipLooper::~AnimationClipLooper
~AnimationClipLooper()
Destructor.
Definition: AnimationClipLooper.h:40
Atoms::AnimationClipLooper::getScale
AtomsCore::Vector3 getScale(const unsigned int jointId, const double time) const
Gets joint scale.
Atoms::AnimationClipLooper::getTranslationAtGlobalFrame
AtomsCore::Vector3 getTranslationAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint translation at frame.
Atoms::AnimationClipLooper
Animation clip looper.
Definition: AnimationClipLooper.h:27
Atoms::AnimationClipLooper::getScaleAtGlobalFrame
AtomsCore::Vector3 getScaleAtGlobalFrame(const unsigned int jointId, const unsigned frame, const double reminder) const
Gets joint scale at frame.