Movement/rotation queue fixed and Simon force push
This commit is contained in:
+1
-1
Submodule assets updated: e077e4412b...0f0dc5d839
@@ -15,6 +15,9 @@ namespace Components
|
||||
EntityID ShotTemplate;
|
||||
float ShotSpeed;
|
||||
|
||||
float LowerRotationLimit;
|
||||
float UpperRotationLimit;
|
||||
|
||||
virtual BarrelSteering* Clone() const override { return new BarrelSteering(*this); }
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef Components_Follow_h__
|
||||
#define Components_Follow_h__
|
||||
|
||||
#include "Component.h"
|
||||
#include "Entity.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Follow : Component
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::vec3 FollowAxis;
|
||||
float Distance;
|
||||
|
||||
virtual Follow* Clone() const override { return new Follow(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
#endif // !Components_Follow_h__
|
||||
@@ -9,7 +9,8 @@ namespace Components
|
||||
struct TriggerMove : Component
|
||||
{
|
||||
EntityID Entity;
|
||||
float Time;
|
||||
float Speed;
|
||||
glm::vec3 StartPosition;
|
||||
glm::vec3 GoalPosition;
|
||||
virtual TriggerMove* Clone() const override { return new TriggerMove(*this); }
|
||||
};
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ namespace Events
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::vec3 GoalPosition;
|
||||
double Time;
|
||||
float Speed;
|
||||
bool Queue;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef Event_Rotate_h__
|
||||
#define Event_Rotate_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct Rotate : Event
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::quat GoalRotation;
|
||||
double Time;
|
||||
bool Queue;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Event_Rotate_h__
|
||||
+143
-128
@@ -35,6 +35,8 @@ void GameWorld::Initialize()
|
||||
BindKey(GLFW_KEY_J, "cam_horizontal", 1.f);
|
||||
BindKey(GLFW_KEY_U, "cam_normal", 1.f);
|
||||
BindKey(GLFW_KEY_T, "cam_normal", -1.f);
|
||||
BindKey(GLFW_KEY_B, "cam_speed", -1.f);
|
||||
BindKey(GLFW_KEY_N, "cam_speed", 1.f);
|
||||
|
||||
//BindGamepadButton(Gamepad::Button::Up, "Gamepad::Button::Up", 1.f);
|
||||
//BindGamepadButton(Gamepad::Button::Down, "Gamepad::Button::Down", 1.f);
|
||||
@@ -126,8 +128,9 @@ void GameWorld::Initialize()
|
||||
EntityID tank1 = CreateTank(1);
|
||||
{
|
||||
auto transform = GetComponent<Components::Transform>(tank1);
|
||||
transform->Position.z = 145.f;
|
||||
|
||||
transform->Position.z = 125.f;
|
||||
transform->Position.y = -20.f;
|
||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
|
||||
Events::SetViewportCamera e;
|
||||
e.CameraEntity = GetProperty<EntityID>(tank1, "Camera");
|
||||
e.ViewportFrame = "Viewport1";
|
||||
@@ -178,6 +181,8 @@ void GameWorld::Initialize()
|
||||
CommitEntity(flag);
|
||||
}
|
||||
|
||||
CreateGate(glm::vec3(0, -50, 150));
|
||||
|
||||
//for (int i = 0; i < 500; i++)
|
||||
//{
|
||||
// auto Light = CreateEntity();
|
||||
@@ -192,126 +197,6 @@ void GameWorld::Initialize()
|
||||
// //auto model = AddComponent<Components::Model>(Light, "Model");
|
||||
// //model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||
//}
|
||||
|
||||
|
||||
{
|
||||
auto gateBase = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gateBase);
|
||||
transform->Position = glm::vec3(0, -50, 150);
|
||||
auto model = AddComponent<Components::Model>(gateBase);
|
||||
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gateBase);
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
|
||||
{
|
||||
auto leftBaseShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(leftBaseShape);
|
||||
transform->Position = glm::vec3(8.5f, 3, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(leftBaseShape);
|
||||
box->Width = 3.f/2;
|
||||
box->Height = 6.094f/2;
|
||||
box->Depth = 4.f/2;
|
||||
CommitEntity(leftBaseShape);
|
||||
}
|
||||
{
|
||||
auto RightBaseShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RightBaseShape);
|
||||
transform->Position = glm::vec3(-8.5f, 3, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(RightBaseShape);
|
||||
box->Width = 3.f/2;
|
||||
box->Height = 6.094f/2;
|
||||
box->Depth = 4.f/2;
|
||||
CommitEntity(RightBaseShape);
|
||||
}
|
||||
{
|
||||
auto LeftTopShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(LeftTopShape);
|
||||
transform->Position = glm::vec3(7.5485f, 9.385f, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(LeftTopShape);
|
||||
box->Width = 1.747f/2;
|
||||
box->Height = 6.851f/2;
|
||||
box->Depth = 1.767f/2;
|
||||
CommitEntity(LeftTopShape);
|
||||
}
|
||||
{
|
||||
auto RightTopShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RightTopShape);
|
||||
transform->Position = glm::vec3(-7.5485f, 9.385f, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(RightTopShape);
|
||||
box->Width = 1.747f/2;
|
||||
box->Height = 6.851f/2;
|
||||
box->Depth = 1.767f/2;
|
||||
CommitEntity(RightTopShape);
|
||||
}
|
||||
{
|
||||
auto RampShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RampShape);
|
||||
transform->Position = glm::vec3(0, 0.24f, 0);
|
||||
auto mesh = AddComponent<Components::MeshShape>(RampShape);
|
||||
mesh->ResourceName = "Models/Gate/Lift/RampCollision.obj";
|
||||
CommitEntity(RampShape);
|
||||
}
|
||||
CommitEntity(gateBase);
|
||||
}
|
||||
|
||||
{
|
||||
auto gate = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gate);
|
||||
transform->Position = glm::vec3(0, -50, 150);
|
||||
auto model = AddComponent<Components::Model>(gate);
|
||||
model->ModelFile = "Models/Gate/Gate/Gate.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gate);
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
|
||||
{
|
||||
auto mainShape = CreateEntity(gate);
|
||||
auto transform = AddComponent<Components::Transform>(mainShape);
|
||||
transform->Position = glm::vec3(0.f, 3.09776f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(mainShape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 2.478f;
|
||||
box->Depth = 0.522f;
|
||||
CommitEntity(mainShape);
|
||||
}
|
||||
{
|
||||
auto lowerShape = CreateEntity(gate);
|
||||
auto transform = AddComponent<Components::Transform>(lowerShape);
|
||||
transform->Position = glm::vec3(0.f, 0.35f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(lowerShape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 0.308f;
|
||||
box->Depth = 0.222f;
|
||||
CommitEntity(lowerShape);
|
||||
}
|
||||
CommitEntity(gate);
|
||||
|
||||
{
|
||||
auto gateTrigger = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
||||
transform->Position = glm::vec3(0, -50 + 2.8241, 150);
|
||||
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
||||
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
||||
triggerMove->Entity = gate;
|
||||
triggerMove->Time = 0.5f;
|
||||
triggerMove->GoalPosition = glm::vec3(0, -50 + 9.02345f, 150);
|
||||
|
||||
|
||||
{
|
||||
auto shape = CreateEntity(gateTrigger);
|
||||
auto transform = AddComponent<Components::Transform>(shape);
|
||||
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(shape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 3.104f;
|
||||
box->Depth = 10.356f;
|
||||
CommitEntity(shape);
|
||||
}
|
||||
CommitEntity(gateTrigger);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GameWorld::Update(double dt)
|
||||
@@ -344,6 +229,7 @@ void GameWorld::RegisterSystems()
|
||||
m_SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(this, EventBroker, ResourceManager); });
|
||||
m_SystemFactory.Register<Systems::PhysicsSystem>([this]() { return new Systems::PhysicsSystem(this, EventBroker, ResourceManager); });
|
||||
m_SystemFactory.Register<Systems::TriggerSystem>([this]() { return new Systems::TriggerSystem(this, EventBroker, ResourceManager); });
|
||||
m_SystemFactory.Register<Systems::FollowSystem>([this]() { return new Systems::FollowSystem(this, EventBroker, ResourceManager); });
|
||||
m_SystemFactory.Register<Systems::RenderSystem>([this]() { return new Systems::RenderSystem(this, EventBroker, ResourceManager); });
|
||||
}
|
||||
|
||||
@@ -364,6 +250,7 @@ void GameWorld::AddSystems()
|
||||
AddSystem<Systems::SoundSystem>();
|
||||
AddSystem<Systems::PhysicsSystem>();
|
||||
AddSystem<Systems::TriggerSystem>();
|
||||
AddSystem<Systems::FollowSystem>();
|
||||
AddSystem<Systems::RenderSystem>();
|
||||
}
|
||||
|
||||
@@ -457,13 +344,15 @@ EntityID GameWorld::CreateTank(int playerID)
|
||||
{
|
||||
auto barrel = CreateEntity(tower);
|
||||
auto transform = AddComponent<Components::Transform>(barrel);
|
||||
transform->Position = glm::vec3(-0.012f, 0.4f, -0.75);
|
||||
transform->Position = glm::vec3(-0.012f, 0.3f, -0.95);
|
||||
auto model = AddComponent<Components::Model>(barrel);
|
||||
model->ModelFile = "Models/Tank/tankBarrel.obj";
|
||||
auto barrelSteering = AddComponent<Components::BarrelSteering>(barrel);
|
||||
barrelSteering->Axis = glm::vec3(1.f, 0.f, 0.f);
|
||||
barrelSteering->TurnSpeed = glm::pi<float>() / 4.f;
|
||||
barrelSteering->ShotSpeed = 70.f;
|
||||
barrelSteering->LowerRotationLimit = glm::radians(-10.f);
|
||||
barrelSteering->UpperRotationLimit = glm::radians(40.f);
|
||||
{
|
||||
auto shot = CreateEntity(barrel);
|
||||
auto transform = AddComponent<Components::Transform>(shot);
|
||||
@@ -494,15 +383,18 @@ EntityID GameWorld::CreateTank(int playerID)
|
||||
barrelSteering->ShotTemplate = shot;
|
||||
|
||||
|
||||
auto cameraTower = CreateEntity(barrel);
|
||||
auto cameraTower = CreateEntity();
|
||||
{
|
||||
auto model = AddComponent<Components::Model>(cameraTower);
|
||||
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||
auto transform = AddComponent<Components::Transform>(cameraTower);
|
||||
transform->Position.z = 16.f;
|
||||
transform->Position.y = 4.f;
|
||||
transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f));
|
||||
transform->Scale = glm::vec3(10);
|
||||
auto cameraComp = AddComponent<Components::Camera>(cameraTower);
|
||||
cameraComp->FarClip = 2000.f;
|
||||
//auto freeSteering = AddComponent<Components::FreeSteering>(cameraTower);
|
||||
auto follow = AddComponent<Components::Follow>(cameraTower);
|
||||
follow->Entity = barrel;
|
||||
follow->Distance = 15.f;
|
||||
follow->FollowAxis = glm::vec3(1, 1, 1);
|
||||
}
|
||||
|
||||
SetProperty(tank, "Camera", cameraTower);
|
||||
@@ -576,6 +468,129 @@ EntityID GameWorld::CreateTank(int playerID)
|
||||
return tank;
|
||||
}
|
||||
|
||||
void GameWorld::CreateGate(glm::vec3 Position)
|
||||
{
|
||||
{
|
||||
auto gateBase = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gateBase);
|
||||
transform->Position = Position;
|
||||
auto model = AddComponent<Components::Model>(gateBase);
|
||||
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gateBase);
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
|
||||
{
|
||||
auto leftBaseShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(leftBaseShape);
|
||||
transform->Position = glm::vec3(8.5f, 3, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(leftBaseShape);
|
||||
box->Width = 3.f/2;
|
||||
box->Height = 6.094f/2;
|
||||
box->Depth = 4.f/2;
|
||||
CommitEntity(leftBaseShape);
|
||||
}
|
||||
{
|
||||
auto RightBaseShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RightBaseShape);
|
||||
transform->Position = glm::vec3(-8.5f, 3, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(RightBaseShape);
|
||||
box->Width = 3.f/2;
|
||||
box->Height = 6.094f/2;
|
||||
box->Depth = 4.f/2;
|
||||
CommitEntity(RightBaseShape);
|
||||
}
|
||||
{
|
||||
auto LeftTopShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(LeftTopShape);
|
||||
transform->Position = glm::vec3(7.5485f, 9.385f, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(LeftTopShape);
|
||||
box->Width = 1.747f/2;
|
||||
box->Height = 6.851f/2;
|
||||
box->Depth = 1.767f/2;
|
||||
CommitEntity(LeftTopShape);
|
||||
}
|
||||
{
|
||||
auto RightTopShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RightTopShape);
|
||||
transform->Position = glm::vec3(-7.5485f, 9.385f, 0);
|
||||
auto box = AddComponent<Components::BoxShape>(RightTopShape);
|
||||
box->Width = 1.747f/2;
|
||||
box->Height = 6.851f/2;
|
||||
box->Depth = 1.767f/2;
|
||||
CommitEntity(RightTopShape);
|
||||
}
|
||||
{
|
||||
auto RampShape = CreateEntity(gateBase);
|
||||
auto transform = AddComponent<Components::Transform>(RampShape);
|
||||
transform->Position = glm::vec3(0, 0.24f, 0);
|
||||
auto mesh = AddComponent<Components::MeshShape>(RampShape);
|
||||
mesh->ResourceName = "Models/Gate/Lift/RampCollision.obj";
|
||||
CommitEntity(RampShape);
|
||||
}
|
||||
CommitEntity(gateBase);
|
||||
}
|
||||
|
||||
{
|
||||
auto gate = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gate);
|
||||
transform->Position = Position;
|
||||
auto model = AddComponent<Components::Model>(gate);
|
||||
model->ModelFile = "Models/Gate/Gate/Gate.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gate);
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
|
||||
{
|
||||
auto mainShape = CreateEntity(gate);
|
||||
auto transform = AddComponent<Components::Transform>(mainShape);
|
||||
transform->Position = glm::vec3(0.f, 3.09776f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(mainShape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 2.478f;
|
||||
box->Depth = 0.522f;
|
||||
CommitEntity(mainShape);
|
||||
}
|
||||
{
|
||||
auto lowerShape = CreateEntity(gate);
|
||||
auto transform = AddComponent<Components::Transform>(lowerShape);
|
||||
transform->Position = glm::vec3(0.f, 0.35f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(lowerShape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 0.308f;
|
||||
box->Depth = 0.222f;
|
||||
CommitEntity(lowerShape);
|
||||
}
|
||||
CommitEntity(gate);
|
||||
|
||||
{
|
||||
auto gateTrigger = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
||||
transform->Position = glm::vec3(Position.x, Position.y + 2.8241, Position.z);
|
||||
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
||||
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
||||
triggerMove->Entity = gate;
|
||||
triggerMove->Speed = 5.f;
|
||||
triggerMove->GoalPosition = glm::vec3(0, -50 + 9.02345f, 150);
|
||||
triggerMove->StartPosition = glm::vec3(0, -50, 150);
|
||||
|
||||
|
||||
{
|
||||
auto shape = CreateEntity(gateTrigger);
|
||||
auto transform = AddComponent<Components::Transform>(shape);
|
||||
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(shape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 3.104f;
|
||||
box->Depth = 10.356f;
|
||||
CommitEntity(shape);
|
||||
}
|
||||
CommitEntity(gateTrigger);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GameWorld::AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool front)
|
||||
{
|
||||
const float separation = 1.77f;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Systems/TimerSystem.h"
|
||||
#include "Systems/DamageSystem.h"
|
||||
#include "Systems/WheelPairSystem.h"
|
||||
#include "Systems/FollowSystem.h"
|
||||
|
||||
#include "Components/Camera.h"
|
||||
#include "Components/DirectionalLight.h"
|
||||
@@ -49,6 +50,7 @@
|
||||
#include "Components/Trigger.h"
|
||||
#include "Components/Flag.h"
|
||||
#include "Components/WheelPair.h"
|
||||
#include "Components/Follow.h"
|
||||
|
||||
class GameWorld : public World
|
||||
{
|
||||
@@ -72,6 +74,7 @@ private:
|
||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||
|
||||
EntityID CreateTank(int playerID);
|
||||
void CreateGate(glm::vec3 Position);
|
||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||
EntityID CreateJeep(int playerID);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "FollowSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::FollowSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Follow>([]() { return new Components::Follow(); });
|
||||
}
|
||||
|
||||
void Systems::FollowSystem::Update( double dt )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Systems::FollowSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
|
||||
{
|
||||
auto followComponent = m_World->GetComponent<Components::Follow>(entity);
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||
if(!followComponent || !transformComponent)
|
||||
return;
|
||||
auto absoluteTransformTarget = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(followComponent->Entity);
|
||||
|
||||
glm::vec3 Offset = (absoluteTransformTarget.Orientation * glm::normalize(absoluteTransformTarget.Position) * followComponent->Distance);
|
||||
transformComponent->Position = (absoluteTransformTarget.Position + Offset);
|
||||
transformComponent->Orientation = -glm::quat(glm::eulerAngles(absoluteTransformTarget.Orientation) * followComponent->FollowAxis);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef FollowSystem_h__
|
||||
#define FollowSystem_h__
|
||||
|
||||
|
||||
#include "System.h"
|
||||
#include "Systems/TransformSystem.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Follow.h"
|
||||
|
||||
#include "Events/Move.h"
|
||||
#include "Events/Rotate.h"
|
||||
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
class FollowSystem : public System
|
||||
{
|
||||
public:
|
||||
|
||||
FollowSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||
: System(world, eventBroker, resourceManager) { }
|
||||
|
||||
//void Initialize() override;
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
/*void OnComponentCreated(std::string type, std::shared_ptr<Component> component) override;
|
||||
void OnComponentRemoved(EntityID entity, std::string type, Component* component) override;
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
void OnEntityRemoved(EntityID entity) override;*/
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // FollowSystem_h__
|
||||
@@ -158,8 +158,7 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
if (!transformComponent)
|
||||
continue;
|
||||
|
||||
if(/*m_RigidBodies[entity]->isActive()*/ true)
|
||||
{
|
||||
|
||||
hkVector4 position;
|
||||
hkQuaternion rotation;
|
||||
hkVector4 velocity;
|
||||
@@ -179,10 +178,14 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
}
|
||||
m_PhysicsWorld->markForWrite();
|
||||
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
||||
|
||||
if(m_RigidBodies[entity]->getMotionType() != hkpMotion::MOTION_FIXED)
|
||||
{
|
||||
m_RigidBodies[entity]->setLinearVelocity(velocity);
|
||||
}
|
||||
m_PhysicsWorld->unmarkForWrite();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
glm::vec3 pos1 = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[m_World->m_Terrain]->getPosition());
|
||||
@@ -751,9 +754,9 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
||||
{
|
||||
if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
||||
{
|
||||
|
||||
m_PhysicsWorld->markForWrite();
|
||||
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
||||
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||
transformComponent->Velocity = event.Velocity;
|
||||
m_PhysicsWorld->unmarkForWrite();
|
||||
|
||||
@@ -68,6 +68,20 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
glm::quat orientation = glm::angleAxis(barrelSteeringComponent->TurnSpeed * inputController->BarrelDirection * (float)dt, barrelSteeringComponent->Axis);
|
||||
transformComponent->Orientation *= orientation;
|
||||
|
||||
glm::vec3 angles = glm::eulerAngles(transformComponent->Orientation);
|
||||
if(angles.x > barrelSteeringComponent->UpperRotationLimit)
|
||||
{
|
||||
angles.x = barrelSteeringComponent->UpperRotationLimit;
|
||||
transformComponent->Orientation = glm::quat(angles);
|
||||
}
|
||||
else if(angles.x < barrelSteeringComponent->LowerRotationLimit)
|
||||
{
|
||||
angles.x = barrelSteeringComponent->LowerRotationLimit;
|
||||
transformComponent->Orientation = glm::quat(angles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
||||
{
|
||||
EntityID clone = m_World->CloneEntity(barrelSteeringComponent->ShotTemplate);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
void Systems::TransformSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMove, &Systems::TransformSystem::OnMove);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERotate, &Systems::TransformSystem::OnRotate);
|
||||
}
|
||||
|
||||
void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
|
||||
@@ -23,14 +24,16 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
||||
if(m_MoveItems.find(entity) != m_MoveItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
glm::vec3 move = m_MoveItems[entity].GoalPosition - transform->Position;
|
||||
move /= m_MoveItems[entity].Time;
|
||||
m_MoveItems[entity].Time -= dt;
|
||||
|
||||
if(m_MoveItems[entity].Time <= 0)
|
||||
glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position);
|
||||
glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt;
|
||||
|
||||
glm::vec3 v1 = m_MoveItems[entity].GoalPosition - transform->Position;
|
||||
glm::vec3 v2 = movement;
|
||||
|
||||
if(glm::length(v2) >= glm::length(v1))
|
||||
{
|
||||
float movetime = dt + m_MoveItems[entity].Time;
|
||||
transform->Position += move * movetime;
|
||||
transform->Position = m_MoveItems[entity].GoalPosition;
|
||||
|
||||
m_MoveItems.erase(entity);
|
||||
|
||||
@@ -43,24 +46,81 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
||||
}
|
||||
else
|
||||
{
|
||||
transform->Position += move * (float)dt;
|
||||
transform->Position += movement;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
float percentage = dt/m_RotationItems[entity].Time;
|
||||
m_RotationItems[entity].Time -= dt;
|
||||
glm::clamp(percentage, 0.f, 1.0f);
|
||||
transform->Orientation = glm::slerp(transform->Orientation, m_RotationItems[entity].GoalRotation, percentage);
|
||||
|
||||
if(m_RotationItems[entity].Time <= 0)
|
||||
{
|
||||
m_RotationItems.erase(entity);
|
||||
|
||||
if(m_QueuedRotationItems.find(entity) != m_QueuedRotationItems.end())
|
||||
{
|
||||
auto it = m_QueuedRotationItems.find(entity);
|
||||
m_RotationItems[entity] = it->second;
|
||||
m_QueuedRotationItems.erase(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Systems::TransformSystem::OnRotate( const Events::Rotate &event )
|
||||
{
|
||||
RotationItems item;
|
||||
item.Entity = event.Entity;
|
||||
item.GoalRotation = event.GoalRotation;
|
||||
item.Time = event.Time;
|
||||
|
||||
if(event.Queue)
|
||||
{
|
||||
if(m_RotationItems.find(event.Entity) != m_RotationItems.end())
|
||||
{
|
||||
m_QueuedRotationItems.insert(std::make_pair(event.Entity, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RotationItems[event.Entity] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RotationItems[event.Entity] = item;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Systems::TransformSystem::OnMove( const Events::Move &event )
|
||||
{
|
||||
MoveItems item;
|
||||
item.Entity = event.Entity;
|
||||
item.GoalPosition = event.GoalPosition;
|
||||
item.Time = event.Time;
|
||||
m_MoveItems[event.Entity] = item;
|
||||
item.Speed = event.Speed;
|
||||
|
||||
if(event.Queue)
|
||||
{
|
||||
if(m_MoveItems.find(event.Entity) != m_MoveItems.end())
|
||||
{
|
||||
m_QueuedMoveItems.insert(std::make_pair(event.Entity, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MoveItems[event.Entity] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MoveItems[event.Entity] = item;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "System.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Events/Move.h"
|
||||
#include "Events/Rotate.h"
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
@@ -29,16 +30,25 @@ public:
|
||||
// Events
|
||||
EventRelay<TransformSystem, Events::Move> m_EMove;
|
||||
bool OnMove(const Events::Move &event);
|
||||
EventRelay<TransformSystem, Events::Rotate> m_ERotate;
|
||||
bool OnRotate(const Events::Rotate &event);
|
||||
private:
|
||||
struct MoveItems
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::vec3 GoalPosition;
|
||||
double Time;
|
||||
float Speed;
|
||||
};
|
||||
std::unordered_map<EntityID, MoveItems> m_MoveItems;
|
||||
std::multimap<EntityID, MoveItems> m_QueuedMoveItems;
|
||||
|
||||
struct RotationItems
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::quat GoalRotation;
|
||||
double Time;
|
||||
};
|
||||
std::unordered_map<EntityID, RotationItems> m_RotationItems;
|
||||
std::multimap<EntityID, RotationItems> m_QueuedRotationItems;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -121,11 +121,13 @@ void Systems::TriggerSystem::Move( EntityID entity )
|
||||
Events::Move e;
|
||||
e.Entity = trigger->Entity;
|
||||
e.GoalPosition = trigger->GoalPosition;
|
||||
e.Time = trigger->Time;
|
||||
e.Speed = trigger->Speed;
|
||||
e.Queue = false;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
trigger->GoalPosition = transform->Position;
|
||||
glm::vec3 temp = trigger->GoalPosition;
|
||||
trigger->GoalPosition = trigger->StartPosition;
|
||||
trigger->StartPosition = temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Components/TriggerMove.h"
|
||||
#include "Components/Player.h"
|
||||
#include "Events/Move.h"
|
||||
#include "Events/Rotate.h"
|
||||
#include <math.h>
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
<ClCompile Include="..\..\src\Sound.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\DebugSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\FreeSteeringSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\HelicopterSteeringSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\InputSystem.cpp" />
|
||||
@@ -135,6 +136,7 @@
|
||||
<ClInclude Include="..\..\src\Components\Camera.h" />
|
||||
<ClInclude Include="..\..\src\Components\DirectionalLight.h" />
|
||||
<ClInclude Include="..\..\src\Components\Flag.h" />
|
||||
<ClInclude Include="..\..\src\Components\Follow.h" />
|
||||
<ClInclude Include="..\..\src\Components\FrameTimer.h" />
|
||||
<ClInclude Include="..\..\src\Components\TriggerMove.h" />
|
||||
<ClInclude Include="..\..\src\Components\Timer.h" />
|
||||
@@ -190,6 +192,7 @@
|
||||
<ClInclude Include="..\..\src\Events\MouseRelease.h" />
|
||||
<ClInclude Include="..\..\src\Events\Move.h" />
|
||||
<ClInclude Include="..\..\src\Events\PlaySound.h" />
|
||||
<ClInclude Include="..\..\src\Events\Rotate.h" />
|
||||
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
||||
<ClInclude Include="..\..\src\Events\SetViewportCamera.h" />
|
||||
<ClInclude Include="..\..\src\Events\TankSteer.h" />
|
||||
@@ -219,6 +222,7 @@
|
||||
<ClInclude Include="..\..\src\System.h" />
|
||||
<ClInclude Include="..\..\src\Systems\DamageSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\DebugSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\FollowSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\FreeSteeringSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\HelicopterSteeringSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\InputSystem.h" />
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<Filter>Physics\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\HelicopterSteeringSystem.cpp">
|
||||
<Filter>Gameplay\Vehicles\Helicopter\Systems</Filter>
|
||||
<Filter>Game\Vehicles\Helicopter\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp">
|
||||
<Filter>Physics\Systems</Filter>
|
||||
@@ -73,9 +73,12 @@
|
||||
<Filter>Base\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Util">
|
||||
@@ -150,36 +153,36 @@
|
||||
<Filter Include="Physics\Events">
|
||||
<UniqueIdentifier>{42ae084f-ade8-402c-87ba-f03f6b846bc8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay">
|
||||
<UniqueIdentifier>{5b992473-73e6-485e-8f13-17e0801fb2ca}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Vehicles">
|
||||
<UniqueIdentifier>{8a78be3a-a3c5-4054-a2f1-1456f3fcbab0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Vehicles\Helicopter">
|
||||
<UniqueIdentifier>{8ccc0abe-5bdd-4656-ab11-5708a39c71ae}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Vehicles\Helicopter\Components">
|
||||
<UniqueIdentifier>{b2416d05-a49e-4fef-a5c4-cd03d8cc2efd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Vehicles\Helicopter\Systems">
|
||||
<UniqueIdentifier>{b34c0c95-a887-4cf4-af24-cf7c1f459aa8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Components">
|
||||
<UniqueIdentifier>{cb06b441-90b8-46ed-b347-4190dac7185b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Systems">
|
||||
<UniqueIdentifier>{3c2ea0e5-41a1-4b11-a891-1d59ead7223c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Rendering\Events">
|
||||
<UniqueIdentifier>{a025d51e-594d-4844-983b-f683726bf1bf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Gameplay\Events">
|
||||
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Base\Events">
|
||||
<UniqueIdentifier>{ffab6cc2-2fbf-400f-9398-a6741b6cc95c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game">
|
||||
<UniqueIdentifier>{5b992473-73e6-485e-8f13-17e0801fb2ca}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Vehicles">
|
||||
<UniqueIdentifier>{8a78be3a-a3c5-4054-a2f1-1456f3fcbab0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Vehicles\Helicopter">
|
||||
<UniqueIdentifier>{8ccc0abe-5bdd-4656-ab11-5708a39c71ae}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Vehicles\Helicopter\Components">
|
||||
<UniqueIdentifier>{b2416d05-a49e-4fef-a5c4-cd03d8cc2efd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Vehicles\Helicopter\Systems">
|
||||
<UniqueIdentifier>{b34c0c95-a887-4cf4-af24-cf7c1f459aa8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Components">
|
||||
<UniqueIdentifier>{cb06b441-90b8-46ed-b347-4190dac7185b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Systems">
|
||||
<UniqueIdentifier>{3c2ea0e5-41a1-4b11-a891-1d59ead7223c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Events">
|
||||
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\World.h" />
|
||||
@@ -405,10 +408,10 @@
|
||||
<Filter>Input\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\HelicopterSteering.h">
|
||||
<Filter>Gameplay\Vehicles\Helicopter\Components</Filter>
|
||||
<Filter>Game\Vehicles\Helicopter\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Systems\HelicopterSteeringSystem.h">
|
||||
<Filter>Gameplay\Vehicles\Helicopter\Systems</Filter>
|
||||
<Filter>Game\Vehicles\Helicopter\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\ApplyForce.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
@@ -417,7 +420,7 @@
|
||||
<Filter>Physics\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\Player.h">
|
||||
<Filter>Gameplay\Components</Filter>
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\Collision.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
@@ -456,13 +459,13 @@
|
||||
<Filter>Base\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Systems\DamageSystem.h">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\Damage.h">
|
||||
<Filter>Gameplay\Events</Filter>
|
||||
<Filter>Game\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\Flag.h">
|
||||
<Filter>Gameplay\Components</Filter>
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\GUI\TextureFrame.h">
|
||||
<Filter>GUI</Filter>
|
||||
@@ -491,6 +494,16 @@
|
||||
<ClInclude Include="..\..\src\Events\LeaveTrigger.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\TriggerMove.h" />
|
||||
<ClInclude Include="..\..\src\Components\Follow.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Systems\FollowSystem.h">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\Rotate.h">
|
||||
<Filter>Base\Events</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||
|
||||
Reference in New Issue
Block a user