Animation blending improved and Animation Override added
This commit is contained in:
@@ -133,7 +133,16 @@ struct ModelJob : RenderJob
|
||||
}
|
||||
animationData.time = (double)animationComponent["Time" + std::to_string(i)];
|
||||
animationData.weight = (double)animationComponent["Weight" + std::to_string(i)];
|
||||
|
||||
if((int)animationComponent["BlendType" + std::to_string(i)].Enum("Additive") == (int)animationComponent["BlendType" + std::to_string(i)]) {
|
||||
animationData.blendType = Skeleton::BlendType::Additive;
|
||||
} else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Blend") == (int)animationComponent["BlendType" + std::to_string(i)]) {
|
||||
animationData.blendType = Skeleton::BlendType::Blend;
|
||||
} else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Override") == (int)animationComponent["BlendType" + std::to_string(i)]) {
|
||||
animationData.blendType = Skeleton::BlendType::Override;
|
||||
}
|
||||
|
||||
animationData.level = (int)animationComponent["Level" + std::to_string(i)];
|
||||
Animations.push_back(animationData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,18 +68,26 @@ public:
|
||||
std::map<int, std::vector<Keyframe>> JointAnimations;
|
||||
};
|
||||
|
||||
enum class BlendType
|
||||
{
|
||||
Additive,
|
||||
Blend,
|
||||
Override,
|
||||
};
|
||||
struct AnimationData
|
||||
{
|
||||
const Animation* animation;
|
||||
BlendType blendType;
|
||||
float time;
|
||||
int level;
|
||||
float weight;
|
||||
};
|
||||
|
||||
struct JointFrameTransform {
|
||||
glm::vec3 Position = glm::vec3(0);
|
||||
glm::quat Rotation = glm::quat();
|
||||
glm::vec3 Scale = glm::vec3(0);
|
||||
float Weight;
|
||||
struct JointFramePose {
|
||||
BlendType Type;
|
||||
int Level = 0;
|
||||
glm::mat4 Pose = glm::mat4(0);
|
||||
float Weight = 0.0f;
|
||||
};
|
||||
|
||||
struct AnimationOffset {
|
||||
@@ -119,8 +127,10 @@ public:
|
||||
glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector<AnimationData> animations, glm::mat4 childMatrix);
|
||||
int GetKeyframe(const Animation& animation, double time);
|
||||
|
||||
|
||||
private:
|
||||
JointFrameTransform GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
||||
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
||||
glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion);
|
||||
|
||||
std::map<std::string, Bone*> m_BonesByName;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user