26 if (m_translation.size() > frame)
27 m_translation[frame].setValue(translation);
32 if (m_rotation.size() > frame)
33 m_rotation[frame] = rotation;
38 if (m_scale.size() > frame)
39 m_scale[frame].setValue(scale);
44 return frame > m_numberOfFrames - 1 ? m_translation[m_numberOfFrames - 1] : m_translation[frame];
49 return frame > m_numberOfFrames - 1 ? m_rotation[m_numberOfFrames - 1] : m_rotation[frame];
54 return frame > m_numberOfFrames - 1 ? m_scale[m_numberOfFrames - 1] : m_scale[frame];
57 unsigned int JointClipData::getArrayMetadataType(
const std::string &name)
const
59 return m_metadata.at(
name)->typeId();
62 template <
class T>
inline T JointClipData::getArrayMetadataValueAtFrame(
const std::string &name,
const unsigned int frame)
const
64 auto metaIt = m_metadata.find(
name);
65 if (metaIt == m_metadata.end())
68 AtomsPtr<AtomsCore::TypedArrayMetadata<T>> vec = std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T >>(metaIt->second);
71 return vec->getBasicTypeValue(frame > m_numberOfFrames - 1 ? m_numberOfFrames - 1 : frame);
75 T JointClipData::getBlendedArrayMetadataValue(
const std::string& name,
const unsigned int initialFrame,
const unsigned int finalFrame,
const double weight)
const
77 auto metaIt = m_metadata.find(
name);
78 if (metaIt == m_metadata.end())
81 if (initialFrame > m_numberOfFrames - 1)
84 return std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>(metaIt->second)->getBasicTypeValue(m_numberOfFrames - 1);
89 return std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>(metaIt->second)->getBasicTypeValue(initialFrame);
92 unsigned int fframe = finalFrame > m_numberOfFrames - 1 ? m_numberOfFrames - 1 : finalFrame;
95 return std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>(metaIt->second)->getBasicTypeValue(fframe);
98 return std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>(metaIt->second)->getBlendedBasicTypeValue(initialFrame, fframe, weight);
101 AtomsPtr<AtomsCore::Metadata> JointClipData::getArrayMetadataAtFrame(
const std::string &name,
const unsigned int frame)
const
103 auto metaIt = m_metadata.find(
name);
104 if (metaIt != m_metadata.cend())
105 return metaIt->second->getBasicTypeMetadata(frame > m_numberOfFrames - 1 ? m_numberOfFrames - 1 : frame);
109 template <
class T>
void JointClipData::setArrayMetadataValue(
const std::string &name,
const unsigned int frame, T value)
111 AtomsPtr<AtomsCore::TypedArrayMetadata<T>> vec = std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>( m_metadata[
name] );
112 vec->get()[frame] = value;
115 std::vector<std::string> JointClipData::getArrayMetadataNames()
const
118 std::vector<std::string> metadataNames;
119 metadataNames.reserve(m_metadata.size());
120 for (
auto it = m_metadata.cbegin(); it != m_metadata.cend(); it++)
121 metadataNames.push_back(it->first);
122 return metadataNames;
125 bool JointClipData::hasArrayMetadata(
const std::string &name)
const
127 return m_metadata.find(
name) != m_metadata.cend();
130 void JointClipData::deleteArrayMetadata(
const std::string& name)
132 auto it = m_metadata.find(
name);
133 if (it != m_metadata.end())
134 m_metadata.erase(it);
137 template<
typename T,
typename V>
inline void JointClipData::getArrayMetadataValues(
const std::string& name, std::vector<V>& values)
139 if (m_metadata.find(
name) == m_metadata.end())
141 AtomsPtr<AtomsCore::TypedArrayMetadata<T>> vec = std::static_pointer_cast<AtomsCore::TypedArrayMetadata<T>>(m_metadata[
name]);
147 template<
class T>
void JointClipData::addArrayMetadata(
const std::string &name,
const bool force)
149 if (m_metadata.find(
name) == m_metadata.end() || force)
153 AtomsPtr<T> d = std::static_pointer_cast<T>(data);
154 d->get().resize(
static_cast<unsigned int>(m_numberOfFrames));
156 m_metadata[
name] = d;
162 void JointClipData::addArrayMetadata(
const std::string &name, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>& data)
164 m_metadata[
name] = data;
167 AtomsPtr<AtomsCore::BaseTypedArrayMetadata> JointClipData::getArrayMetadata(
const std::string& name)
169 auto it = m_metadata.find(
name);
170 return (it != m_metadata.end()) ? it->second : AtomsPtr<AtomsCore::BaseTypedArrayMetadata>();
173 std::vector<std::string> JointClipData::getStaticMetadataNames()
const
175 return m_staticMetadata.
getKeys();
178 void JointClipData::setStaticMetadata(
const std::string &name,
AtomsCore::Metadata &metadata)
183 AtomsPtr<AtomsCore::Metadata> JointClipData::getStaticMetadata(
const std::string &name)
188 AtomsPtr<const AtomsCore::Metadata> JointClipData::getStaticMetadata(
const std::string &name)
const
195 return m_staticMetadata;
200 return m_staticMetadata;
203 std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& JointClipData::metadata()
208 const std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& JointClipData::metadata()
const
213 bool JointClipData::isTransformAnimated()
const
215 return m_isTransformAnimated;
218 inline const std::vector<std::string>& JointClipData::animatedMetadata()
const
220 return m_animatedMetadata;
228 return static_cast<int>(m_joints.size());
233 return m_numberOfFrames;
248 double f = time * m_fps;
249 unsigned int ret =
static_cast<unsigned int>(f);
256 m_jointIndex[jointName] = index;
257 m_joints[index].setName(jointName);
262 auto it = m_jointIndex.find(jointName);
263 return it != m_jointIndex.end() ? it->second : -1;
268 return m_joints[index];
273 return m_joints[index];
278 return m_joints.at(index);
283 return m_joints.at(index);
313 return m_directionType;
318 m_directionFromJoints.first = fromJoint;
319 m_directionFromJoints.second = toJoint;
325 return m_directionFromJoints;
330 m_isFootLockDisabled = value;
335 return m_isFootLockDisabled;
340 return m_transitionFrames;
345 return m_additiveMode;
350 return m_additiveReferenceClip;
unsigned int directionType() const
Gets the clip direction type.
Definition: AnimationClip.impl.h:311
AtomsCore::MapMetadata & metadata()
Gets metadata map.
Definition: AnimationClip.impl.h:286
int numFrames() const
Gets the number of frames.
Definition: AnimationClip.impl.h:231
int numJoints() const
Gets the number of joints.
Definition: AnimationClip.impl.h:226
const std::pair< unsigned int, unsigned int > & directionFromJoints() const
Gets the two joint ids used for evaluating the direction when the direction type is set to kJoints.
Definition: AnimationClip.impl.h:323
AtomsCore::Vector3 direction() const
Gets the clip direction.
Definition: AnimationClip.impl.h:301
JointClipData & at(unsigned short index)
Gets joint clip data.
Definition: AnimationClip.impl.h:276
unsigned int additiveMode() const
Gets the clip additive mode.
Definition: AnimationClip.impl.h:343
int jointId(const std::string &jointName) const
Get joint index from joint name.
Definition: AnimationClip.impl.h:260
const std::vector< int > & transitionFrames() const
Gets the transition frames.
Definition: AnimationClip.impl.h:338
const std::string & additiveReferenceClip() const
Gets the clip additive mode.
Definition: AnimationClip.impl.h:348
bool isFootLockDisabled() const
Returns false if the the foot lock is disabled.
Definition: AnimationClip.impl.h:333
unsigned int mapTimeToFrame(const double time, double &reminder) const
Maps time to frame.
Definition: AnimationClip.impl.h:246
void setDirectionFromJoints(unsigned int fromJoint, unsigned int toJoint)
Sets the two joint ids used for evaluating the direction when the direction type is set to kJoints.
Definition: AnimationClip.impl.h:316
void setFps(double value)
Sets the frame per second.
Definition: AnimationClip.impl.h:241
void setDirection(const AtomsCore::Vector3 &direction)
Sets the clip direction.
Definition: AnimationClip.impl.h:296
JointClipData & operator[](unsigned short index)
Gets joint clip data.
Definition: AnimationClip.impl.h:266
void setJointName(const unsigned int index, const std::string &jointName)
Sets the joint name.
Definition: AnimationClip.impl.h:254
void setDirectionType(unsigned int directionType)
Sets the clip direction type.
Definition: AnimationClip.impl.h:306
double fps() const
Gets the frame per second.
Definition: AnimationClip.impl.h:236
void disableFootLock(bool value)
Sets the clip foot lock state.
Definition: AnimationClip.impl.h:328
Joint Clip data.
Definition: AnimationClip.h:38
void setRotation(const AtomsCore::Quaternion &rotation, const unsigned int frame)
Sets rotation at frame.
Definition: AnimationClip.impl.h:30
const AtomsCore::Vector3 & getTranslation(const unsigned int frame) const
Gets translation at frame.
Definition: AnimationClip.impl.h:42
const std::string & name() const
Gets name.
Definition: AnimationClip.impl.h:14
void setScale(const AtomsCore::Vector3 &scale, const unsigned int frame)
Sets scale at frame.
Definition: AnimationClip.impl.h:36
void setName(const std::string &name)
Sets name.
Definition: AnimationClip.impl.h:19
const AtomsCore::Quaternion & getRotation(const unsigned int frame) const
Gets rotation at frame.
Definition: AnimationClip.impl.h:47
void setTranslation(const AtomsCore::Vector3 &translation, const unsigned int frame)
Sets translation at frame.
Definition: AnimationClip.impl.h:24
const AtomsCore::Vector3 & getScale(const unsigned int frame) const
Gets scale at frame.
Definition: AnimationClip.impl.h:52
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
Atoms namespace.
Definition: Agent.h:29