Crude animations

This commit is contained in:
2016-01-24 23:44:29 +01:00
parent d6cc1eaac4
commit 04f6233d99
4 changed files with 41 additions and 12 deletions
+1 -1
Submodule assets updated: 5f3ab8b35d...7577819337
+1 -1
View File
@@ -198,7 +198,7 @@
</Team> </Team>
</c:Team> </c:Team>
<c:Transform> <c:Transform>
<Position X="-0.246963501" Y="0.0264999866" Z="3.01600003"/> <Position X="-1.68112314" Y="0.0264999866" Z="3.06287026"/>
<Orientation X="0" Y="2.14675093" Z="0"/> <Orientation X="0" Y="2.14675093" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
+8 -7
View File
@@ -7,7 +7,6 @@
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
</c:AABB> </c:AABB>
<c:Collidable/> <c:Collidable/>
<c:Model/>
<c:Physics/> <c:Physics/>
<c:Player> <c:Player>
<MovementSpeed>5</MovementSpeed> <MovementSpeed>5</MovementSpeed>
@@ -18,8 +17,7 @@
</Team> </Team>
</c:Team> </c:Team>
<c:Transform> <c:Transform>
<Position X="-0.246963501" Y="0.0265000071" Z="3.01600003"/> <Position X="-0.246963501" Y="0.0264999941" Z="3.01600003"/>
<Orientation X="0" Y="2.14675093" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
@@ -51,6 +49,7 @@
<Components> <Components>
<c:Model> <c:Model>
<Resource>Models/Camera.mesh</Resource> <Resource>Models/Camera.mesh</Resource>
<Visible>false</Visible>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="0" Y="0.0331346765" Z="-0.0792061687"/> <Position X="0" Y="0.0331346765" Z="-0.0792061687"/>
@@ -77,13 +76,15 @@
</Entity> </Entity>
<Entity name="PlayerModel"> <Entity name="PlayerModel">
<Components> <Components>
<c:Animation>
<Name>Hold Pos</Name>
<Speed>1</Speed>
</c:Animation>
<c:Model> <c:Model>
<Resource>Models/AssaultHeadless.mesh</Resource> <Resource>Models/AssaultAnimated.mesh</Resource>
<Color A="1" B="0" G="0" R="1"/> <Color A="1" B="0" G="0" R="1"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform/>
<Orientation X="0" Y="3.14159274" Z="0"/>
</c:Transform>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
+31 -3
View File
@@ -36,15 +36,18 @@ void PlayerMovementSystem::Update(double dt)
glm::vec3& ori = cTransform["Orientation"]; glm::vec3& ori = cTransform["Orientation"];
ori.y += controller->Rotation().y; ori.y += controller->Rotation().y;
float playerMovementSpeed = player["Player"]["MovementSpeed"];
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
if (player.HasComponent("Physics")) { if (player.HasComponent("Physics")) {
ComponentWrapper cPhysics = player["Physics"]; ComponentWrapper cPhysics = player["Physics"];
glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
float wishSpeed; float wishSpeed;
if (controller->Crouching()) { if (controller->Crouching()) {
wishSpeed = player["Player"]["CrouchSpeed"]; wishSpeed = playerCrouchSpeed;
} else { } else {
wishSpeed = player["Player"]["MovementSpeed"]; wishSpeed = playerMovementSpeed;
} }
glm::vec3& velocity = cPhysics["Velocity"]; glm::vec3& velocity = cPhysics["Velocity"];
ImGui::Text("velocity: (%f, %f, %f)", velocity.x, velocity.y, velocity.z); ImGui::Text("velocity: (%f, %f, %f)", velocity.x, velocity.y, velocity.z);
@@ -85,8 +88,33 @@ void PlayerMovementSystem::Update(double dt)
// size = glm::vec3(1.f, 1.6f, 1.f); // size = glm::vec3(1.f, 1.6f, 1.f);
// } // }
//} //}
// Animations
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
ComponentWrapper cAnimation = playerModel["Animation"];
float movementLength = glm::length(groundVelocity);
if (glm::length(controller->Movement()) > 0.f) {
if (controller->Crouching()) {
cAnimation["Name"] = "Crouch Walk";
(double&)cAnimation["Speed"] = 1.f * -glm::sign(controller->Movement().z);
} else {
cAnimation["Name"] = "Run";
(double&)cAnimation["Speed"] = 2.f * -glm::sign(controller->Movement().z);
}
} else {
if (controller->Crouching()) {
cAnimation["Name"] = "Crouch";
(double&)cAnimation["Speed"] = 1.f;
} else {
cAnimation["Name"] = "Hold Pos";
(double&)cAnimation["Speed"] = 1.f;
}
}
}
} }
controller->Reset(); controller->Reset();
} }
} }