Changed Animation and BoneAttachment "Name" field to "AnimationName" and "BoneName"
This commit is contained in:
@@ -46,7 +46,7 @@ struct ModelJob : RenderJob
|
|||||||
|
|
||||||
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
|
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
|
||||||
auto animationComponent = world->GetComponent(Entity, "Animation");
|
auto animationComponent = world->GetComponent(Entity, "Animation");
|
||||||
Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["Name"]);
|
Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName"]);
|
||||||
AnimationTime = (double)animationComponent["Time"];
|
AnimationTime = (double)animationComponent["Time"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Animation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Animation.xsd">
|
<Animation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Animation.xsd">
|
||||||
<Name></Name>
|
<AnimationName></AnimationName>
|
||||||
<Time>0</Time>
|
<Time>0</Time>
|
||||||
<Speed>0</Speed>
|
<Speed>0</Speed>
|
||||||
<Loop>true</Loop>
|
<Loop>true</Loop>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<xs:element name="Animation">
|
<xs:element name="Animation">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Name" type="t:string" minOccurs="0"/>
|
<xs:element name="AnimationName" type="t:string" minOccurs="0"/>
|
||||||
<xs:element name="Time" type="t:double" minOccurs="0"/>
|
<xs:element name="Time" type="t:double" minOccurs="0"/>
|
||||||
<xs:element name="Speed" type="t:double" minOccurs="0"/>
|
<xs:element name="Speed" type="t:double" minOccurs="0"/>
|
||||||
<xs:element name="Loop" type="t:bool" minOccurs="0"/>
|
<xs:element name="Loop" type="t:bool" minOccurs="0"/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<BoneAttachment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoneAttachment.xsd">
|
<BoneAttachment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoneAttachment.xsd">
|
||||||
<Name></Name>
|
<BoneName></BoneName>
|
||||||
<PositionOffset X="0" Y="0" Z="0"/>
|
<PositionOffset X="0" Y="0" Z="0"/>
|
||||||
<OrientationOffset X="0" Y="0" Z="0"/>
|
<OrientationOffset X="0" Y="0" Z="0"/>
|
||||||
<ScaleOffset X="1" Y="1" Z="1"/>
|
<ScaleOffset X="1" Y="1" Z="1"/>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<xs:element name="BoneAttachment">
|
<xs:element name="BoneAttachment">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Name" type="t:string" minOccurs="0"/>
|
<xs:element name="BoneName" type="t:string" minOccurs="0"/>
|
||||||
<xs:element name="PositionOffset" type="t:Vector" minOccurs="0"/>
|
<xs:element name="PositionOffset" type="t:Vector" minOccurs="0"/>
|
||||||
<xs:element name="InheritPosition" type="t:bool" minOccurs="0"/>
|
<xs:element name="InheritPosition" type="t:bool" minOccurs="0"/>
|
||||||
<xs:element name="OrientationOffset" type="t:Vector" minOccurs="0"/>
|
<xs:element name="OrientationOffset" type="t:Vector" minOccurs="0"/>
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
<Entity>
|
<Entity>
|
||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Run</Name>
|
<AnimationName>Walk</AnimationName>
|
||||||
<Time>0.45698878438365576</Time>
|
<Time>0.56225092855229164</Time>
|
||||||
<Speed>0.5</Speed>
|
<Speed>0.5</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -75,8 +75,8 @@
|
|||||||
<Entity name="Test">
|
<Entity name="Test">
|
||||||
<Components>
|
<Components>
|
||||||
<c:BoneAttachment>
|
<c:BoneAttachment>
|
||||||
|
<BoneName>L_Foot</BoneName>
|
||||||
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
<Name>L_Foot</Name>
|
|
||||||
<InheritScale>true</InheritScale>
|
<InheritScale>true</InheritScale>
|
||||||
</c:BoneAttachment>
|
</c:BoneAttachment>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -84,9 +84,9 @@
|
|||||||
<Color A="1" B="1" G="19.6078434" R="1"/>
|
<Color A="1" B="1" G="19.6078434" R="1"/>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-0.0864050835" Y="0.271049351" Z="0.442295641"/>
|
<Position X="-0.106393129" Y="0.164001703" Z="0.26629591"/>
|
||||||
<Scale X="0.200000003" Y="0.199999988" Z="0.200000033"/>
|
<Scale X="0.199999988" Y="0.200000003" Z="0.200000003"/>
|
||||||
<Orientation X="-1.9622153" Y="0.00355640799" Z="-3.12462544"/>
|
<Orientation X="-1.91579378" Y="0.00274402252" Z="-3.12450099"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
@@ -94,8 +94,8 @@
|
|||||||
<Entity name="Test">
|
<Entity name="Test">
|
||||||
<Components>
|
<Components>
|
||||||
<c:BoneAttachment>
|
<c:BoneAttachment>
|
||||||
|
<BoneName>R_Foot</BoneName>
|
||||||
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
<ScaleOffset X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||||
<Name>R_Foot</Name>
|
|
||||||
<InheritScale>true</InheritScale>
|
<InheritScale>true</InheritScale>
|
||||||
</c:BoneAttachment>
|
</c:BoneAttachment>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -103,9 +103,9 @@
|
|||||||
<Color A="1" B="1" G="1" R="19.6078434"/>
|
<Color A="1" B="1" G="1" R="19.6078434"/>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.120880835" Y="0.045114398" Z="-0.153178662"/>
|
<Position X="0.0958700925" Y="0.0355969071" Z="-0.102683716"/>
|
||||||
<Scale X="0.200000003" Y="0.200000077" Z="0.200000077"/>
|
<Scale X="0.199999988" Y="0.200000033" Z="0.200000033"/>
|
||||||
<Orientation X="-0.176647186" Y="0.236876175" Z="-3.10332251"/>
|
<Orientation X="0.00436601695" Y="0.262745619" Z="-3.10364795"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
|
|||||||
|
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["Name"]);
|
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]);
|
||||||
|
|
||||||
if(animation != nullptr) {
|
if(animation != nullptr) {
|
||||||
double animationSpeed = (double)animationComponent["Speed"];
|
double animationSpeed = (double)animationComponent["Speed"];
|
||||||
@@ -29,7 +29,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
|
|||||||
(double&)animationComponent["Speed"] = 0.0;
|
(double&)animationComponent["Speed"] = 0.0;
|
||||||
Events::AnimationComplete e;
|
Events::AnimationComplete e;
|
||||||
e.Entity = entity;
|
e.Entity = entity;
|
||||||
e.Name = (std::string)animationComponent["Name"];
|
e.Name = (std::string)animationComponent["AnimationName"];
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
} else {
|
} else {
|
||||||
if (glm::abs(nextTime) > animation->Duration) {
|
if (glm::abs(nextTime) > animation->Duration) {
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
|
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
const Skeleton::Animation* animation = skeleton->GetAnimation(parent["Animation"]["Name"]);
|
const Skeleton::Animation* animation = skeleton->GetAnimation(parent["Animation"]["AnimationName"]);
|
||||||
|
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = skeleton->GetBoneID(entity["BoneAttachment"]["Name"]);
|
int id = skeleton->GetBoneID(entity["BoneAttachment"]["BoneName"]);
|
||||||
|
|
||||||
if(id == -1) {
|
if(id == -1) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -156,17 +156,9 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//TODO: Fixa så att modelsJobs kan spela upp olika animationer och så att den kan få in en tid istället för 1.0f - Hälsningar Johan och Andreas :)
|
|
||||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
if (modelJob->Animation != 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);
|
||||||
// std::vector<glm::mat4> frameBones2 = modelJob->Skeleton->GetFrameBones(*modelJob->Skeleton->GetAnimation("Walk"), modelJob->AnimationTime);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < frameBones.size(); i++) {
|
|
||||||
// frameBones[i] = frameBones[i] * glm::mat4(glm::quat(glm::vec3(0.f, 0.f, 0.f)));//* frameBones2[i];
|
|
||||||
// }
|
|
||||||
|
|
||||||
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]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user