Fixed mesh animating modifying template skeleton
Former-commit-id: d70bd2ed7c8a38f879641a4b22be4876f6825edb
This commit is contained in:
parent
b652bada13
commit
37d6b71036
|
|
@ -36,6 +36,7 @@ class NAZARA_API NzModel : public NzSceneNode
|
||||||
unsigned int GetSkinCount() const;
|
unsigned int GetSkinCount() const;
|
||||||
const NzMesh* GetMesh() const;
|
const NzMesh* GetMesh() const;
|
||||||
nzSceneNodeType GetSceneNodeType() const override;
|
nzSceneNodeType GetSceneNodeType() const override;
|
||||||
|
NzSkeleton* GetSkeleton();
|
||||||
const NzSkeleton* GetSkeleton() const;
|
const NzSkeleton* GetSkeleton() const;
|
||||||
|
|
||||||
bool HasAnimation() const;
|
bool HasAnimation() const;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||||
bool AddSubMesh(NzSubMesh* subMesh);
|
bool AddSubMesh(NzSubMesh* subMesh);
|
||||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||||
|
|
||||||
void Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation) const;
|
void Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation, NzSkeleton* skeleton) const;
|
||||||
|
|
||||||
bool CreateKeyframe();
|
bool CreateKeyframe();
|
||||||
bool CreateSkeletal(unsigned int jointCount);
|
bool CreateSkeletal(unsigned int jointCount);
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,11 @@ nzSceneNodeType NzModel::GetSceneNodeType() const
|
||||||
return nzSceneNodeType_Model;
|
return nzSceneNodeType_Model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzSkeleton* NzModel::GetSkeleton()
|
||||||
|
{
|
||||||
|
return &m_skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
const NzSkeleton* NzModel::GetSkeleton() const
|
const NzSkeleton* NzModel::GetSkeleton() const
|
||||||
{
|
{
|
||||||
return &m_skeleton;
|
return &m_skeleton;
|
||||||
|
|
@ -419,5 +424,5 @@ void NzModel::Update(float elapsedTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mesh->Animate(m_animation, m_currentFrame, m_nextFrame, m_interpolation);
|
m_mesh->Animate(m_animation, m_currentFrame, m_nextFrame, m_interpolation, &m_skeleton);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ bool NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation) const
|
void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation, NzSkeleton* skeleton) const
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
@ -182,11 +182,19 @@ void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nzAnimationType_Skeletal:
|
case nzAnimationType_Skeletal:
|
||||||
animation->AnimateSkeleton(&m_impl->skeleton, frameA, frameB, interpolation);
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!skeleton)
|
||||||
|
{
|
||||||
|
NazaraError("Skeleton must be valid for skeletal animation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
animation->AnimateSkeleton(skeleton, frameA, frameB, interpolation);
|
||||||
for (NzSubMesh* subMesh : m_impl->subMeshes)
|
for (NzSubMesh* subMesh : m_impl->subMeshes)
|
||||||
{
|
{
|
||||||
NzSkeletalMesh* skeletalMesh = static_cast<NzSkeletalMesh*>(subMesh);
|
NzSkeletalMesh* skeletalMesh = static_cast<NzSkeletalMesh*>(subMesh);
|
||||||
skeletalMesh->Skin(&m_impl->skeleton);
|
skeletalMesh->Skin(skeleton);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue