Fixed MD2 animation
Former-commit-id: 3ba7d63f9518c64677e575e13d8a42b459c5151f
This commit is contained in:
parent
15888b0f42
commit
11fccc4c4b
|
|
@ -44,6 +44,8 @@ class NAZARA_API NzAnimation : public NzResource
|
||||||
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
|
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
|
void EnableLoopPointInterpolation(bool loopPointInterpolation);
|
||||||
|
|
||||||
unsigned int GetFrameCount() const;
|
unsigned int GetFrameCount() const;
|
||||||
unsigned int GetJointCount() const;
|
unsigned int GetJointCount() const;
|
||||||
NzSequence* GetSequence(const NzString& sequenceName);
|
NzSequence* GetSequence(const NzString& sequenceName);
|
||||||
|
|
@ -59,6 +61,7 @@ class NAZARA_API NzAnimation : public NzResource
|
||||||
bool HasSequence(const NzString& sequenceName) const;
|
bool HasSequence(const NzString& sequenceName) const;
|
||||||
bool HasSequence(unsigned int index = 0) const;
|
bool HasSequence(unsigned int index = 0) const;
|
||||||
|
|
||||||
|
bool IsLoopPointInterpolationEnabled() const;
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
bool LoadFromFile(const NzString& filePath, const NzAnimationParams& params = NzAnimationParams());
|
bool LoadFromFile(const NzString& filePath, const NzAnimationParams& params = NzAnimationParams());
|
||||||
|
|
|
||||||
|
|
@ -423,10 +423,18 @@ void NzModel::Update(float elapsedTime)
|
||||||
|
|
||||||
unsigned lastFrame = m_currentSequence->firstFrame + m_currentSequence->frameCount - 1;
|
unsigned lastFrame = m_currentSequence->firstFrame + m_currentSequence->frameCount - 1;
|
||||||
if (m_nextFrame+1 > lastFrame)
|
if (m_nextFrame+1 > lastFrame)
|
||||||
|
{
|
||||||
|
if (m_animation->IsLoopPointInterpolationEnabled())
|
||||||
|
{
|
||||||
|
m_currentFrame = m_nextFrame;
|
||||||
|
m_nextFrame = m_currentSequence->firstFrame;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_currentFrame = m_currentSequence->firstFrame;
|
m_currentFrame = m_currentSequence->firstFrame;
|
||||||
m_nextFrame = m_currentFrame+1;
|
m_nextFrame = m_currentFrame+1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_currentFrame = m_nextFrame;
|
m_currentFrame = m_nextFrame;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ struct NzAnimationImpl
|
||||||
std::vector<NzSequence> sequences;
|
std::vector<NzSequence> sequences;
|
||||||
std::vector<NzSequenceJoint> sequenceJoints; // Uniquement pour les animations squelettiques
|
std::vector<NzSequenceJoint> sequenceJoints; // Uniquement pour les animations squelettiques
|
||||||
nzAnimationType type;
|
nzAnimationType type;
|
||||||
|
bool loopPointInterpolation = false;
|
||||||
unsigned int frameCount;
|
unsigned int frameCount;
|
||||||
unsigned int jointCount; // Uniquement pour les animations squelettiques
|
unsigned int jointCount; // Uniquement pour les animations squelettiques
|
||||||
};
|
};
|
||||||
|
|
@ -206,6 +207,19 @@ void NzAnimation::Destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzAnimation::EnableLoopPointInterpolation(bool loopPointInterpolation)
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Animation not created");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_impl->loopPointInterpolation = loopPointInterpolation;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int NzAnimation::GetFrameCount() const
|
unsigned int NzAnimation::GetFrameCount() const
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
|
@ -435,6 +449,19 @@ bool NzAnimation::HasSequence(unsigned int index) const
|
||||||
return index >= m_impl->sequences.size();
|
return index >= m_impl->sequences.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzAnimation::IsLoopPointInterpolationEnabled() const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Animation not created");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_impl->loopPointInterpolation;
|
||||||
|
}
|
||||||
|
|
||||||
bool NzAnimation::IsValid() const
|
bool NzAnimation::IsValid() const
|
||||||
{
|
{
|
||||||
return m_impl != nullptr;
|
return m_impl != nullptr;
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,9 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Le MD2 requiert une interpolation de la dernière à la première frame (en cas de loop)
|
||||||
|
animation->EnableLoopPointInterpolation(true);
|
||||||
|
|
||||||
// Décodage des séquences
|
// Décodage des séquences
|
||||||
///TODO: Optimiser le calcul
|
///TODO: Optimiser le calcul
|
||||||
char last[16];
|
char last[16];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue