10 #include <Atoms/Globals.h>
11 #include <AtomsCore/AtomsMath.h>
12 #include <Atoms/AgentType.h>
13 #include <AtomsCore/Metadata/MetadataFactory.h>
14 #include <AtomsCore/Metadata/TypedArrayMetadata.h>
15 #include <AtomsCore/Metadata/ArrayMetadata.h>
16 #include <AtomsCore/Metadata/MapMetadata.h>
17 #include <AtomsCore/Metadata/Vector2ArrayMetadata.h>
18 #include <AtomsCore/Metadata/Vector3ArrayMetadata.h>
19 #include <AtomsCore/Skeleton.h>
23 #define DOUBLE_FOOT_DOWN_TRESHOLD 0.95
56 inline const std::string& name()
const;
63 inline void setName(
const std::string& name);
75 inline void setTranslation(
const AtomsCore::Vector3 &translation,
const unsigned int frame);
110 inline unsigned int getArrayMetadataType(
const std::string &name)
const;
112 template <
class T>
inline void setArrayMetadataValue(
const std::string &name,
const unsigned int frame, T value);
114 inline AtomsPtr<AtomsCore::Metadata> getArrayMetadataAtFrame(
const std::string &name,
const unsigned int frame)
const;
116 template <
class T>
inline T getArrayMetadataValueAtFrame(
const std::string &name,
const unsigned int frame)
const;
118 AtomsPtr<AtomsCore::Metadata> getBlendedArrayMetadata(
const std::string &name,
const unsigned int initialFrame,
const unsigned int finalFrame,
const double weight)
const;
120 bool getBlendedArrayMetadataInPlace(
const std::string& name,
const unsigned int initialFrame,
const unsigned int finalFrame,
const double weight, AtomsPtr<AtomsCore::Metadata>& OutMeta)
const;
122 template <
class T>
inline T getBlendedArrayMetadataValue(
const std::string &name,
const unsigned int initialFrame,
const unsigned int finalFrame,
const double weight)
const;
124 AtomsPtr<AtomsCore::Metadata> getDoubleBlendedArrayMetadata(
const std::string &name,
const unsigned int initialFrame1,
const unsigned int finalFrame1,
const double weight1,
const unsigned int initialFrame2,
const unsigned int finalFrame2,
const double weight2,
const double finalWeight)
const;
125 bool getDoubleBlendedArrayMetadataInPlace(
const std::string& name,
const unsigned int initialFrame1,
const unsigned int finalFrame1,
const double weight1,
const unsigned int initialFrame2,
const unsigned int finalFrame2,
const double weight2,
const double finalWeight, AtomsPtr<AtomsCore::Metadata>& OutMeta)
const;
127 inline std::vector<std::string> getArrayMetadataNames()
const;
129 template<
class T>
inline void addArrayMetadata(
const std::string &name,
const bool force =
false);
131 template<
typename T,
typename V>
inline void getArrayMetadataValues(
const std::string& name, std::vector<V>& values);
133 inline AtomsPtr<AtomsCore::BaseTypedArrayMetadata> getArrayMetadata(
const std::string& name);
135 inline void addArrayMetadata(
const std::string &name, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>& data);
137 inline bool hasArrayMetadata(
const std::string &name)
const;
139 inline void deleteArrayMetadata(
const std::string& name);
141 inline std::vector<std::string> getStaticMetadataNames()
const;
145 inline AtomsPtr<AtomsCore::Metadata> getStaticMetadata(
const std::string &name);
147 inline AtomsPtr<const AtomsCore::Metadata> getStaticMetadata(
const std::string &name)
const;
153 inline std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& metadata();
155 inline const std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& metadata()
const;
161 void computeIsAnimated();
164 inline bool isTransformAnimated()
const;
167 inline const std::vector<std::string>& animatedMetadata()
const;
170 void addAnimatedMetadata(
const std::string& metadataName);
172 void copyFrame(
unsigned int from,
unsigned int to);
176 static bool getBindPoseData(
186 static bool getBindPoseData(
199 std::vector<AtomsCore::Vector3> m_translation;
201 std::vector<AtomsCore::Quaternion> m_rotation;
203 std::vector<AtomsCore::Vector3> m_scale;
205 std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>> m_metadata;
207 std::vector<std::string> m_animatedMetadata;
213 unsigned int m_numberOfFrames;
215 bool m_isTransformAnimated;
248 enum MirrorSideJointsSearch
254 enum MirrorStringReplacementType
264 AnimationClip(
const unsigned int numberOfJoints,
const unsigned int numberOfFrames,
const double fps);
270 inline int numJoints()
const;
273 inline int numFrames()
const;
282 inline double fps()
const;
285 inline void setFps(
double value);
288 inline unsigned int mapTimeToFrame(
const double time,
double &reminder)
const;
291 inline void setJointName(
const unsigned int index,
const std::string &jointName);
294 inline int jointId(
const std::string& jointName)
const;
300 inline const JointClipData& operator[](
unsigned short index)
const;
324 inline void setDirectionType(
unsigned int directionType);
327 inline unsigned int directionType()
const;
330 inline void setDirectionFromJoints(
unsigned int fromJoint,
unsigned int toJoint);
333 inline const std::pair<unsigned int, unsigned int>& directionFromJoints()
const;
336 inline void disableFootLock(
bool value);
339 inline bool isFootLockDisabled()
const;
342 inline const std::vector<int>& transitionFrames()
const;
354 void setGlobalIKData(
const std::string& jointName,
const AtomsCore::Vector2ArrayMetadata& data);
366 void setFootDownData(
const std::string& jointName,
const AtomsCore::Vector2ArrayMetadata& data);
369 void addJointMetadata(
const std::string& metadataName,
const std::string& jointName,
const int metadataType,
const AtomsCore::Vector2ArrayMetadata& data);
378 inline unsigned int additiveMode()
const;
381 inline const std::string & additiveReferenceClip()
const;
412 const unsigned int animMirrorPlane,
413 const unsigned int bindMirrorPlane,
414 const unsigned int searchMode,
415 const std::string &left,
416 const std::string &right,
417 const bool rawMirror =
false,
418 const unsigned int stringReplacementType = 0,
419 const std::vector<std::string> skipJoints = {},
420 const bool affectSkipJointsHierarchy =
false);
449 int clampedFrame,
double weight,
494 std::vector<JointClipData> m_joints;
497 std::vector<AtomsCore::Vector2> m_sittingFramesData;
503 std::vector<int> m_transitionFrames;
506 std::map<std::string, unsigned int> m_jointIndex;
515 unsigned int m_numberOfFrames;
524 std::pair<unsigned int, unsigned int> m_directionFromJoints;
527 unsigned int m_directionType;
530 bool m_isFootLockDisabled;
533 std::string m_compatibleAgentType;
536 unsigned int m_additiveMode;
539 std::string m_additiveReferenceClip;
542 bool m_frameRootRotationCached;
545 bool m_transferMotionToVirtualRootX;
548 bool m_transferMotionToVirtualRootY;
551 bool m_transferMotionToVirtualRootZ;
554 bool m_overrideVirtualRootPosition;
556 bool m_updateVirtualRootMotion;
561 #include "AnimationClip.impl.h"
Animation clip.
Definition: AnimationClip.h:221
void computeAnimatedJoints()
Compute the animated joints.
void refreshSittingData()
refresh the sitting data
void setAdditiveMode(const unsigned int additiveMode)
Set the additive mode.
void setAdditiveReferenceClip(const std::string &clipName)
Set additive reference clip.
void setTransitionFrames(const std::vector< int > &frames)
Get the transition frames.
void setNumJoints(const unsigned int numberOfJoints)
Sets the number of frames.
void setTransferMotionToVirtualRoot(const bool x, const bool y, const bool z, const bool overrideVirtualRootPos, const AtomsCore::Vector3 &virtualRootPos)
double computeAverageAngularVelocity() const
Get the mean angular velocity of this clip.
void computePelvisAndFeetHeight(double height)
Compute the the pelvis and feet height.
void sanitizeJointNames()
Sanitize joint names.
double computeAverageVelocity() const
Get the mean velocity of this clip.
bool overrideVirtualRootPosition() const
Get override virtual root position flag.
Definition: AnimationClip.h:482
void setCompatibleAgentType(const std::string &agentType)
Set compatible agent type name.
bool transferMotionToVirtualRootZ() const
Get transfer Z motion from root to virtual root flag.
Definition: AnimationClip.h:479
void sanitizeJointScales()
Sanitize joint scales.
void computeMirror(const unsigned int animMirrorPlane, const unsigned int bindMirrorPlane, const unsigned int searchMode, const std::string &left, const std::string &right, const bool rawMirror=false, const unsigned int stringReplacementType=0, const std::vector< std::string > skipJoints={}, const bool affectSkipJointsHierarchy=false)
Compute the mirror of the clip in the given mirror plane.
AnimationClip()
Constructor.
void cacheFrameRootRotation(const std::string &agentType)
Cache frame root rotation.
void computeClipDirections(const std::string &agentType, std::vector< AtomsCore::Vector3 > &directions) const
Compute and returns the clip directions.
AtomsCore::Vector3 computeClipDirection(Atoms::AgentTypeCPtr atPtr, const int frame) const
Compute and returns the clip direction for a frame.
void setSittingData(const AtomsCore::Vector2ArrayMetadata &data)
Set sitting data.
void conformFootDownDataForLocomotion()
Conforms the foot down data for locomotion.
bool transferMotionToVirtualRootX() const
Get transfer X motion from root to virtual root flag.
Definition: AnimationClip.h:473
void setFootDownData(const std::string &jointName, const AtomsCore::Vector2ArrayMetadata &data)
Set foot data for a specific joint.
void setPerchingData(const AtomsCore::Vector2ArrayMetadata &data)
Set perching data on the joint root.
AtomsCore::Vector3 virtualRootPositionOverride() const
Get override virtual root position flag.
Definition: AnimationClip.h:485
~AnimationClip()
Destructor.
Definition: AnimationClip.h:267
void setNumFrames(const unsigned int numberOfFrames)
Sets the number of frames.
void transferMotionToVirtualRoot()
Transfers the motion from the skeleton root to the virtual root.
void refreshVirtualRoot()
marks the this clip so that the virtual roo data is rebuilt
AtomsCore::Matrix clipJointWorldMatrix(const AtomsCore::Skeleton &skeleton, int clampedFrame, double weight, AtomsCore::JointCPtr pelvisJoint) const
Get a world matrix form the clip.
const std::string & getCompatibleAgentType() const
Get compatible agent type name.
void reverse()
Reverse clip.
void setGlobalIKData(const std::string &jointName, const AtomsCore::Vector2ArrayMetadata &data)
Set global ik data for a specific joint.
void addJointMetadata(const std::string &metadataName, const std::string &jointName, const int metadataType, const AtomsCore::Vector2ArrayMetadata &data)
Add a joint metadata.
bool transferMotionToVirtualRootY() const
Get transfer Y motion from root to virtual root flag.
Definition: AnimationClip.h:476
Joint Clip data.
Definition: AnimationClip.h:38
AtomsCore::Vector3 getBlendedScale(const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended scale between two frames.
void getBlendedScaleInPlace(AtomsCore::Vector3 &out, const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended scale between two frames.
void setNumberOfFrames(const int value)
set number of frames
void getBlendedTranslationInPlace(AtomsCore::Vector3 &out, const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended translation between two frames.
~JointClipData()
Destructr.
unsigned int getNumberOfFrames()
get number of frames
Definition: AnimationClip.h:69
AtomsCore::Quaternion getBlendedRotation(const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended rotation between two frames.
JointClipData(const unsigned int numberOfFrames)
Cosntructor.
AtomsCore::Vector3 getBlendedTranslation(const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended translation between two frames.
void getBlendedRotationInPlace(AtomsCore::Quaternion &out, const unsigned int initialFrame, const unsigned int finalFrame, const double weight) const
Gets blended rotation between two frames.
Joint class.
Definition: Joint.h:30
Skeleton class.
Definition: Skeleton.h:68
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< const AnimationClip > AnimationClipCPtr
animation clip const pointer
Definition: AnimationClip.h:32
AtomsPtr< AnimationClip > AnimationClipPtr
animation clip pointer
Definition: AnimationClip.h:28
AtomsPtr< const AgentType > AgentTypeCPtr
Agent type const pointer.
Definition: AgentType.h:21