mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Fixed errors in skeletal animation code
This commit is contained in:
@@ -171,7 +171,7 @@ set(7.in_practice
|
||||
|
||||
set(GUEST_ARTICLES
|
||||
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/2.frustum_culling
|
||||
8.guest/2021/2.csm
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
m_FinalBoneMatrices.push_back(glm::mat4(1.0f));
|
||||
}
|
||||
|
||||
void Animator::UpdateAnimation(float dt)
|
||||
void UpdateAnimation(float dt)
|
||||
{
|
||||
m_DeltaTime = dt;
|
||||
if (m_CurrentAnimation)
|
||||
@@ -33,13 +33,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void Animator::PlayAnimation(Animation* pAnimation)
|
||||
void PlayAnimation(Animation* pAnimation)
|
||||
{
|
||||
m_CurrentAnimation = pAnimation;
|
||||
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;
|
||||
glm::mat4 nodeTransform = node->transformation;
|
||||
@@ -77,4 +77,4 @@ private:
|
||||
float m_CurrentTime;
|
||||
float m_DeltaTime;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ private:
|
||||
|
||||
}
|
||||
|
||||
glm::mat4 Bone::InterpolateScaling(float animationTime)
|
||||
glm::mat4 InterpolateScaling(float animationTime)
|
||||
{
|
||||
if (1 == m_NumScalings)
|
||||
return glm::scale(glm::mat4(1.0f), m_Scales[0].scale);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
@@ -8,4 +8,4 @@ uniform sampler2D texture_diffuse1;
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(texture_diffuse1, TexCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 pos;
|
||||
layout(location = 1) in vec3 norm;
|
||||
@@ -36,4 +36,4 @@ void main()
|
||||
mat4 viewModel = view * model;
|
||||
gl_Position = projection * viewModel * totalPosition;
|
||||
TexCoords = tex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ int main()
|
||||
ourShader.setMat4("projection", projection);
|
||||
ourShader.setMat4("view", view);
|
||||
|
||||
auto transforms = animator.GetPoseTransforms();
|
||||
auto transforms = animator.GetFinalBoneMatrices();
|
||||
for (int i = 0; i < transforms.size(); ++i)
|
||||
ourShader.setMat4("finalBonesTransformations[" + std::to_string(i) + "]", transforms[i]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user