24 return m_animationClip;
29 return m_animationClip.get() !=
nullptr;
34 return m_animationClip->numJoints();
39 if (
static_cast<int>(value) > (m_animationClip->numFrames() - 1) || (m_loopStart - value) < 0)
41 Logger::error() <<
"Blend frame value outside range " << m_loopStart <<
"-" << m_animationClip->numFrames() - 1;
45 m_numBlendFrames = value;
50 return m_numBlendFrames;
55 if (value > m_loopEnd)
57 Logger::error() <<
"Loop start value outside range 0-" << m_loopEnd <<
" : " << value;
61 if (value - m_numBlendFrames < 0)
63 Logger::error() <<
"Blend frames value outside range " << value <<
"-" << m_animationClip->numFrames() - 1 <<
". Resetting number of blend frames to 0.";
77 if (value < m_loopStart ||
static_cast<int>(value) > (m_animationClip->numFrames() - 1))
79 Logger::error() <<
"Loop end value outside range " << m_loopStart <<
"-" << m_animationClip->numFrames() - 1 <<
" : " << value;
80 m_loopEnd = m_loopStart + m_animationClip->numFrames() - 1;
91 unsigned int AnimationClipLooper::mapTimeToFrame(
const double time,
double &reminder,
unsigned int &nextFrame,
int offset)
const
93 if (!m_animationClip)
return -1;
94 unsigned int frame = m_animationClip->mapTimeToFrame(time, reminder);
95 int relative_duration = std::max(1u, m_loopEnd - m_loopStart);
96 int signedFrame = frame + offset;
97 frame = signedFrame < 0 ? m_loopEnd - (std::abs(signedFrame) % relative_duration + m_loopStart): signedFrame;
98 frame = frame % relative_duration + m_loopStart;
99 nextFrame = frame == (relative_duration + m_loopStart) ? m_loopStart : frame + 1;
103 unsigned int AnimationClipLooper::mapFrameToFrame(
const unsigned frame,
unsigned int &nextFrame)
const
105 if (!m_animationClip)
return -1;
106 int relative_duration = std::max(1u,m_loopEnd - m_loopStart);
107 unsigned int resFrame = frame % relative_duration + m_loopStart;
108 nextFrame = resFrame == (relative_duration + m_loopStart) ? m_loopStart : resFrame + 1;
114 return m_loopEnd - m_loopStart;
119 if (!m_animationClip)
return std::vector<std::string>();
120 return (*m_animationClip)[
static_cast<unsigned short>(jointId)].getArrayMetadataNames();
125 return (*m_animationClip)[
static_cast<unsigned short>(jointId)].getStaticMetadataNames();
130 assert(m_animationClip !=
nullptr);
131 assert(m_animationClip->numJoints() > jointId);
132 return (*m_animationClip)[
static_cast<unsigned short>(jointId)].
getStaticMetadata(metdataName);
137 assert(m_animationClip !=
nullptr);
138 assert(m_animationClip->numJoints() > jointId);
139 const JointClipData& jClipData = (*m_animationClip)[
static_cast<unsigned short>(jointId)];
140 return jClipData.staticMetadata();
143 const std::map<std::string, AtomsPtr<AtomsCore::BaseTypedArrayMetadata>>& AnimationClipLooper::metadata(
const unsigned int jointId)
const
145 return (*m_animationClip)[
static_cast<unsigned short>(jointId)].metadata();
148 const std::vector<std::string>& AnimationClipLooper::animatedMetadata(
const unsigned int jointId)
const
150 return (*m_animationClip)[
static_cast<unsigned short>(jointId)].animatedMetadata();
const AtomsCore::MapMetadata & staticMetadata(const unsigned int jointId) const
Gets joint static metadatas.
Definition: AnimationClipLooper.impl.h:135
unsigned int numFrames() const
Gets the number of frames.
Definition: AnimationClipLooper.impl.h:112
std::vector< std::string > staticMetadataNames(const unsigned int jointId) const
Gets joint static metadata names.
Definition: AnimationClipLooper.impl.h:123
unsigned int loopStartFrame() const
Gets the loop start frame.
Definition: AnimationClipLooper.impl.h:70
AtomsPtr< const AtomsCore::Metadata > getStaticMetadata(const unsigned int jointId, const std::string &metadataName) const
Gets joint static metadata value.
Definition: AnimationClipLooper.impl.h:128
unsigned int loopEndFrame() const
Gets the loop end frame.
Definition: AnimationClipLooper.impl.h:86
void setLoopStartFrame(unsigned int value)
Sets the loop start frame.
Definition: AnimationClipLooper.impl.h:53
void setNumberBlendFrames(unsigned int value)
Sets the number of blend frames.
Definition: AnimationClipLooper.impl.h:37
const AnimationClipCPtr animationClip() const
Get the animation clip.
Definition: AnimationClipLooper.impl.h:22
std::vector< std::string > metadataNames(const unsigned int jointId) const
Gets joint metadata names.
Definition: AnimationClipLooper.impl.h:117
void setLoopEndFrame(unsigned int value)
Sets the loop end frame.
Definition: AnimationClipLooper.impl.h:75
bool isValid() const
Check if the looper is valid and has a valid anim clip.
Definition: AnimationClipLooper.impl.h:27
int numJoints() const
Returns the number of joints.
Definition: AnimationClipLooper.impl.h:32
unsigned int numberBlendFrames() const
Returns the number of blend frames.
Definition: AnimationClipLooper.impl.h:48
Joint Clip data.
Definition: AnimationClip.h:38
static LogProxy error()
Get logger proxy error.
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< const AnimationClip > AnimationClipCPtr
animation clip const pointer
Definition: AnimationClip.h:32