Adjust irrlicht CSkinnedMesh class for .spm

The last frame in .spm is usable
This commit is contained in:
Benau 2017-12-02 15:24:05 +08:00
parent 2161efd9c4
commit 3607c7d520
4 changed files with 11 additions and 6 deletions

View File

@ -68,7 +68,7 @@ namespace scene
//! constructor
CSkinnedMesh::CSkinnedMesh()
: SkinningBuffers(0), AnimationFrames(0.f), FramesPerSecond(25.f),
: AnimationFrames(0.f), SkinningBuffers(0), FramesPerSecond(25.f),
LastAnimatedFrame(-1), SkinnedLastFrame(false),
InterpolationMode(EIM_LINEAR),
HasAnimation(false), PreparedForSkinning(false),

View File

@ -175,6 +175,8 @@ namespace scene
u32 getTotalJoints() const { return m_total_joints; }
f32 AnimationFrames;
private:
void toStaticPose();
@ -215,7 +217,6 @@ private:
core::aabbox3d<f32> BoundingBox;
f32 AnimationFrames;
f32 FramesPerSecond;
f32 LastAnimatedFrame;

View File

@ -20,6 +20,7 @@
#include "utils/constants.hpp"
#include "utils/mini_glm.hpp"
#include "../../lib/irrlicht/source/Irrlicht/CSkinnedMesh.h"
const uint8_t VERSION_NOW = 1;
#include <algorithm>
@ -47,7 +48,7 @@ scene::IAnimatedMesh* SPMeshLoader::createMesh(io::IReadFile* f)
}
m_bind_frame = 0;
m_joint_count = 0;
//m_frame_count = 0;
m_frame_count = 0;
m_mesh = NULL;
m_mesh = m_scene_manager->createSkinnedMesh();
io::IFileSystem* fs = m_scene_manager->getFileSystem();
@ -196,6 +197,9 @@ scene::IAnimatedMesh* SPMeshLoader::createMesh(io::IReadFile* f)
f->read(&pre_computed_size, 2);
}
m_mesh->finalize();
// Because the last frame in spm is usable
static_cast<scene::CSkinnedMesh*>(m_mesh)->AnimationFrames =
(float)m_frame_count + 1.0f;
m_all_armatures.clear();
m_to_bind_pose_matrices.clear();
m_joints.clear();
@ -366,8 +370,8 @@ void SPMeshLoader::createAnimationData(irr::io::IReadFile* spm)
}
for (unsigned i = 0; i < armature_size; i++)
{
//m_frame_count = std::max(m_frame_count,
// (unsigned)m_all_armatures[i].m_frame_pose_matrices.back().first);
m_frame_count = std::max(m_frame_count,
(unsigned)m_all_armatures[i].m_frame_pose_matrices.back().first);
m_joint_count += m_all_armatures[i].m_joint_used;
}

View File

@ -79,7 +79,7 @@ private:
unsigned id);
};
// ------------------------------------------------------------------------
unsigned m_bind_frame, m_joint_count;//, m_frame_count;
unsigned m_bind_frame, m_joint_count, m_frame_count;
// ------------------------------------------------------------------------
std::vector<Armature> m_all_armatures;
// ------------------------------------------------------------------------