Model that has animations is now visible when it does not play an animation (T-pose)
This commit is contained in:
@@ -83,7 +83,7 @@ public:
|
||||
int GetBoneID(std::string name);
|
||||
|
||||
const Animation* GetAnimation(std::string name);
|
||||
std::vector<glm::mat4> GetFrameBones(const Animation& animation, double time, bool noRootMotion = false);
|
||||
std::vector<glm::mat4> GetFrameBones(const Animation* animation, double time, bool noRootMotion = false);
|
||||
void AccumulateBoneTransforms(bool noRootMotion, const Animation::Keyframe& currentFrame, const Animation::Keyframe& nextFrame, float progress, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
|
||||
void PrintSkeleton();
|
||||
void PrintSkeleton(const Bone* parent, int depthCount);
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<Axis X="0" Y="5" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="117.03714" Y="3023.50244" Z="3.03297734"/>
|
||||
<Orientation X="117.03714" Y="3077.6958" Z="3.03297734"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -154,7 +154,7 @@
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="-0.100000001" Z="0"/>
|
||||
<Orientation X="0" Y="191.457993" Z="0"/>
|
||||
<Orientation X="0" Y="209.88414" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
<Resource>Models/Core/UnitPlane.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-1.79600012" Y="0.200000003" Z="-5.20000029"/>
|
||||
<Scale X="10" Y="10" Z="10"/>
|
||||
<Position X="-1.79600012" Y="-2.11031318" Z="-5.20000029"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -34,16 +33,15 @@
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName>Walk</AnimationName>
|
||||
<Time>0.56225092855229164</Time>
|
||||
<Speed>0.5</Speed>
|
||||
<AnimationName>Run</AnimationName>
|
||||
<Time>0.60863376686742265</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.219988048"/>
|
||||
<Orientation X="0" Y="1.95300007" Z="0"/>
|
||||
<Position X="0.200000003" Y="-1.245" Z="-2.08000016"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -84,34 +82,51 @@
|
||||
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.106393129" Y="0.164001703" Z="0.26629591"/>
|
||||
<Scale X="0.199999988" Y="0.200000003" Z="0.200000003"/>
|
||||
<Orientation X="-1.91579378" Y="0.00274402252" Z="-3.12450099"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Test">
|
||||
<Components>
|
||||
<c:BoneAttachment>
|
||||
<BoneName>R_Foot</BoneName>
|
||||
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||
<InheritScale>true</InheritScale>
|
||||
</c:BoneAttachment>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="1" B="1" G="1" R="19.6078434"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.0958700925" Y="0.0355969071" Z="-0.102683716"/>
|
||||
<Scale X="0.199999988" Y="0.200000033" Z="0.200000033"/>
|
||||
<Orientation X="0.00436601695" Y="0.262745619" Z="-3.10364795"/>
|
||||
<Position X="-0.0864263624" Y="0.210641265" Z="-0.0983783901"/>
|
||||
<Scale X="0.199999988" Y="0.200000033" Z="0.200000003"/>
|
||||
<Orientation X="-2.90010285" Y="0.0159484055" Z="-3.1345098"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName>Walk</AnimationName>
|
||||
<Time>0.66325497978402836</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="-1.245" Z="-1.05166435"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Test">
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName>Crouch Walk</AnimationName>
|
||||
<Time>0.6245290972212274</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:BoneAttachment>
|
||||
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||
</c:BoneAttachment>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="1" G="1" R="19.6078434"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.0539491512" Y="-1.24511254" Z="0.0892278999"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
<Children>
|
||||
<Entity name="Hexagon">
|
||||
<Components>
|
||||
<c:HealthHUD/>
|
||||
<c:Fill>
|
||||
<Percentage>0.65990006923675537</Percentage>
|
||||
<Color A="0" B="0.659900069" G="0" R="0.340099931"/>
|
||||
</c:Fill>
|
||||
<c:HealthHUD/>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitHexagon.mesh</Resource>
|
||||
<Color A="0.313725501" B="0.70588237" G="0.70588237" R="0.70588237"/>
|
||||
@@ -161,7 +161,7 @@
|
||||
<Axis X="0.200000003" Y="3.4000001" Z="0.5"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="758.058899" Y="20632.8691" Z="1320.68018"/>
|
||||
<Orientation X="792.149475" Y="21212.4141" Z="1405.90698"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -308,7 +308,7 @@
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Assault.mesh</Resource>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="1" G="1" R="3.92156863"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
|
||||
@@ -88,11 +88,8 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
GLERROR("DrawFinalPass::ExplosionEffect: 2");
|
||||
|
||||
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (explosionEffectJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
|
||||
//TODO: Renderer: bättre textur felhantering samt fler texturer stöd
|
||||
@@ -157,10 +154,9 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
}*/
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
|
||||
@@ -91,7 +91,7 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,20 +39,29 @@ const Skeleton::Animation* Skeleton::GetAnimation(std::string name)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation& animation, double time, bool noRootMotion /*= false*/)
|
||||
std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation* animation, double time, bool noRootMotion /*= false*/)
|
||||
{
|
||||
if(animation == nullptr) {
|
||||
std::vector<glm::mat4> finalMatrices;
|
||||
for(auto& b : Bones) {
|
||||
finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix);
|
||||
}
|
||||
return finalMatrices;
|
||||
}
|
||||
|
||||
|
||||
// HACK: Animation wrap-around
|
||||
while (time < 0) {
|
||||
time += animation.Duration;
|
||||
time += animation->Duration;
|
||||
}
|
||||
while (time > animation.Duration) {
|
||||
time -= animation.Duration;
|
||||
while (time > animation->Duration) {
|
||||
time -= animation->Duration;
|
||||
}
|
||||
|
||||
int currentKeyframeIndex = GetKeyframe(animation, time);
|
||||
int currentKeyframeIndex = GetKeyframe(*animation, time);
|
||||
|
||||
const Animation::Keyframe& currentFrame = animation.Keyframes[currentKeyframeIndex];
|
||||
const Animation::Keyframe& nextFrame = animation.Keyframes[(currentKeyframeIndex + 1) % animation.Keyframes.size()];
|
||||
const Animation::Keyframe& currentFrame = animation->Keyframes[currentKeyframeIndex];
|
||||
const Animation::Keyframe& nextFrame = animation->Keyframes[(currentKeyframeIndex + 1) % animation->Keyframes.size()];
|
||||
float alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
||||
|
||||
//auto animationFrame = Animations[""].Keyframes[frame];
|
||||
|
||||
Reference in New Issue
Block a user