diff --git a/CMakeLists.txt b/CMakeLists.txt index a60f028d3..86b4b3baf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,8 @@ else() set(LIBS ) endif(WIN32) +set(CMAKE_CXX_STANDARD 14) + set(CHAPTERS 1.getting_started 2.lighting @@ -62,6 +64,7 @@ set(CHAPTERS 5.advanced_lighting 6.pbr 7.in_practice + 8.guest ) set(1.getting_started @@ -166,6 +169,10 @@ set(7.in_practice #3.2d_game ) +set(8.guest + skeletal_animation +) + configure_file(configuration/root_directory.h.in configuration/root_directory.h) diff --git a/includes/learnopengl/animator.h b/includes/learnopengl/animator.h index 341ccb202..9d3bca5db 100644 --- a/includes/learnopengl/animator.h +++ b/includes/learnopengl/animator.h @@ -11,7 +11,7 @@ class Animator { public: - Animator::Animator(Animation* current) + Animator(Animation* current) { m_CurrentAnimation = current; m_CurrentTime = 0.0; @@ -20,7 +20,7 @@ class Animator m_Transforms.push_back(glm::mat4(1.0f)); } - void Animator::UpdateAnimation(float dt) + void UpdateAnimation(float dt) { m_DeltaTime = dt; if (m_CurrentAnimation) @@ -31,13 +31,13 @@ class Animator } } - 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; @@ -75,4 +75,4 @@ class Animator float m_CurrentTime; float m_DeltaTime; -}; \ No newline at end of file +}; diff --git a/includes/learnopengl/assimp_glm_helpers.h b/includes/learnopengl/assimp_glm_helpers.h index 960c1d938..6d8b3f2ce 100644 --- a/includes/learnopengl/assimp_glm_helpers.h +++ b/includes/learnopengl/assimp_glm_helpers.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -31,4 +31,4 @@ class AssimpGLMHelpers { return glm::quat(pOrientation.w, pOrientation.x, pOrientation.y, pOrientation.z); } -}; \ No newline at end of file +}; diff --git a/includes/learnopengl/bone.h b/includes/learnopengl/bone.h index e562041b6..8e48b160d 100644 --- a/includes/learnopengl/bone.h +++ b/includes/learnopengl/bone.h @@ -160,7 +160,7 @@ class Bone } - 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); diff --git a/includes/learnopengl/mesh.h b/includes/learnopengl/mesh.h index 743a3bddb..18acfd6bd 100644 --- a/includes/learnopengl/mesh.h +++ b/includes/learnopengl/mesh.h @@ -12,6 +12,8 @@ #include using namespace std; +#define MAX_BONE_INFLUENCE 4 + struct Vertex { // position glm::vec3 Position; @@ -23,6 +25,12 @@ struct Vertex { glm::vec3 Tangent; // bitangent glm::vec3 Bitangent; + + //bone indexes which will influence this vertex + int m_BoneIDs[MAX_BONE_INFLUENCE]; + + //weights from each bone + float m_Weights[MAX_BONE_INFLUENCE]; }; struct Texture { diff --git a/includes/learnopengl/model_animation.h b/includes/learnopengl/model_animation.h index f1200f0bc..eda24e0a8 100644 --- a/includes/learnopengl/model_animation.h +++ b/includes/learnopengl/model_animation.h @@ -97,7 +97,7 @@ class Model void SetVertexBoneDataToDefault(Vertex& vertex) { - for (int i = 0; i < MAX_BONE_WEIGHTS; i++) + for (int i = 0; i < AI_MAX_BONE_WEIGHTS; i++) { vertex.m_BoneIDs[i] = -1; vertex.m_Weights[i] = 0.0f; @@ -154,7 +154,7 @@ class Model void SetVertexBoneData(Vertex& vertex, int boneID, float weight) { - for (int i = 0; i < MAX_BONE_WEIGHTS; ++i) + for (int i = 0; i < AI_MAX_BONE_WEIGHTS; ++i) { if (vertex.m_BoneIDs[i] < 0) { diff --git a/src/8.guest/2020/skeletal_animation/skeletal_animation.cpp b/src/8.guest/skeletal_animation/skeletal_animation.cpp similarity index 100% rename from src/8.guest/2020/skeletal_animation/skeletal_animation.cpp rename to src/8.guest/skeletal_animation/skeletal_animation.cpp