diff --git a/.gitignore b/.gitignore index dfcbe19a..c8e7988f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules cmake-build-debug .idea docs +/.vs diff --git a/include/Mesh.hpp b/include/Mesh.hpp index ff960406..29182350 100644 --- a/include/Mesh.hpp +++ b/include/Mesh.hpp @@ -48,7 +48,7 @@ class Mesh : public MeshUnmanaged { other.indices = nullptr; other.animVertices = nullptr; other.animNormals = nullptr; - other.boneIds = nullptr; + other.boneIndices = nullptr; other.boneWeights = nullptr; other.vaoId = 0; other.vboId = nullptr; @@ -73,7 +73,7 @@ class Mesh : public MeshUnmanaged { other.indices = nullptr; other.animVertices = nullptr; other.animNormals = nullptr; - other.boneIds = nullptr; + other.boneIndices = nullptr; other.boneWeights = nullptr; other.vaoId = 0; other.vboId = nullptr; diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index 386ae2a4..8aaa1d6e 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -35,9 +35,8 @@ class MeshUnmanaged : public ::Mesh { indices = nullptr; animVertices = nullptr; animNormals = nullptr; - boneIds = nullptr; + boneIndices = nullptr; boneWeights = nullptr; - boneMatrices = nullptr; boneCount = 0; vaoId = 0; vboId = nullptr; @@ -130,7 +129,7 @@ class MeshUnmanaged : public ::Mesh { GETTERSETTER(unsigned short*, Indices, indices) // NOLINT GETTERSETTER(float*, AnimVertices, animVertices) GETTERSETTER(float*, AnimNormals, animNormals) - GETTERSETTER(unsigned char*, BoneIds, boneIds) + GETTERSETTER(unsigned char*, BoneIndices, boneIndices) GETTERSETTER(float*, BoneWeights, boneWeights) GETTERSETTER(unsigned int, VaoId, vaoId) GETTERSETTER(unsigned int*, VboId, vboId) @@ -242,9 +241,8 @@ class MeshUnmanaged : public ::Mesh { indices = mesh.indices; animVertices = mesh.animVertices; animNormals = mesh.animNormals; - boneIds = mesh.boneIds; + boneIndices = mesh.boneIndices; boneWeights = mesh.boneWeights; - boneMatrices = mesh.boneMatrices; vaoId = mesh.vaoId; vboId = mesh.vboId; } diff --git a/include/Model.hpp b/include/Model.hpp index c8c65af5..5e6597c0 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -58,9 +58,13 @@ class Model : public ::Model { other.meshes = nullptr; other.materials = nullptr; other.meshMaterial = nullptr; - other.boneCount = 0; - other.bones = nullptr; - other.bindPose = nullptr; + + other.skeleton.boneCount = 0; + other.skeleton.bones = nullptr; + other.skeleton.bindPose = nullptr; + + ModelAnimPose currentPose; + Matrix *boneMatrices; } GETTERSETTER(::Matrix, Transform, transform) @@ -69,9 +73,11 @@ class Model : public ::Model { GETTERSETTER(::Mesh*, Meshes, meshes) GETTERSETTER(::Material*, Materials, materials) GETTERSETTER(int*, MeshMaterial, meshMaterial) - GETTERSETTER(int, BoneCount, boneCount) - GETTERSETTER(::BoneInfo*, Bones, bones) - GETTERSETTER(::Transform*, BindPose, bindPose) + GETTERSETTER(int, BoneCount, skeleton.boneCount) + GETTERSETTER(::BoneInfo*, Bones, skeleton.bones) + GETTERSETTER(::Transform*, BindPose, skeleton.bindPose) + GETTERSETTER(::ModelAnimPose, CurrentPose, currentPose) + GETTERSETTER(::Matrix*, BoneMatrices, boneMatrices) Model& operator=(const ::Model& model) { set(model); @@ -93,9 +99,11 @@ class Model : public ::Model { other.meshes = nullptr; other.materials = nullptr; other.meshMaterial = nullptr; - other.boneCount = 0; - other.bones = nullptr; - other.bindPose = nullptr; + other.skeleton.boneCount = 0; + other.skeleton.bones = nullptr; + other.skeleton.bindPose = nullptr; + other.currentPose = nullptr; + other.boneMatrices = nullptr; return *this; } @@ -122,7 +130,7 @@ class Model : public ::Model { /** * Update model animation pose */ - Model& UpdateAnimation(const ::ModelAnimation& anim, int frame) { + Model& UpdateAnimation(const ::ModelAnimation& anim, float frame) { ::UpdateModelAnimation(*this, anim, frame); return *this; } @@ -130,8 +138,8 @@ class Model : public ::Model { /** * Update model animation pose */ - Model& UpdateAnimationBones(const ::ModelAnimation& anim, int frame) { - ::UpdateModelAnimationBones(*this, anim, frame); + Model& UpdateAnimationsEx(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { + ::UpdateModelAnimationEx(*this, animA, frameA, animB, frameB, blend); return *this; } @@ -240,9 +248,11 @@ class Model : public ::Model { materials = model.materials; meshMaterial = model.meshMaterial; - boneCount = model.boneCount; - bones = model.bones; - bindPose = model.bindPose; + skeleton.boneCount = model.skeleton.boneCount; + skeleton.bones = model.skeleton.bones; + skeleton.bindPose = model.skeleton.bindPose; + currentPose = model.currentPose; + boneMatrices = model.boneMatrices; } }; diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index f747244e..c5b2efd1 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -22,12 +22,12 @@ class ModelAnimation : public ::ModelAnimation { set(other); other.boneCount = 0; - other.frameCount = 0; - other.bones = nullptr; - other.framePoses = nullptr; + other.keyframeCount = 0; + other.keyframePoses = nullptr; } - ~ModelAnimation() { Unload(); } + // TODO: Implement a way to unload all animations at once, as the current Unload() only unloads one animation. + ~ModelAnimation() { Unload(1); } /** * Load model animations from file @@ -43,9 +43,8 @@ class ModelAnimation : public ::ModelAnimation { } GETTERSETTER(int, BoneCount, boneCount) - GETTERSETTER(::BoneInfo*, Bones, bones) - GETTERSETTER(int, FrameCount, frameCount) - GETTERSETTER(::Transform**, FramePoses, framePoses) + GETTERSETTER(int, KeyframeCount, keyframeCount) + GETTERSETTER(::Transform**, KeyframePoses, keyframePoses) ModelAnimation& operator=(const ::ModelAnimation& model) { set(model); @@ -59,13 +58,12 @@ class ModelAnimation : public ::ModelAnimation { return *this; } - Unload(); + Unload(1); set(other); other.boneCount = 0; - other.frameCount = 0; - other.bones = nullptr; - other.framePoses = nullptr; + other.keyframeCount = 0; + other.keyframePoses = nullptr; return *this; } @@ -73,7 +71,7 @@ class ModelAnimation : public ::ModelAnimation { /** * Unload animation data */ - void Unload() { ::UnloadModelAnimation(*this); } + void Unload(int animCount) { ::UnloadModelAnimations(this, animCount); } /** * Update model animation pose @@ -87,7 +85,7 @@ class ModelAnimation : public ::ModelAnimation { * Update model animation mesh bone matrices (GPU skinning) */ ModelAnimation& UpdateBones(const ::Model& model, int frame) { - ::UpdateModelAnimationBones(model, *this, frame); + ::UpdateModelAnimation(model, *this, frame); return *this; } @@ -98,9 +96,8 @@ class ModelAnimation : public ::ModelAnimation { protected: void set(const ::ModelAnimation& model) { boneCount = model.boneCount; - frameCount = model.frameCount; - bones = model.bones; - framePoses = model.framePoses; + keyframeCount = model.keyframeCount; + keyframePoses = model.keyframePoses; // Duplicate the name. TextCopy() uses the null terminator, which we ignore here. for (int i = 0; i < 32; i++) {