Set new type of animation
This commit is contained in:
1 parent
52c4ad8ee0
commit
4d9a5b0a6e
49 files changed
+684419
-64
No files matched your search
@@ -167,6 +167,7 @@ namespace ZL
|
||||
|
||||
startBones = bones;
|
||||
currentBones = bones;
|
||||
this->boneNames = boneNames;
|
||||
|
||||
// ---- Multi-mesh header ----
|
||||
std::getline(f, tempLine); // === TOTAL MESHES TO EXPORT: N ===
|
||||
@@ -487,7 +488,7 @@ namespace ZL
|
||||
if (std::memcmp(magic, "BSMF", 4) != 0)
|
||||
throw std::runtime_error("Invalid multi-mesh binary animation file (bad magic)");
|
||||
uint32_t version = readUint32();
|
||||
if (version != 1)
|
||||
if (version != 2)
|
||||
throw std::runtime_error("Unsupported multi-mesh binary animation file version");
|
||||
|
||||
// Armature matrix (row-major in file, stored with stride-4 into Matrix4f)
|
||||
@@ -528,6 +529,11 @@ namespace ZL
|
||||
startBones = bones;
|
||||
currentBones = bones;
|
||||
|
||||
// Bone names
|
||||
boneNames.resize(numBones);
|
||||
for (uint32_t i = 0; i < numBones; i++)
|
||||
boneNames[i] = readString();
|
||||
|
||||
// Meshes
|
||||
uint32_t numMeshes = readUint32();
|
||||
|
||||
@@ -629,6 +635,15 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
int BoneSystemNew::findBoneIndex(const std::string& name) const
|
||||
{
|
||||
for (size_t i = 0; i < boneNames.size(); i++)
|
||||
{
|
||||
if (boneNames[i] == name) return static_cast<int>(i);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BoneSystemNew::Interpolate(int frame)
|
||||
{
|
||||
int startingKeyFrame = -1;
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace ZL
|
||||
|
||||
std::vector<Bone> startBones;
|
||||
std::vector<Bone> currentBones;
|
||||
std::vector<std::string> boneNames;
|
||||
|
||||
std::vector<Animation> animations;
|
||||
int startingFrame = 0;
|
||||
@@ -28,6 +29,8 @@ namespace ZL
|
||||
void LoadFromBinaryFile(const std::string& fileName, const std::string& ZIPFileName = "");
|
||||
|
||||
void Interpolate(int frame);
|
||||
|
||||
int findBoneIndex(const std::string& name) const;
|
||||
};
|
||||
|
||||
struct MeshGpuSkinningData
|
||||
|
||||
+24
-22
@@ -315,10 +315,14 @@ void Character::draw(Renderer& renderer) {
|
||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||
|
||||
auto& anim = it->second;
|
||||
modelMutable.AssignFrom(anim.model.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
@@ -370,17 +374,7 @@ void Character::drawGpuSkinning(Renderer& renderer) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
|
||||
// Bind VAO (desktop only)
|
||||
#ifndef EMSCRIPTEN
|
||||
#ifndef __ANDROID__
|
||||
if (anim.gpuSkinningShaderData.bindPoseMutable.vao) {
|
||||
glBindVertexArray(anim.gpuSkinningShaderData.bindPoseMutable.vao->getBuffer());
|
||||
renderer.shaderManager.EnableVertexAttribArrays();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
anim.gpuSkinningShaderData.RenderVBO(renderer);
|
||||
anim.gpuSkinningShaderData.RenderVBO(renderer, anim.model.meshNamesOrdered);
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
@@ -477,9 +471,13 @@ void Character::drawShadowDepthCpu(Renderer& renderer) {
|
||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||
|
||||
auto& anim = it->second;
|
||||
modelMutable.AssignFrom(anim.model.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
}
|
||||
renderer.PopMatrix();
|
||||
|
||||
drawAttachedWeapon(renderer);
|
||||
@@ -516,7 +514,7 @@ void Character::drawShadowDepthGpuSkinning(Renderer& renderer) {
|
||||
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
renderer.PopMatrix();
|
||||
@@ -565,10 +563,14 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
|
||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||
|
||||
auto& anim = it->second;
|
||||
modelMutable.AssignFrom(anim.model.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
@@ -628,7 +630,7 @@ void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matri
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "BoneAnimatedModel.h"
|
||||
#include "BoneAnimatedModelNew.h"
|
||||
#include "render/Renderer.h"
|
||||
#include "render/TextureManager.h"
|
||||
#include "items/Item.h"
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::map<AnimationState, BoneAnimationData> animations;
|
||||
std::map<AnimationState, BoneAnimationDataNew> animations;
|
||||
VertexRenderStruct modelMutable;
|
||||
std::shared_ptr<Texture> texture;
|
||||
|
||||
|
||||
+1
-7
@@ -520,15 +520,9 @@ namespace ZL
|
||||
}
|
||||
for (auto& npc : npcs)
|
||||
{
|
||||
if (npc->canAttack)
|
||||
{
|
||||
npc->update(delta);
|
||||
}
|
||||
//npc->update(delta);
|
||||
npc->update(delta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if player reached target interactive object
|
||||
if (targetInteractiveObject && player) {
|
||||
float distToObject = (player->position - targetInteractiveObject->position).norm();
|
||||
|
||||
Reference in new issue
Block a user