Merge remote-tracking branch 'origin/Animations' into TCPConnections

This commit is contained in:
stiffly
2016-02-11 22:15:59 +01:00
9 changed files with 655 additions and 277 deletions
+28 -2
View File
@@ -120,6 +120,32 @@ struct ModelJob : RenderJob
if (model->IsSkinned()) {
Skeleton = Model->m_RawModel->m_Skeleton;
if (Skeleton != nullptr) {
if (world->HasComponent(Entity, "Animation")) {
auto animationComponent = world->GetComponent(Entity, "Animation");
for (int i = 1; i <= 3; i++) {
::Skeleton::AnimationData animationData;
animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]);
if (animationData.animation == nullptr) {
continue;
}
animationData.time = (double)animationComponent["Time" + std::to_string(i)];
animationData.weight = (double)animationComponent["Weight" + std::to_string(i)];
Animations.push_back(animationData);
}
}
if (world->HasComponent(Entity, "AnimationOffset")) {
auto animationOffsetComponent = world->GetComponent(Entity, "AnimationOffset");
AnimationOffset.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationOffsetComponent["AnimationName"]);
AnimationOffset.time = (double)animationOffsetComponent["Time"];
} else {
AnimationOffset.animation = nullptr;
}
}
}
};
@@ -140,8 +166,8 @@ struct ModelJob : RenderJob
glm::vec4 Color;
const ::Model* Model = nullptr;
::Skeleton* Skeleton = nullptr;
// const ::Skeleton::Animation* Animation = nullptr;
std::vector<::Skeleton::AnimationData> Animations;
::Skeleton::AnimationOffset AnimationOffset;
+7 -28
View File
@@ -100,50 +100,29 @@ public:
int GetBoneID(std::string name);
void CalculateFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
void CalculateFrameBones(std::vector<AnimationData> animations, bool noRootMotion = false);
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, bool noRootMotion = false);
const Animation* GetAnimation(std::string name);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, const Bone* bone, glm::mat4 parentMatrix);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, const Bone* bone, glm::mat4 parentMatrix);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, std::map<int, glm::mat4>& frameBones, const Bone* bone, glm::mat4 parentMatrix);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, std::map<int, glm::mat4>& frameBones, const Bone* bone, glm::mat4 parentMatrix);
void PrintSkeleton();
void PrintSkeleton(const Bone* parent, int depthCount);
std::map<std::string, Animation> Animations;
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector<AnimationData> animations, AnimationOffset animationOffset, glm::mat4 childMatrix);
glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector<AnimationData> animations, glm::mat4 childMatrix);
int GetKeyframe(const Animation& animation, double time);
std::vector<glm::mat4> GetBones()
{
std::vector<glm::mat4> finalMatrices;
for (auto &kv : m_BoneLocalTransforms) {
finalMatrices.push_back(kv.second);
}
return finalMatrices;;
}
glm::mat4 GetBoneTransformSuper(int boneID)
{
if(m_BoneTransforms.find(boneID) != m_BoneTransforms.end()) {
return m_BoneTransforms.at(boneID);
} else {
return glm::mat4(1);
}
}
private:
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
std::map<std::string, Bone*> m_BonesByName;
float aim = 0.f;
std::map<int, glm::mat4> m_BoneLocalTransforms;
std::map<int, glm::mat4> m_BoneTransforms;
};
#endif