Fixed BoneAttachment component and optimized animation code a bit
This commit is contained in:
+1
-1
Submodule assets updated: 7531e441fe...45cbc3abae
@@ -23,9 +23,7 @@ public:
|
|||||||
~AnimationSystem() { }
|
~AnimationSystem() { }
|
||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) override;
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) override;
|
||||||
private:
|
private:
|
||||||
float angle = 0.f;
|
|
||||||
bool b_forward = false;
|
|
||||||
char bone[100];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -117,33 +117,11 @@ struct ModelJob : RenderJob
|
|||||||
FillColor = fillColor;
|
FillColor = fillColor;
|
||||||
FillPercentage = fillPercentage;
|
FillPercentage = fillPercentage;
|
||||||
|
|
||||||
Skeleton = Model->m_RawModel->m_Skeleton;
|
|
||||||
|
|
||||||
if (Skeleton != nullptr) {
|
if (model->IsSkinned()) {
|
||||||
if (world->HasComponent(Entity, "Animation")) {
|
Skeleton = Model->m_RawModel->m_Skeleton;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int TextureID;
|
unsigned int TextureID;
|
||||||
@@ -164,10 +142,8 @@ struct ModelJob : RenderJob
|
|||||||
::Skeleton* Skeleton = nullptr;
|
::Skeleton* Skeleton = nullptr;
|
||||||
// const ::Skeleton::Animation* Animation = nullptr;
|
// const ::Skeleton::Animation* Animation = nullptr;
|
||||||
|
|
||||||
std::vector<::Skeleton::AnimationData> Animations;
|
|
||||||
::Skeleton::AnimationOffset AnimationOffset;
|
|
||||||
|
|
||||||
float AnimationTime = 0.f;
|
|
||||||
|
|
||||||
glm::vec4 DiffuseColor;
|
glm::vec4 DiffuseColor;
|
||||||
glm::vec4 SpecularColor;
|
glm::vec4 SpecularColor;
|
||||||
|
|||||||
@@ -100,13 +100,13 @@ public:
|
|||||||
|
|
||||||
int GetBoneID(std::string name);
|
int GetBoneID(std::string name);
|
||||||
|
|
||||||
const Animation* GetAnimation(std::string name);
|
void CalculateFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
|
||||||
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, 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);
|
|
||||||
|
|
||||||
//void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, float time, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
|
const Animation* GetAnimation(std::string name);
|
||||||
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
|
|
||||||
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
|
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 PrintSkeleton();
|
void PrintSkeleton();
|
||||||
void PrintSkeleton(const Bone* parent, int depthCount);
|
void PrintSkeleton(const Bone* parent, int depthCount);
|
||||||
@@ -115,12 +115,35 @@ public:
|
|||||||
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
|
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
|
||||||
int GetKeyframe(const Animation& animation, double time);
|
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:
|
private:
|
||||||
|
|
||||||
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
||||||
|
|
||||||
std::map<std::string, Bone*> m_BonesByName;
|
std::map<std::string, Bone*> m_BonesByName;
|
||||||
float aim = 0.f;
|
float aim = 0.f;
|
||||||
|
|
||||||
|
|
||||||
|
std::map<int, glm::mat4> m_BoneLocalTransforms;
|
||||||
|
std::map<int, glm::mat4> m_BoneTransforms;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,28 +31,524 @@
|
|||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Run</AnimationName1>
|
<AnimationName1>Run</AnimationName1>
|
||||||
<Weight1>0.5</Weight1>
|
<Weight1>0.5</Weight1>
|
||||||
<Time1>0.23980116887997371</Time1>
|
<Time1>0.78014858943309839</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
<Speed2>1</Speed2>
|
<Speed2>1</Speed2>
|
||||||
<AnimationName2>StrafeRight</AnimationName2>
|
<AnimationName2>StrafeRight</AnimationName2>
|
||||||
<Weight2>0.5</Weight2>
|
<Weight2>0.5</Weight2>
|
||||||
<Time2>0.42593105566437428</Time2>
|
<Time2>0.78620929522779459</Time2>
|
||||||
<AnimationName3>ReloadSwitch</AnimationName3>
|
<AnimationName3>ShootFastRifle</AnimationName3>
|
||||||
<Time3>0.68855715986371058</Time3>
|
<Time3>0.13809128482706701</Time3>
|
||||||
<Speed3>1</Speed3>
|
<Speed3>1</Speed3>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:AnimationOffset>
|
<c:AnimationOffset>
|
||||||
<AnimationName>AimRifle</AnimationName>
|
<AnimationName>AimRifle</AnimationName>
|
||||||
|
<Time>0.040000014007091522</Time>
|
||||||
</c:AnimationOffset>
|
</c:AnimationOffset>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
|
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
|
||||||
<Color A="1" B="0.984313726" G="1" R="1"/>
|
<Color A="0.627451003" B="19.6078434" G="1" R="3.92156863"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-0.690088332" Y="0" Z="0"/>
|
<Position X="-0.690088332" Y="0" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children>
|
||||||
|
<Entity name="Skeleton">
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="R_Arm_Weapon_Joint">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Arm_Weapon_Joint</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Weapons/Blue/AssaultWeapon.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="1" R="19.6078434"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.146708429" Y="0.959003806" Z="-0.144033641"/>
|
||||||
|
<Orientation X="-0.690611959" Y="0.0597511008" Z="0.907224596"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Hand">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Hand</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.19621858" Y="0.975460351" Z="-0.104317382"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.690611959" Y="0.0597511008" Z="0.907224596"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Arm">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Arm</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.112078801" Y="1.12475431" Z="0.0186089575"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.348061472" Y="-0.280602992" Z="0.0212468337"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Shoulder">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Shoulder</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0998888761" Y="1.06440032" Z="-0.0541408062"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097531" Z="0.295018554"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Neck">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Neck</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0595470108" Y="1.13743448" Z="-0.115631148"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.474229157" Y="0.226053014" Z="0.283275545"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Spine_3">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Spine_3</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.040999718" Y="1.07331288" Z="-0.0806797668"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097531" Z="0.295018554"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Spine_2">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Spine_2</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0108884424" Y="0.970344663" Z="-0.0237468518"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097531" Z="0.295018554"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Spine_1">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Spine_1</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.000923306216" Y="0.839232147" Z="-0.0103478255"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.453410149" Y="0.84963572" Z="0.317277819"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Hip">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Hip</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.706098855" Z="0"/>
|
||||||
|
<Scale X="0.100000001" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.0795478821" Y="0.278701752" Z="0.00956994947"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Leg_Top">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Leg_Top</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0715532005" Y="0.667656481" Z="-0.0155252069"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.863384187" Y="-0.0913920924" Z="-0.0523470864"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Leg_Bottom">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Leg_Bottom</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0830632523" Y="0.43405664" Z="-0.297806978"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.227692038" Y="-0.13753739" Z="-0.134345591"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Foot">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Foot</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0640328377" Y="0.0827684402" Z="-0.195051223"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.191934288" Y="0.0670221746" Z="0.0191321708"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Toe">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Toe</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.057431899" Y="0.0840257108" Z="-0.387664855"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.191934288" Y="0.0670221746" Z="0.0191321708"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Shoulder">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Shoulder</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0232796557" Y="1.04240012" Z="-0.133887768"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097531" Z="0.295018554"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Arm">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Arm</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0629788637" Y="1.0744822" Z="-0.163618684"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.526039183" Y="0.750539362" Z="-0.983756781"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Hand">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Hand</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.051236406" Y="0.847513258" Z="-0.384556502"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.773511231" Y="0.0559770092" Z="-2.11538386"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Shoulder_Armor_Joint">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Shoulder_Armor_Joint</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0417820327" Y="1.11634767" Z="-0.207201466"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097472" Z="0.514142215"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Chin">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Chin</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0709581524" Y="1.10222101" Z="-0.22557795"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.511836052" Y="0.034663897" Z="0.28629449"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Head">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Head</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0924771726" Y="1.22002876" Z="-0.173797935"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.511836052" Y="0.034663897" Z="0.28629449"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Perietal">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>Perietal</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.143368542" Y="1.36145091" Z="-0.268759578"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.511836052" Y="0.034663897" Z="0.28629449"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="L_Elbow">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Elbow</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.0896638185" Y="0.883698523" Z="-0.277650088"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-1.29343295" Y="0.500798821" Z="-1.7653892"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Leg_Bottom">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Leg_Bottom</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.169350237" Y="0.325810552" Z="-0.0545702502"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="1.05215073" Y="0.426247299" Z="0.235435873"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Elbow">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Elbow</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.326490343" Y="1.00602782" Z="0.0126616545"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-1.18299294" Y="-0.366671294" Z="1.66835237"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Leg_Top">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Leg_Top</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0702434108" Y="0.66948396" Z="0.025169529"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="-0.270252436" Y="0.219192564" Z="-0.194402263"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Foot">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Foot</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.111992255" Y="0.145771623" Z="0.259642601"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.824790478" Y="0.332380295" Z="0.256255209"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Toe">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Toe</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.169808939" Y="-0.0109154135" Z="0.163479775"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.824790478" Y="0.332380295" Z="0.256255209"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="R_Shoulder_Armor_Joint">
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Shoulder_Armor_Joint</BoneName>
|
||||||
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.14515765" Y="1.17003202" Z="-0.012605153"/>
|
||||||
|
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
|
||||||
|
<Orientation X="0.676645637" Y="0.781097531" Z="0.130682677"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity>
|
<Entity>
|
||||||
<Components>
|
<Components>
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="AnimationTests" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.100000001" Y="-1.11500001" Z="-3.10500026"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:DirectionalLight/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Widgets/Lights/DirectionalLightWidget.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="2.42800021" Z="-2.80000019"/>
|
||||||
|
<Orientation X="5.40800047" Y="3.65100026" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Wave">
|
||||||
|
<Components>
|
||||||
|
<c:Animation>
|
||||||
|
<AnimationName1>Run</AnimationName1>
|
||||||
|
<Weight1>0.5</Weight1>
|
||||||
|
<Time1>0.97312056690160276</Time1>
|
||||||
|
<Speed1>1</Speed1>
|
||||||
|
<Speed2>1</Speed2>
|
||||||
|
<AnimationName2>ReloadSwitch</AnimationName2>
|
||||||
|
<Time2>0.91310356788604263</Time2>
|
||||||
|
<AnimationName3>LeftRight</AnimationName3>
|
||||||
|
<Weight3>0</Weight3>
|
||||||
|
<Time3>0.040207288496060478</Time3>
|
||||||
|
<Speed3>1</Speed3>
|
||||||
|
</c:Animation>
|
||||||
|
<c:AnimationOffset>
|
||||||
|
<AnimationName>DownUp</AnimationName>
|
||||||
|
<Time>0.77999961376190186</Time>
|
||||||
|
</c:AnimationOffset>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||||
|
<Color A="0.627451003" B="19.6078434" G="1" R="3.92156863"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.690088332" Y="1.00491476" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Arm_Weapon_Joint</BoneName>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Weapons/Blue/AssaultWeapon.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.120548911" Y="-0.223148599" Z="-0.151705116"/>
|
||||||
|
<Orientation X="0.09407565" Y="0.0181003436" Z="0.0279055703"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Camera/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:PointLight>
|
||||||
|
<Radius>10</Radius>
|
||||||
|
</c:PointLight>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.0823108" Z="0.738871336"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitPlane.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="10" Y="1" Z="10"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="Wave" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Animation>
|
||||||
|
<AnimationName1>Run</AnimationName1>
|
||||||
|
<Weight1>0.5</Weight1>
|
||||||
|
<Time1>0.97312056690160276</Time1>
|
||||||
|
<Speed1>1</Speed1>
|
||||||
|
<Speed2>1</Speed2>
|
||||||
|
<AnimationName2>ReloadSwitch</AnimationName2>
|
||||||
|
<Time2>0.91310356788604263</Time2>
|
||||||
|
<AnimationName3>LeftRight</AnimationName3>
|
||||||
|
<Weight3>0</Weight3>
|
||||||
|
<Time3>0.040207288496060478</Time3>
|
||||||
|
<Speed3>1</Speed3>
|
||||||
|
</c:Animation>
|
||||||
|
<c:AnimationOffset>
|
||||||
|
<AnimationName>DownUp</AnimationName>
|
||||||
|
<Time>0.77999961376190186</Time>
|
||||||
|
</c:AnimationOffset>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||||
|
<Color A="0.627451003" B="19.6078434" G="1" R="3.92156863"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.690088332" Y="1.00491476" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Arm_Weapon_Joint</BoneName>
|
||||||
|
</c:BoneAttachment>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Weapons/Blue/AssaultWeapon.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.120778561" Y="-0.223796993" Z="-0.15143311"/>
|
||||||
|
<Orientation X="0.0957378224" Y="0.0132024018" Z="0.0284451656"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Camera/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -47,7 +47,7 @@ ComponentWrapper ComponentPool::Allocate(EntityID entity)
|
|||||||
|
|
||||||
ComponentWrapper ComponentPool::GetByEntity(EntityID ent)
|
ComponentWrapper ComponentPool::GetByEntity(EntityID ent)
|
||||||
{
|
{
|
||||||
return ComponentWrapper(m_ComponentInfo, m_EntityToComponent.at(ent));
|
return ComponentWrapper(m_ComponentInfo, m_EntityToComponent.at(ent));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComponentPool::KnowsEntity(EntityID ent)
|
bool ComponentPool::KnowsEntity(EntityID ent)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
|
|||||||
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]);
|
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]);
|
||||||
|
|
||||||
if (animation == nullptr) {
|
if (animation == nullptr) {
|
||||||
return;
|
continue;;
|
||||||
}
|
}
|
||||||
|
|
||||||
double animationSpeed = (double)animationComponent["Speed" + std::to_string(i)];
|
double animationSpeed = (double)animationComponent["Speed" + std::to_string(i)];
|
||||||
@@ -49,5 +49,32 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Calculate bone transforms
|
||||||
|
if (skeleton != nullptr) {
|
||||||
|
std::vector<Skeleton::AnimationData> animations;
|
||||||
|
if (entity.HasComponent("Animation")) {
|
||||||
|
for (int i = 1; i <= 3; i++) {
|
||||||
|
Skeleton::AnimationData animationData;
|
||||||
|
animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(entity["Animation"]["AnimationName" + std::to_string(i)]);
|
||||||
|
if (animationData.animation == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
animationData.time = (double)entity["Animation"]["Time" + std::to_string(i)];
|
||||||
|
animationData.weight = (double)entity["Animation"]["Weight" + std::to_string(i)];
|
||||||
|
|
||||||
|
animations.push_back(animationData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent("AnimationOffset")) {
|
||||||
|
Skeleton::AnimationOffset animationOffset;
|
||||||
|
animationOffset.animation = skeleton->GetAnimation(entity["AnimationOffset"]["AnimationName"]);
|
||||||
|
animationOffset.time = (double)entity["AnimationOffset"]["Time"];
|
||||||
|
skeleton->CalculateFrameBones(animations, animationOffset);
|
||||||
|
} else {
|
||||||
|
skeleton->CalculateFrameBones(animations);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 boneTransform = skeleton->GetBoneTransform(skeleton->Bones[id], animation, (double)parent["Animation"]["Time1"], glm::mat4(1));
|
glm::mat4 boneTransform = skeleton->GetBoneTransformSuper(id);
|
||||||
|
//glm::mat4 boneTransform = skeleton->GetBoneTransform(skeleton->Bones[id], animation, (double)parent["Animation"]["Time1"], glm::mat4(1));
|
||||||
|
|
||||||
glm::vec3 scale;
|
glm::vec3 scale;
|
||||||
glm::quat rotation;
|
glm::quat rotation;
|
||||||
@@ -48,7 +49,9 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
glm::vec4 perspective;
|
glm::vec4 perspective;
|
||||||
glm::decompose(boneTransform, scale, rotation, translation, skew, perspective);
|
glm::decompose(boneTransform, scale, rotation, translation, skew, perspective);
|
||||||
|
|
||||||
glm::vec3 angles;
|
glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation));
|
||||||
|
/*
|
||||||
|
|
||||||
angles.y = asin(-boneTransform[0][2]);
|
angles.y = asin(-boneTransform[0][2]);
|
||||||
if (cos(angles.y) != 0) {
|
if (cos(angles.y) != 0) {
|
||||||
angles.x = atan2(boneTransform[1][2], boneTransform[2][2]);
|
angles.x = atan2(boneTransform[1][2], boneTransform[2][2]);
|
||||||
@@ -56,7 +59,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
} else {
|
} else {
|
||||||
angles.x = atan2(-boneTransform[2][0], boneTransform[1][1]);
|
angles.x = atan2(-boneTransform[2][0], boneTransform[1][1]);
|
||||||
angles.z = 0;
|
angles.z = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ((bool)entity["BoneAttachment"]["InheritPosition"]) {
|
if ((bool)entity["BoneAttachment"]["InheritPosition"]) {
|
||||||
(glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"];
|
(glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"];
|
||||||
|
|||||||
@@ -328,11 +328,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
//bind textures
|
//bind textures
|
||||||
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
frameBones = explosionEffectJob->Skeleton->GetBones();
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
} else {
|
} else {
|
||||||
m_ExplosionEffectProgram->Bind();
|
m_ExplosionEffectProgram->Bind();
|
||||||
@@ -355,11 +351,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob);
|
BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob);
|
||||||
GLERROR("asdasd");
|
GLERROR("asdasd");
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
frameBones = explosionEffectJob->Skeleton->GetBones();
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -400,11 +392,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
//bind textures
|
//bind textures
|
||||||
BindModelTextures(forwardSkinnedHandle, modelJob);
|
BindModelTextures(forwardSkinnedHandle, modelJob);
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -428,11 +416,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindModelTextures(forwardSplatMapSkinnedHandle, modelJob);
|
BindModelTextures(forwardSplatMapSkinnedHandle, modelJob);
|
||||||
GLERROR("asdasd");
|
GLERROR("asdasd");
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -476,13 +460,8 @@ void DrawFinalPass::DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJo
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_ShieldToStencilProgram->Bind();
|
m_ShieldToStencilProgram->Bind();
|
||||||
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
|
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
|
||||||
@@ -535,11 +514,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
frameBones = explosionEffectJob->Skeleton->GetBones();
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
if (GLERROR("Animation")) {
|
if (GLERROR("Animation")) {
|
||||||
@@ -574,11 +549,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
|
|||||||
BindModelTextures(forwardHandle ,modelJob);
|
BindModelTextures(forwardHandle ,modelJob);
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
|
|
||||||
@@ -610,11 +581,7 @@ void DrawFinalPass::DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& job
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -103,11 +103,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -160,11 +156,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
} else {
|
} else {
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
@@ -215,11 +207,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -276,11 +264,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
frameBones = modelJob->Skeleton->GetBones();
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
|
||||||
} else {
|
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
|
|
||||||
}
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,14 +62,14 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only render children of a camera if that camera is currently active
|
// Only render children of a camera if that camera is currently active
|
||||||
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||||
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* model;
|
Model* model;
|
||||||
try {
|
try {
|
||||||
|
|||||||
+156
-247
@@ -29,6 +29,32 @@ Skeleton::~Skeleton()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Skeleton::CalculateFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion /*= false*/)
|
||||||
|
{
|
||||||
|
if (animations.size() <= 0 || animationOffset.animation == nullptr) {
|
||||||
|
for (auto& b : Bones) {
|
||||||
|
m_BoneLocalTransforms[b.first] = glm::mat4(1);
|
||||||
|
m_BoneTransforms[b.first] = glm::mat4(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AccumulateBoneTransforms(noRootMotion, animations, animationOffset, RootBone, glm::mat4(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Skeleton::CalculateFrameBones(std::vector<AnimationData> animations, bool noRootMotion /*= false*/)
|
||||||
|
{
|
||||||
|
if (animations.size() <= 0) {
|
||||||
|
for (auto& b : Bones) {
|
||||||
|
m_BoneLocalTransforms[b.first] = glm::mat4(1);
|
||||||
|
m_BoneTransforms[b.first] = glm::mat4(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AccumulateBoneTransforms(noRootMotion, animations, RootBone, glm::mat4(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Skeleton::Animation* Skeleton::GetAnimation(std::string name)
|
const Skeleton::Animation* Skeleton::GetAnimation(std::string name)
|
||||||
{
|
{
|
||||||
auto it = Animations.find(name);
|
auto it = Animations.find(name);
|
||||||
@@ -39,252 +65,10 @@ const Skeleton::Animation* Skeleton::GetAnimation(std::string name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<glm::mat4> Skeleton::GetFrameBones(std::vector<AnimationData> animations, bool noRootMotion /*= false*/)
|
void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, const Bone* bone, glm::mat4 parentMatrix)
|
||||||
{
|
|
||||||
if (animations.size() <= 0) {
|
|
||||||
std::vector<glm::mat4> finalMatrices;
|
|
||||||
for (auto& b : Bones) {
|
|
||||||
finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix);
|
|
||||||
}
|
|
||||||
return finalMatrices;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<int, glm::mat4> frameBones;
|
|
||||||
AccumulateBoneTransforms(true, animations, frameBones, RootBone, glm::mat4(1));
|
|
||||||
|
|
||||||
std::vector<glm::mat4> finalMatrices;
|
|
||||||
for (auto &kv : frameBones) {
|
|
||||||
finalMatrices.push_back(kv.second);
|
|
||||||
}
|
|
||||||
return finalMatrices;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<glm::mat4> Skeleton::GetFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion /*= false*/)
|
|
||||||
{
|
|
||||||
if (animations.size() <= 0 || animationOffset.animation == nullptr) {
|
|
||||||
std::vector<glm::mat4> finalMatrices;
|
|
||||||
for (auto& b : Bones) {
|
|
||||||
finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix);
|
|
||||||
}
|
|
||||||
return finalMatrices;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::map<int, glm::mat4> frameBones;
|
|
||||||
AccumulateBoneTransforms(true, animations, animationOffset, frameBones, RootBone, glm::mat4(1));
|
|
||||||
|
|
||||||
std::vector<glm::mat4> finalMatrices;
|
|
||||||
for (auto &kv : frameBones) {
|
|
||||||
finalMatrices.push_back(kv.second);
|
|
||||||
}
|
|
||||||
return finalMatrices;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
|
|
||||||
void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, float time, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix)
|
|
||||||
{
|
{
|
||||||
glm::mat4 boneMatrix;
|
glm::mat4 boneMatrix;
|
||||||
|
|
||||||
Animation::Keyframe currentFrame;
|
|
||||||
Animation::Keyframe nextFrame;
|
|
||||||
|
|
||||||
if(animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
|
||||||
std::vector<Animation::Keyframe> boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
|
||||||
|
|
||||||
if(boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
|
||||||
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
|
||||||
if (time >= boneKeyFrames.at(index).Time) {
|
|
||||||
currentFrame = boneKeyFrames.at(index);
|
|
||||||
nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float progress;
|
|
||||||
|
|
||||||
if(nextFrame.Index == 0) {
|
|
||||||
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
|
||||||
} else {
|
|
||||||
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (progress > 1.0f || progress < 0.0f) {
|
|
||||||
LOG_INFO("Progress: %f", progress);
|
|
||||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
|
||||||
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
|
|
||||||
|
|
||||||
glm::vec3 positionInterp = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
|
||||||
glm::quat rotationInterp = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress);
|
|
||||||
glm::vec3 scaleInterp = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress;
|
|
||||||
|
|
||||||
// Flag for no root motion
|
|
||||||
if (bone == RootBone && noRootMotion) {
|
|
||||||
positionInterp.x = 0;
|
|
||||||
positionInterp.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
boneMatrix = parentMatrix *(glm::translate(positionInterp) * glm::toMat4(rotationInterp) * glm::scale(scaleInterp));
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
|
|
||||||
} else { // 1 keyframes for the current bone
|
|
||||||
currentFrame = boneKeyFrames.at(0);
|
|
||||||
boneMatrix = parentMatrix *(glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale));
|
|
||||||
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
}
|
|
||||||
} else { // 0 keyframes for the current bone
|
|
||||||
|
|
||||||
// LOG_INFO("%s Has no keyframe", bone->Name.c_str());
|
|
||||||
if (bone->Parent) {
|
|
||||||
boneMatrix = parentMatrix * glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix;
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
} else {
|
|
||||||
boneMatrix = glm::inverse(bone->OffsetMatrix);
|
|
||||||
boneMatrices[bone->ID] = parentMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &child : bone->Children) {
|
|
||||||
AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, child, boneMatrix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix)
|
|
||||||
{
|
|
||||||
glm::mat4 boneMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<JointFrameTransform> JointTransforms;
|
|
||||||
|
|
||||||
for (const AnimationData animationData : animations) {
|
|
||||||
const Animation* animation = animationData.animation;
|
|
||||||
const float time = animationData.time;
|
|
||||||
|
|
||||||
JointFrameTransform jointTransform;
|
|
||||||
jointTransform.Weight = animationData.weight;;
|
|
||||||
|
|
||||||
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
|
||||||
std::vector<Animation::Keyframe> boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
|
||||||
|
|
||||||
Animation::Keyframe currentFrame;
|
|
||||||
Animation::Keyframe nextFrame;
|
|
||||||
|
|
||||||
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
|
||||||
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
|
||||||
if (time >= boneKeyFrames.at(index).Time) {
|
|
||||||
currentFrame = boneKeyFrames.at(index);
|
|
||||||
nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float progress;
|
|
||||||
|
|
||||||
if (nextFrame.Index == 0) {
|
|
||||||
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
|
||||||
} else {
|
|
||||||
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (progress > 1.0f || progress < 0.0f) {
|
|
||||||
LOG_INFO("Progress: %f", progress);
|
|
||||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
|
||||||
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
|
|
||||||
|
|
||||||
jointTransform.PositionInterp = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
|
||||||
jointTransform.RotationInterp = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress);
|
|
||||||
jointTransform.ScaleInterp = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress;
|
|
||||||
|
|
||||||
// Flag for no root motion
|
|
||||||
if (bone == RootBone && noRootMotion) {
|
|
||||||
jointTransform.PositionInterp.x = 0;
|
|
||||||
jointTransform.PositionInterp.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
JointTransforms.push_back(jointTransform);
|
|
||||||
|
|
||||||
} else { // 1 keyframes for the current bone
|
|
||||||
currentFrame = boneKeyFrames.at(0);
|
|
||||||
jointTransform.PositionInterp = currentFrame.BoneProperties.Position;
|
|
||||||
jointTransform.RotationInterp = currentFrame.BoneProperties.Rotation;
|
|
||||||
jointTransform.ScaleInterp = currentFrame.BoneProperties.Scale;
|
|
||||||
JointTransforms.push_back(jointTransform);
|
|
||||||
|
|
||||||
}
|
|
||||||
} else { // 0 keyframes for the current bone
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(JointTransforms.size() <= 0) {
|
|
||||||
if (bone->Parent) {
|
|
||||||
boneMatrix = parentMatrix * glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix;
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
} else {
|
|
||||||
boneMatrix = glm::inverse(bone->OffsetMatrix);
|
|
||||||
boneMatrices[bone->ID] = parentMatrix;
|
|
||||||
}
|
|
||||||
} else if (JointTransforms.size() == 1) {
|
|
||||||
boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp));
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
glm::vec3 finalPosInterp;
|
|
||||||
glm::quat finalRotInterp;
|
|
||||||
glm::vec3 finalScaleInterp;
|
|
||||||
float totalWeight = 0;
|
|
||||||
|
|
||||||
for (JointFrameTransform jointTransform : JointTransforms) {
|
|
||||||
totalWeight += jointTransform.Weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (JointFrameTransform jointTransform : JointTransforms)
|
|
||||||
{
|
|
||||||
if(jointTransform.Weight == 1.0f) {
|
|
||||||
finalPosInterp = jointTransform.PositionInterp;
|
|
||||||
finalRotInterp = jointTransform.RotationInterp;
|
|
||||||
finalScaleInterp = jointTransform.ScaleInterp;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
finalPosInterp += jointTransform.PositionInterp * (jointTransform.Weight/totalWeight);
|
|
||||||
finalRotInterp *= glm::slerp(glm::quat(), jointTransform.RotationInterp, (jointTransform.Weight/totalWeight));
|
|
||||||
finalScaleInterp += jointTransform.ScaleInterp * (jointTransform.Weight/totalWeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
boneMatrix = parentMatrix *(glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp));
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (auto &child : bone->Children) {
|
|
||||||
AccumulateBoneTransforms(noRootMotion, animations, boneMatrices, child, boneMatrix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix)
|
|
||||||
{
|
|
||||||
glm::mat4 boneMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<JointFrameTransform> JointTransforms;
|
std::vector<JointFrameTransform> JointTransforms;
|
||||||
|
|
||||||
for (const AnimationData animationData : animations) {
|
for (const AnimationData animationData : animations) {
|
||||||
@@ -363,10 +147,12 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
|||||||
boneMatrix = parentMatrix *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix));
|
boneMatrix = parentMatrix *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix));
|
||||||
|
|
||||||
}
|
}
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
m_BoneLocalTransforms[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
} else {
|
} else {
|
||||||
boneMatrix = offset * glm::inverse(bone->OffsetMatrix);
|
boneMatrix = offset * glm::inverse(bone->OffsetMatrix);
|
||||||
boneMatrices[bone->ID] = parentMatrix;
|
m_BoneLocalTransforms[bone->ID] = parentMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -402,14 +188,137 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
|||||||
boneMatrix = parentMatrix * (glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp));
|
boneMatrix = parentMatrix * (glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp));
|
||||||
}
|
}
|
||||||
|
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
m_BoneLocalTransforms[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &child : bone->Children) {
|
for (auto &child : bone->Children) {
|
||||||
AccumulateBoneTransforms(noRootMotion, animations, animationOffset, boneMatrices, child, boneMatrix);
|
AccumulateBoneTransforms(noRootMotion, animations, animationOffset, child, boneMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, const Bone* bone, glm::mat4 parentMatrix)
|
||||||
|
{
|
||||||
|
glm::mat4 boneMatrix;
|
||||||
|
std::vector<JointFrameTransform> JointTransforms;
|
||||||
|
|
||||||
|
for (const AnimationData animationData : animations) {
|
||||||
|
const Animation* animation = animationData.animation;
|
||||||
|
const float time = animationData.time;
|
||||||
|
|
||||||
|
JointFrameTransform jointTransform;
|
||||||
|
jointTransform.Weight = animationData.weight;;
|
||||||
|
|
||||||
|
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
||||||
|
std::vector<Animation::Keyframe> boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
||||||
|
|
||||||
|
Animation::Keyframe currentFrame;
|
||||||
|
Animation::Keyframe nextFrame;
|
||||||
|
|
||||||
|
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
||||||
|
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
||||||
|
if (time >= boneKeyFrames.at(index).Time) {
|
||||||
|
currentFrame = boneKeyFrames.at(index);
|
||||||
|
nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float progress;
|
||||||
|
|
||||||
|
if (nextFrame.Index == 0) {
|
||||||
|
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
||||||
|
} else {
|
||||||
|
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (progress > 1.0f || progress < 0.0f) {
|
||||||
|
LOG_INFO("Progress: %f", progress);
|
||||||
|
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
||||||
|
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
|
||||||
|
|
||||||
|
jointTransform.PositionInterp = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
||||||
|
jointTransform.RotationInterp = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress);
|
||||||
|
jointTransform.ScaleInterp = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress;
|
||||||
|
|
||||||
|
// Flag for no root motion
|
||||||
|
if (bone == RootBone && noRootMotion) {
|
||||||
|
jointTransform.PositionInterp.x = 0;
|
||||||
|
jointTransform.PositionInterp.z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JointTransforms.push_back(jointTransform);
|
||||||
|
|
||||||
|
} else { // 1 keyframes for the current bone
|
||||||
|
currentFrame = boneKeyFrames.at(0);
|
||||||
|
jointTransform.PositionInterp = currentFrame.BoneProperties.Position;
|
||||||
|
jointTransform.RotationInterp = currentFrame.BoneProperties.Rotation;
|
||||||
|
jointTransform.ScaleInterp = currentFrame.BoneProperties.Scale;
|
||||||
|
JointTransforms.push_back(jointTransform);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else { // 0 keyframes for the current bone
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JointTransforms.size() <= 0) {
|
||||||
|
if (bone->Parent) {
|
||||||
|
boneMatrix = parentMatrix * glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix;
|
||||||
|
m_BoneLocalTransforms[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
|
} else {
|
||||||
|
boneMatrix = glm::inverse(bone->OffsetMatrix);
|
||||||
|
m_BoneLocalTransforms[bone->ID] = parentMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
|
}
|
||||||
|
} else if (JointTransforms.size() == 1) {
|
||||||
|
boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp));
|
||||||
|
m_BoneLocalTransforms[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
glm::vec3 finalPosInterp;
|
||||||
|
glm::quat finalRotInterp;
|
||||||
|
glm::vec3 finalScaleInterp;
|
||||||
|
float totalWeight = 0;
|
||||||
|
|
||||||
|
for (JointFrameTransform jointTransform : JointTransforms) {
|
||||||
|
totalWeight += jointTransform.Weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (JointFrameTransform jointTransform : JointTransforms) {
|
||||||
|
if (jointTransform.Weight == 1.0f) {
|
||||||
|
finalPosInterp = jointTransform.PositionInterp;
|
||||||
|
finalRotInterp = jointTransform.RotationInterp;
|
||||||
|
finalScaleInterp = jointTransform.ScaleInterp;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
finalPosInterp += jointTransform.PositionInterp * (jointTransform.Weight/totalWeight);
|
||||||
|
finalRotInterp *= glm::slerp(glm::quat(), jointTransform.RotationInterp, (jointTransform.Weight/totalWeight));
|
||||||
|
finalScaleInterp += jointTransform.ScaleInterp * (jointTransform.Weight/totalWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
boneMatrix = parentMatrix *(glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp));
|
||||||
|
|
||||||
|
m_BoneLocalTransforms[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
|
m_BoneTransforms[bone->ID] = boneMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (auto &child : bone->Children) {
|
||||||
|
AccumulateBoneTransforms(noRootMotion, animations, child, boneMatrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset)
|
glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user