Animations kind of working

This commit is contained in:
viktorljung
2016-02-06 18:09:51 +01:00
parent b6e0332574
commit 933a32aa8d
8 changed files with 224 additions and 100 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ public:
void PrintSkeleton(const Bone* parent, int depthCount);
std::map<std::string, Animation> Animations;
glm::mat4 GetBoneTransform(const Bone* bone, const Animation::Keyframe& currentFrame, const Animation::Keyframe& nextFrame, float progress, glm::mat4 parentMatrix);
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 parentMatrix);
int GetKeyframe(const Animation& animation, double time);
private:
+57 -55
View File
@@ -13,7 +13,6 @@
<Color A="1" B="0.392156869" G="0.392156869" R="0.392156869"/>
</c:Model>
<c:Transform>
<Position X="0" Y="-1.245" Z="0"/>
<Scale X="10" Y="10" Z="10"/>
</c:Transform>
</Components>
@@ -32,39 +31,21 @@
</Components>
<Children/>
</Entity>
<Entity>
<Entity name="Wave">
<Components>
<c:Animation>
<AnimationName>Run</AnimationName>
<Time>0.71089640059930681</Time>
<Speed>1</Speed>
<AnimationName>Wave</AnimationName>
<Time>0.12880232983358791</Time>
<Speed>0.099999986588954926</Speed>
</c:Animation>
<c:Model>
<Resource>Models/Asstest.mesh</Resource>
<Resource>Models/finaltest.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="-1.245" Z="0"/>
<Position X="-0.690088332" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<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.0670756698" Y="0.7053985" Z="0.0367298797"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-0.539481044" Y="-0.0316002518" Z="-2.95271134"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="R_Leg_Bottom">
<Components>
<c:BoneAttachment>
@@ -76,9 +57,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="0.148491099" Y="0.406787694" Z="-0.159706444"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="1.192891" Y="0.187030882" Z="-2.87608051"/>
</c:Transform>
</Components>
<Children/>
@@ -94,9 +74,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="0.147671953" Y="0.288556606" Z="0.187201411"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="1.19914544" Y="0.0853852332" Z="-3.1367836"/>
</c:Transform>
</Components>
<Children/>
@@ -112,9 +91,8 @@
<Color A="1" B="1" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="-0.0861762166" Y="0.035969615" Z="-0.0733369738"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-3.14159179" Y="1.56462193e-05" Z="-3.1415894"/>
</c:Transform>
</Components>
<Children/>
@@ -130,9 +108,8 @@
<Color A="1" B="1" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="-0.0949281976" Y="0.38283509" Z="-0.191370964"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-2.88567233" Y="-0.208285078" Z="-3.09033155"/>
</c:Transform>
</Components>
<Children/>
@@ -148,9 +125,8 @@
<Color A="1" B="1" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="-0.0714211613" Y="0.697834671" Z="-0.00534122996"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="2.61832142" Y="-0.111381792" Z="-3.05362916"/>
</c:Transform>
</Components>
<Children/>
@@ -166,9 +142,8 @@
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="-9.4325589e-18" Y="0.738307238" Z="0.00194504182"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-3.03686881" Y="0.365960717" Z="-3.07918954"/>
</c:Transform>
</Components>
<Children/>
@@ -184,9 +159,8 @@
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="-0.00329666352" Y="0.871166348" Z="-0.0110896118"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
<Orientation X="-2.58382678" Y="1.22235525" Z="-2.69361424"/>
</c:Transform>
</Components>
<Children/>
@@ -202,9 +176,8 @@
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="0.00619302923" Y="0.999758601" Z="-0.0344300792"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
<Orientation X="-2.29503679" Y="1.19778895" Z="-2.59355855"/>
</c:Transform>
</Components>
<Children/>
@@ -220,9 +193,8 @@
<Color A="1" B="1" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="0.00619302923" Y="0.999758601" Z="-0.0344300792"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
<Orientation X="-2.29503679" Y="1.19778895" Z="-2.59355855"/>
</c:Transform>
</Components>
<Children/>
@@ -238,9 +210,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="0.0217485577" Y="1.07277262" Z="-0.0545123592"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.0500000007" Y="0.100000001" Z="0.0500000007"/>
<Orientation X="-2.72223639" Y="0.035971649" Z="3.00587177"/>
</c:Transform>
</Components>
<Children/>
@@ -256,9 +227,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="0.00619302923" Y="0.999758601" Z="-0.0344300792"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.0500000007" Z="0.100000001"/>
<Orientation X="-2.29503679" Y="1.19778895" Z="-2.59355855"/>
</c:Transform>
</Components>
<Children/>
@@ -274,9 +244,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="0.0779105872" Y="0.97813803" Z="0.0216788556"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-0.504944384" Y="0.385777682" Z="-0.0470155627"/>
</c:Transform>
</Components>
<Children/>
@@ -292,9 +261,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="-0.145016268" Y="1.09721363" Z="0.0620321929"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-2.07472539" Y="-1.02085268" Z="1.20787954"/>
</c:Transform>
</Components>
<Children/>
@@ -310,9 +278,8 @@
<Color A="1" B="19.6078434" G="19.6078434" R="1"/>
</c:Model>
<c:Transform>
<Position X="-0.194418803" Y="0.990253985" Z="-0.0940467715"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="-0.332483619" Y="0.762842059" Z="0.00552804675"/>
</c:Transform>
</Components>
<Children/>
@@ -328,9 +295,44 @@
<Color A="1" B="19.6078434" G="19.6078434" R="19.6078434"/>
</c:Model>
<c:Transform>
<Position X="0.035807699" Y="1.15795505" Z="-0.12132182"/>
<Position X="0" Y="0.803468645" Z="0"/>
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
<Orientation X="-2.96464038" Y="0.0267533381" Z="2.98014784"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Derp">
<Components>
<c:Animation>
<AnimationName>Run</AnimationName>
<Time>0.086866227306570662</Time>
<Speed>0.099999986588954926</Speed>
</c:Animation>
<c:Model>
<Resource>Models/Supertest2.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.650099277" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="R_Leg_Top">
<Components>
<c:BoneAttachment>
<BoneName>R_Leg_Top</BoneName>
<PositionOffset X="-0.600000024" Y="0" Z="0"/>
<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.526000023" Y="0.85917443" Z="0.00200000009"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="0.0076949019" Y="0.0273150932" Z="0.00913804397"/>
</c:Transform>
</Components>
<Children/>
+16 -1
View File
@@ -60,6 +60,7 @@
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="0.313725501" B="0.70588237" G="0.70588237" R="0.70588237"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="-0.285538822" Y="-0.282350302" Z="-1.52214652e-05"/>
@@ -161,7 +162,7 @@
<Axis X="0.200000003" Y="3.4000001" Z="0.5"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="792.149475" Y="21212.4141" Z="1405.90698"/>
<Orientation X="948.868286" Y="23876.6914" Z="1797.71118"/>
</c:Transform>
</Components>
<Children>
@@ -346,6 +347,20 @@
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Animation>
<AnimationName>Run</AnimationName>
<Time>0.021910293579680166</Time>
<Speed>0.004999999888241291</Speed>
</c:Animation>
<c:Model>
<Resource>Models/SuperTest.mesh</Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+41
View File
@@ -0,0 +1,41 @@
#version 430
uniform vec4 Color;
uniform vec4 FillColor;
uniform float FillPercentage;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout (binding = 0) uniform sampler2D DiffuseTexture;
layout (binding = 1) uniform sampler2D GlowMapTexture;
in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
void main()
{
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
vec4 color_result = Color * diffuseTexel;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) {
color_result += FillColor;
}
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
color_result += glowTexel*3;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
}
+24
View File
@@ -0,0 +1,24 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 4) in vec2 TextureCoords;
out VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
}Output;
void main()
{
gl_Position = P * M * vec4(Position, 1.0);
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
Output.Normal = Normal;
}
+2
View File
@@ -19,6 +19,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
if(skeleton == nullptr) {
return;
}
/*
ImGui::SliderFloat("Angle", &angle, -100.f, 100.f);
{
@@ -28,6 +29,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
it->second->ModificationMatrix = glm::mat4(glm::quat(glm::vec3(glm::radians(angle), 0.f, 0.f)));
}
}
*/
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]);
@@ -2,7 +2,7 @@
void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& BoneAttachmentComponent, double dt)
{
/*
if(!entity.HasComponent("Transform")) {
return;
@@ -33,13 +33,8 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
return;
}
int currentKeyframeIndex = skeleton->GetKeyframe(*animation, parent["Animation"]["Time"]);
const Skeleton::Animation::Keyframe& currentFrame = animation->Keyframes[currentKeyframeIndex];
const Skeleton::Animation::Keyframe& nextFrame = animation->Keyframes[(currentKeyframeIndex + 1) % animation->Keyframes.size()];
float alpha = ((double)parent["Animation"]["Time"] - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
glm::mat4 boneTransform = skeleton->GetBoneTransform(skeleton->Bones[id], currentFrame, nextFrame, alpha, glm::mat4(1));
glm::mat4 boneTransform = skeleton->GetBoneTransform(skeleton->Bones[id], animation, (double)parent["Animation"]["Time"], glm::mat4(1));
@@ -68,5 +63,5 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
}
if ((bool)entity["BoneAttachment"]["InheritScale"]) {
(glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"];
}*/
}
}
+80 -35
View File
@@ -61,7 +61,7 @@ std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation* animation, doubl
//auto animationFrame = Animations[""].Keyframes[frame];
std::map<int, glm::mat4> frameBones;
AccumulateBoneTransforms(noRootMotion, animation, time, frameBones, RootBone, glm::mat4(1));
AccumulateBoneTransforms(true, animation, time, frameBones, RootBone, glm::mat4(1));
//AccumulateBoneTransforms(noRootMotion, currentFrame, nextFrame, alpha, frameBones, RootBone, glm::mat4(1));
std::vector<glm::mat4> finalMatrices;
@@ -71,21 +71,18 @@ std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation* animation, doubl
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(1);
glm::mat4 boneMatrix;
Animation::Keyframe currentFrame;
Animation::Keyframe nextFrame;
if(animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { // find the bone keyframes that surrounds the current frame
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--) {
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());
@@ -93,10 +90,18 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim
}
}
float progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); // fix loopinguuuu
float progress;
if(nextFrame.Index == 0) {
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
} else {
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); // fix loopinguuuu
}
if(progress > 1.0f || progress < 0.0f) {
LOG_INFO("Progress %f", progress);
progress = 0.f;
progress = glm::clamp(progress, 0.0f, 1.0f);
}
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
@@ -111,53 +116,93 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim
positionInterp.z = 0;
}
boneMatrix = parentMatrix * bone->ModificationMatrix * (glm::translate(positionInterp) * glm::toMat4(rotationInterp) * glm::scale(scaleInterp));
boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix;
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 * bone->ModificationMatrix *(glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale));
boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix;
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
boneMatrix = parentMatrix * bone->ModificationMatrix;
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
// 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) {
std::string name = child->Name;
AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, child, boneMatrix);
}
}
glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation::Keyframe& currentFrame, const Animation::Keyframe& nextFrame, float progress, glm::mat4 parentMatrix)
glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 parentMatrix)
{
/* glm::mat4 boneMatrix;
glm::mat4 boneMatrix;
if (currentFrame.BoneProperties.find(bone->ID) != currentFrame.BoneProperties.end() || nextFrame.BoneProperties.find(bone->ID) != nextFrame.BoneProperties.end()) {
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties.at(bone->ID);
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties.at(bone->ID);
Animation::Keyframe currentFrame;
Animation::Keyframe nextFrame;
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;
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); // fix loopinguuuu
}
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;
boneMatrix = parentMatrix * (glm::translate(positionInterp) * glm::toMat4(rotationInterp) * glm::scale(scaleInterp));
} 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));
boneMatrix = (glm::translate(positionInterp) * glm::toMat4(rotationInterp) * glm::scale(scaleInterp)) * bone->ModificationMatrix * parentMatrix;
} else {
if (bone->Parent) {
boneMatrix = parentMatrix;
}
} else { // 0 keyframes for the current bone
if (bone->Parent) {
boneMatrix = glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix * parentMatrix;
} else {
boneMatrix = parentMatrix * glm::inverse(bone->OffsetMatrix);
}
}
if(bone->Parent) {
return GetBoneTransform(bone->Parent, currentFrame, nextFrame, progress, boneMatrix);
if (bone->Parent) {
return GetBoneTransform(bone->Parent, animation, time, boneMatrix);
} else {
return boneMatrix;
}*/
return parentMatrix;
}
}
int Skeleton::GetBoneID(std::string name)