mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Merge pull request #275 from NonLinearGuy/master
Fixed errors in skeletal animation code
This commit is contained in:
@@ -171,7 +171,7 @@ set(7.in_practice
|
|||||||
|
|
||||||
set(GUEST_ARTICLES
|
set(GUEST_ARTICLES
|
||||||
8.guest/2020/oit
|
8.guest/2020/oit
|
||||||
#8.guest/2020/skeletal_animation
|
8.guest/2020/skeletal_animation
|
||||||
8.guest/2021/1.scene/1.scene_graph
|
8.guest/2021/1.scene/1.scene_graph
|
||||||
8.guest/2021/1.scene/2.frustum_culling
|
8.guest/2021/1.scene/2.frustum_culling
|
||||||
8.guest/2021/2.csm
|
8.guest/2021/2.csm
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
m_FinalBoneMatrices.push_back(glm::mat4(1.0f));
|
m_FinalBoneMatrices.push_back(glm::mat4(1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animator::UpdateAnimation(float dt)
|
void UpdateAnimation(float dt)
|
||||||
{
|
{
|
||||||
m_DeltaTime = dt;
|
m_DeltaTime = dt;
|
||||||
if (m_CurrentAnimation)
|
if (m_CurrentAnimation)
|
||||||
@@ -33,13 +33,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animator::PlayAnimation(Animation* pAnimation)
|
void PlayAnimation(Animation* pAnimation)
|
||||||
{
|
{
|
||||||
m_CurrentAnimation = pAnimation;
|
m_CurrentAnimation = pAnimation;
|
||||||
m_CurrentTime = 0.0f;
|
m_CurrentTime = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animator::CalculateBoneTransform(const AssimpNodeData* node, glm::mat4 parentTransform)
|
void CalculateBoneTransform(const AssimpNodeData* node, glm::mat4 parentTransform)
|
||||||
{
|
{
|
||||||
std::string nodeName = node->name;
|
std::string nodeName = node->name;
|
||||||
glm::mat4 nodeTransform = node->transformation;
|
glm::mat4 nodeTransform = node->transformation;
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Bone::InterpolateScaling(float animationTime)
|
glm::mat4 InterpolateScaling(float animationTime)
|
||||||
{
|
{
|
||||||
if (1 == m_NumScalings)
|
if (1 == m_NumScalings)
|
||||||
return glm::scale(glm::mat4(1.0f), m_Scales[0].scale);
|
return glm::scale(glm::mat4(1.0f), m_Scales[0].scale);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec3 pos;
|
layout(location = 0) in vec3 pos;
|
||||||
layout(location = 1) in vec3 norm;
|
layout(location = 1) in vec3 norm;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ int main()
|
|||||||
ourShader.setMat4("projection", projection);
|
ourShader.setMat4("projection", projection);
|
||||||
ourShader.setMat4("view", view);
|
ourShader.setMat4("view", view);
|
||||||
|
|
||||||
auto transforms = animator.GetPoseTransforms();
|
auto transforms = animator.GetFinalBoneMatrices();
|
||||||
for (int i = 0; i < transforms.size(); ++i)
|
for (int i = 0; i < transforms.size(); ++i)
|
||||||
ourShader.setMat4("finalBonesTransformations[" + std::to_string(i) + "]", transforms[i]);
|
ourShader.setMat4("finalBonesTransformations[" + std::to_string(i) + "]", transforms[i]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user