AutoAnimationBlend on unique node working but scale is not working correctly
This commit is contained in:
@@ -3,13 +3,19 @@
|
||||
|
||||
#include "GLM.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "../Common.h"
|
||||
#include "../Core/System.h"
|
||||
#include "../Core/ResourceManager.h"
|
||||
#include "Rendering/Model.h"
|
||||
#include "Rendering/EAnimationComplete.h"
|
||||
#include "Rendering/Skeleton.h"
|
||||
#include "Rendering/BlendTree.h"
|
||||
#include "Rendering/EAnimationBlend.h"
|
||||
#include "Rendering/EAutoAnimationBlend.h"
|
||||
#include "../Input/EInputCommand.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
class AnimationSystem : public ImpureSystem
|
||||
{
|
||||
@@ -20,7 +26,49 @@ public:
|
||||
private:
|
||||
void CreateBlendTrees();
|
||||
void UpdateAnimations(double dt);
|
||||
void UpdateWeights(double dt);
|
||||
void AnimationComplete(EntityWrapper animationEntity);
|
||||
|
||||
EventRelay<AnimationSystem, Events::AnimationBlend> m_EAnimationBlend;
|
||||
bool OnAnimationBlend(Events::AnimationBlend& e);
|
||||
EventRelay<AnimationSystem, Events::AutoAnimationBlend> m_EAutoAnimationBlend;
|
||||
bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e);
|
||||
|
||||
|
||||
EventRelay<AnimationSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
|
||||
struct BlendJob
|
||||
{
|
||||
EntityWrapper BlendEntity = EntityWrapper::Invalid;
|
||||
double StartWeight;
|
||||
double GoalWeight;
|
||||
double Duration;
|
||||
double CurrentTime = 0.0;
|
||||
};
|
||||
|
||||
struct QueuedBlendJob : BlendJob
|
||||
{
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
};
|
||||
|
||||
struct AutoBlendJob
|
||||
{
|
||||
EntityWrapper RootNode = EntityWrapper::Invalid;
|
||||
double Duration;
|
||||
double CurrentTime = 0.0;
|
||||
BlendTree::AutoBlendInfo BlendInfo;
|
||||
};
|
||||
|
||||
std::list<AutoBlendJob> m_AutoBlendJobs;
|
||||
std::list<BlendJob> m_BlendJobs;
|
||||
std::list<QueuedBlendJob> m_QueuedBlendJobs;
|
||||
|
||||
char m_AnimationName1[20] = "Run";
|
||||
float m_BlendTime1 = 0.5f;
|
||||
|
||||
char m_AnimationName2[20] = "Jump";
|
||||
float m_BlendTime2 = 0.5f;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -23,12 +23,13 @@ public:
|
||||
struct Node
|
||||
{
|
||||
std::string Name;
|
||||
EntityWrapper Entity;
|
||||
Node* Parent = nullptr;
|
||||
Node* Child[2] = { nullptr, nullptr };
|
||||
NodeType Type;
|
||||
std::map<int, glm::mat4> Pose;
|
||||
//std::vector<glm::mat4> Pose;
|
||||
float Weight = 0.f;
|
||||
double Weight = 0.0;
|
||||
|
||||
Node* Next() {
|
||||
Node* next = this;
|
||||
@@ -54,7 +55,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct AutoBlendInfo
|
||||
{
|
||||
std::string NodeName;
|
||||
double progress;
|
||||
std::unordered_map<EntityWrapper, double> StartWeights;
|
||||
};
|
||||
|
||||
|
||||
BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton);
|
||||
@@ -66,6 +72,7 @@ public:
|
||||
bool IsValid() { return (m_Root == nullptr ? false : true); }
|
||||
|
||||
void PrintTree();
|
||||
BlendTree::AutoBlendInfo AutoBlendStep(AutoBlendInfo blendInfo);
|
||||
|
||||
private:
|
||||
Skeleton* m_Skeleton = nullptr;
|
||||
@@ -76,6 +83,7 @@ private:
|
||||
|
||||
std::vector<glm::mat4> AccumulateFinalPose();
|
||||
BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity);
|
||||
std::vector<BlendTree::Node*> FindNodesByName(std::string name);
|
||||
|
||||
void Blend(std::map<int, glm::mat4>& pose);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef Events_AnimationBlend_h__
|
||||
#define Events_AnimationBlend_h__
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AnimationBlend : Event
|
||||
{
|
||||
EntityWrapper BlendEntity = EntityWrapper::Invalid;
|
||||
double GoalWeight;
|
||||
double Duration;
|
||||
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef Events_AutoAnimationBlend_h__
|
||||
#define Events_AutoAnimationBlend_h__
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AutoAnimationBlend : Event
|
||||
{
|
||||
EntityWrapper RootNode = EntityWrapper::Invalid;
|
||||
std::string NodeName;
|
||||
double Duration;
|
||||
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
std::map<int, glm::mat4> GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false);
|
||||
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
|
||||
std::map<int, glm::mat4> BlendPoses(const std::map<int, glm::mat4>& pose1, const std::map<int, glm::mat4>& pose2, float weight);
|
||||
std::map<int, glm::mat4> BlendPoses(const std::map<int, glm::mat4>& pose1, const std::map<int, glm::mat4>& pose2, double weight);
|
||||
std::map<int, glm::mat4> OverridePose(const std::map<int, glm::mat4>& overridePose, const std::map<int, glm::mat4>& targetPose);
|
||||
std::map<int, glm::mat4> BlendPoseAdditive(const std::map<int, glm::mat4>& additivePose, const std::map<int, glm::mat4>& targetPose);
|
||||
void GetFinalPose(std::map<int, glm::mat4>& boneMatrices, std::vector<glm::mat4>& finalPose, std::map<int, glm::mat4>& boneTransforms);
|
||||
|
||||
Reference in New Issue
Block a user