Third person animations and shoot effects base work
This commit is contained in:
@@ -66,8 +66,8 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
||||
}
|
||||
|
||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||
continue;
|
||||
if ((entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||
//continue;
|
||||
}
|
||||
|
||||
Model* model;
|
||||
|
||||
@@ -104,7 +104,6 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
||||
|
||||
|
||||
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;
|
||||
@@ -181,7 +180,6 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (offset != glm::mat4(1)) {
|
||||
boneMatrix = parentMatrix * ((glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)) + offset);
|
||||
} else {
|
||||
@@ -233,9 +231,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector<Animation
|
||||
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@@ -353,9 +349,7 @@ glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animati
|
||||
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
+1
-4
@@ -227,11 +227,8 @@ int Game::parseArgs(int argc, char* argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (vm.count("connect")) {
|
||||
m_IsClient = true;
|
||||
}
|
||||
|
||||
// HACK: Right now, client and server are mutually exclusive
|
||||
m_IsClient = true;
|
||||
if (m_IsServer) {
|
||||
m_IsClient = false;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp
|
||||
|
||||
bool MultiplayerSnapshotFilter::OnPlayerSpawned(Events::PlayerSpawned ePlayerSpawned)
|
||||
{
|
||||
m_LocalPlayer = ePlayerSpawned.Player;
|
||||
if (ePlayerSpawned.PlayerID == -1) {
|
||||
m_LocalPlayer = ePlayerSpawned.Player;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -29,12 +29,20 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Aim pitch
|
||||
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
|
||||
if (cameraEntity.Valid()) {
|
||||
glm::vec3& cameraOrientation = cameraEntity["Transform"]["Orientation"];
|
||||
cameraOrientation.x += controller->Rotation().x;
|
||||
// Limit camera pitch so we don't break our necks
|
||||
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi<float>(), glm::half_pi<float>());
|
||||
// Set third person model aim pitch
|
||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||
if (playerModel.Valid()) {
|
||||
ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"];
|
||||
double time = (cameraOrientation.x + glm::half_pi<float>()) / glm::pi<float>();
|
||||
cAnimationOffset["Time"] = time;
|
||||
}
|
||||
}
|
||||
|
||||
ComponentWrapper& cTransform = player["Transform"];
|
||||
@@ -124,24 +132,74 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||
if (playerModel.Valid()) {
|
||||
ComponentWrapper cAnimation = playerModel["Animation"];
|
||||
std::string& animationName1 = cAnimation["AnimationName1"];
|
||||
std::string& animationName2 = cAnimation["AnimationName2"];
|
||||
double& animationTime1 = cAnimation["Time1"];
|
||||
double& animationTime2 = cAnimation["Time2"];
|
||||
double& animationSpeed1 = cAnimation["Speed1"];
|
||||
double& animationSpeed2 = cAnimation["Speed2"];
|
||||
double& animationWeight1 = cAnimation["Weight1"];
|
||||
double& animationWeight2 = cAnimation["Weight2"];
|
||||
|
||||
float movementLength = glm::length(groundVelocity);
|
||||
//TODO: add assault dash animation here
|
||||
if (glm::length(controller->Movement()) > 0.f) {
|
||||
if (controller->Crouching()) {
|
||||
cAnimation["AnimationName1"] = "Crouch Walk";
|
||||
(double&)cAnimation["Speed1"] = 1.f * -glm::sign(controller->Movement().z);
|
||||
double forwardMovement = controller->Movement().z;
|
||||
double strafeMovement = controller->Movement().x;
|
||||
|
||||
if (controller->Crouching() && animationName1 != "CrouchWalk") {
|
||||
animationName1 = "CrouchWalk";
|
||||
animationSpeed1 = 1.0 * -glm::sign(controller->Movement().z);
|
||||
} else {
|
||||
cAnimation["AnimationName1"] = "Run";
|
||||
(double&)cAnimation["Speed1"] = 2.f * -glm::sign(controller->Movement().z);
|
||||
if (glm::abs(forwardMovement) > 0) {
|
||||
if (animationName1 != "Run") {
|
||||
animationName1 = "Run";
|
||||
if (animationName2 == "StrafeLeft" || animationName2 == "StrafeRight") {
|
||||
animationTime1 = animationTime2;
|
||||
} else {
|
||||
animationTime1 = 0.0;
|
||||
}
|
||||
}
|
||||
animationSpeed1 = 2.f * -glm::sign(forwardMovement);
|
||||
}
|
||||
|
||||
if (glm::abs(strafeMovement) > 0) {
|
||||
if (animationName2 != "StrafeLeft" && animationName2 != "StrafeRight") {
|
||||
if (strafeMovement < 0) {
|
||||
animationName2 = "StrafeLeft";
|
||||
}
|
||||
if (strafeMovement > 0) {
|
||||
animationName2 = "StrafeRight";
|
||||
}
|
||||
if (animationName1 == "Run") {
|
||||
animationTime2 = animationTime1;
|
||||
} else {
|
||||
animationTime2 = 0.0;
|
||||
}
|
||||
}
|
||||
animationSpeed2 = 2.f * glm::abs(strafeMovement);
|
||||
}
|
||||
|
||||
double strafeWeight = glm::abs(strafeMovement) / (glm::abs(forwardMovement) + glm::abs(strafeMovement));
|
||||
animationWeight2 = strafeWeight;
|
||||
animationWeight1 = 1.0 - strafeWeight;
|
||||
}
|
||||
} else {
|
||||
if (controller->Crouching()) {
|
||||
cAnimation["AnimationName1"] = "Crouch";
|
||||
(double&)cAnimation["Speed"] = 1.f;
|
||||
animationName1 = "Crouch";
|
||||
animationName2 = "";
|
||||
animationSpeed1 = 1.0;
|
||||
animationSpeed2 = 0.0;
|
||||
animationWeight1 = 1.0;
|
||||
animationWeight2 = 0.0;
|
||||
} else {
|
||||
cAnimation["AnimationName1"] = "Hold Pos";
|
||||
(double&)cAnimation["Speed1"] = 1.f;
|
||||
animationName1 = "Idle";
|
||||
animationName2 = "";
|
||||
animationSpeed1 = 1.f;
|
||||
animationSpeed2 = 0.0;
|
||||
animationWeight1 = 1.0;
|
||||
animationWeight2 = 0.0;
|
||||
//cAnimation["AnimationName2"] = "Idle";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
if (cameraEntity.Valid()) {
|
||||
Events::SetCamera e;
|
||||
e.CameraEntity = cameraEntity;
|
||||
m_EventBroker->Publish(e);
|
||||
//m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
// HACK: Set the player model color to team color
|
||||
|
||||
@@ -20,14 +20,14 @@ void WeaponSystem::Update(double dt)
|
||||
void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt)
|
||||
{
|
||||
// Update potential weapon behaviour for player
|
||||
//auto it = m_ActiveWeapons.find(entity);
|
||||
//if (it != m_ActiveWeapons.end()) {
|
||||
// //if (it->first.Valid()) {
|
||||
// it->second->Update(dt);
|
||||
// //} else {
|
||||
// // m_ActiveWeapons.erase(it);
|
||||
// //}
|
||||
//}
|
||||
auto it = m_ActiveWeapons.find(entity);
|
||||
if (it != m_ActiveWeapons.end()) {
|
||||
if (it->first.Valid()) {
|
||||
it->second->Update(dt);
|
||||
} else {
|
||||
m_ActiveWeapons.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WeaponSystem::OnInputCommand(Events::InputCommand& e)
|
||||
|
||||
Reference in New Issue
Block a user