diff --git a/assets b/assets index a6e3f12..637f866 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit a6e3f120fd90e4c2c3983cf0098bb9c3ebdc4b39 +Subproject commit 637f866e2d220a1c063f7de2d9f64863643d686f diff --git a/src/Components/SpawnPoint.h b/src/Components/SpawnPoint.h index c29230d..74aaaf9 100644 --- a/src/Components/SpawnPoint.h +++ b/src/Components/SpawnPoint.h @@ -8,6 +8,8 @@ namespace Components struct SpawnPoint : Component { + EntityID Player; + virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); } }; diff --git a/src/GUI/Frame.h b/src/GUI/Frame.h index 25c2dd1..ba99851 100644 --- a/src/GUI/Frame.h +++ b/src/GUI/Frame.h @@ -132,7 +132,11 @@ public: Rectangle AbsoluteRectangle() { int left = Left(); + if (m_Parent) + left = std::max(left, m_Parent->Left()); int top = Top(); + if (m_Parent) + top = std::max(top, m_Parent->Top()); int width = Right() - left; int height = Bottom() - top; return Rectangle(left, top, width, height); diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 6490f44..4f3d9fd 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -91,7 +91,7 @@ void GameWorld::Initialize() EventBroker->Publish(e); } - //CreateTerrain(); + CreateTerrain(); #pragma region Wall_Debris_Template @@ -275,7 +275,7 @@ void GameWorld::Initialize() { EntityID Wall = CreateWall(glm::vec3(i*10.f, -15.f, 0.f), glm::quat()); } - + #pragma endregion Region for all wall creations /*EntityID tank1 = CreateTank(1); @@ -301,8 +301,7 @@ void GameWorld::Initialize() EventBroker->Publish(e); }*/ - CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(), 1); // glm::vec3(0, glm::pi()/2.f, 0) - CreateGarage(glm::vec3(-323.2f, 41.4f, -10.2f), glm::quat(), 2); // glm::vec3(0, -glm::pi()/2.f, 0) + { auto flag = CreateEntity(); @@ -790,178 +789,6 @@ EntityID GameWorld::CreateJeep(int playerID) return jeep; } -EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int playerID) -{ - auto garage = CreateEntity(); - auto transform = AddComponent(garage); - transform->Position = position; - transform->Orientation = orientation; - auto player = AddComponent(garage); - player->ID = playerID; - - auto ElevatorBase = CreateEntity(garage); - { - auto transform = AddComponent(ElevatorBase); - auto model = AddComponent(ElevatorBase); - model->ModelFile = "Models/SpawnRamp/Main/Main.obj"; - auto physics = AddComponent(ElevatorBase); - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; - - { - auto mainShape = CreateEntity(ElevatorBase); - auto transform = AddComponent(mainShape); - transform->Position = glm::vec3(0.f, 0, 0.f); - auto mesh = AddComponent(mainShape); - mesh->ResourceName = "Models/SpawnRamp/Main/CollisionShape.obj"; - CommitEntity(mainShape); - } - { - auto StairsShape = CreateEntity(ElevatorBase); - auto transform = AddComponent(StairsShape); - transform->Position = glm::vec3(-7.48639f, 0.4809f, 3.79166f); - auto box = AddComponent(StairsShape); - box->Width = 1.211f; - box->Height = 1.798f; - box->Depth = 3.229f; - CommitEntity(StairsShape); - } - } - CommitEntity(ElevatorBase); - - auto leftHatch = CreateEntity(garage); - { - auto transform = AddComponent(leftHatch); - transform->Position = glm::vec3(5.83103f, 1.3553f, -2.40268f); - auto model = AddComponent(leftHatch); - model->ModelFile = "Models/SpawnRamp/LeftHatch/LeftHatch.obj"; - auto physics = AddComponent(leftHatch); - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; - auto rotate = AddComponent(leftHatch); - rotate->StartRotation = transform->Orientation; - rotate->GoalRotation = transform->Orientation * glm::angleAxis(-glm::radians(110.f), glm::vec3(0, 0, 1)); - rotate->Time = 5.f; - { - auto shape = CreateEntity(leftHatch); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(-2.79331, 0, 0); - auto box = AddComponent(shape); - box->Width = 2.317f; - box->Height = 0.183f; - box->Depth = 6.987f; - CommitEntity(shape); - } - CommitEntity(leftHatch); - } - - auto rightHatch = CreateEntity(garage); - { - auto transform = AddComponent(rightHatch); - transform->Position = glm::vec3(-4.52423f, 1.3553f, -2.40268f); - auto model = AddComponent(rightHatch); - model->ModelFile = "Models/SpawnRamp/RightHatch/RightHatch.obj"; - auto physics = AddComponent(rightHatch); - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; - auto rotate = AddComponent(rightHatch); - rotate->StartRotation = transform->Orientation; - rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1)); - rotate->Time = 5.f; - { - auto shape = CreateEntity(rightHatch); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(2.79331, 0, 0); - auto box = AddComponent(shape); - box->Width = 2.317f; - box->Height = 0.183f; - box->Depth = 6.987f; - CommitEntity(shape); - } - CommitEntity(rightHatch); - } - - auto elevator = CreateEntity(garage); - { - auto transform = AddComponent(elevator); - transform->Position = glm::vec3(0.69385f, 1.25222f, -2.39938f) + glm::vec3(0, -9.5f, 0); - auto model = AddComponent(elevator); - model->ModelFile = "Models/SpawnRamp/Elevator/Elevator.obj"; - auto physics = AddComponent(elevator); - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; - auto move = AddComponent(elevator); - move->StartPosition = transform->Position; - move->GoalPosition = transform->Position + glm::vec3(0, 9.5f, 0); - move->Speed = 1.5f; - { - auto shape = CreateEntity(elevator); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0, 0, 0); - auto box = AddComponent(shape); - box->Width = 4.754f; - box->Height = 0.141f; - box->Depth = 6.86f; - CommitEntity(shape); - } - - auto spawnPoint = CreateEntity(elevator); - { - auto transform = AddComponent(spawnPoint); - transform->Position.y = 1.f; - auto spawnPointComponent = AddComponent(spawnPoint); - } - CommitEntity(spawnPoint); - } - CommitEntity(elevator); - - auto garageComponent = AddComponent(garage); - garageComponent->DoorLeft = leftHatch; - garageComponent->DoorRight = rightHatch; - garageComponent->Elevator = elevator; - CommitEntity(garage); - - { - auto trigger = CreateEntity(garage); - SetProperty(trigger, "Name", "BoundsTrigger"); - auto transform = AddComponent(trigger); - transform->Position = glm::vec3(0, 44.87521f, 0); - auto triggerComponent = AddComponent(trigger); - { - auto shape = CreateEntity(trigger); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0, 0, 0); - auto box = AddComponent(shape); - box->Width = 72.98f; - box->Height = 54.53f; - box->Depth = 72.98f; - CommitEntity(shape); - } - CommitEntity(trigger); - } - - { - auto trigger = CreateEntity(garage); - SetProperty(trigger, "Name", "ElevatorShaftTrigger"); - auto transform = AddComponent(trigger); - transform->Position = glm::vec3(0.69385f, -6.7997f, -2.0f); - auto triggerComponent = AddComponent(trigger); - { - auto shape = CreateEntity(trigger); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0, 0, 0); - auto box = AddComponent(shape); - box->Width = 2.0f; - box->Height = 12.f; - box->Depth = 2.0f; - CommitEntity(shape); - } - CommitEntity(trigger); - } - - return garage; -} - void GameWorld::CreateTerrain() { { @@ -1047,8 +874,8 @@ void GameWorld::CreateTerrain() CommitEntity(ground_middle); } - CreateBase(glm::quat()); - CreateBase(glm::quat(glm::vec3(0, glm::pi()/2.f, 0))); + CreateBase(glm::quat(), 1); + CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0)), 2); { auto tree = CreateEntity(); @@ -1117,12 +944,15 @@ void GameWorld::CreateTerrain() } } -void GameWorld::CreateBase(glm::quat orientation) +void GameWorld::CreateBase(glm::quat orientation, int playerID) { + auto base = CreateEntity(); + auto transform = AddComponent(base); + transform->Orientation = orientation; + { - auto ground_small = CreateEntity(); + auto ground_small = CreateEntity(base); auto transform = AddComponent(ground_small); - transform->Orientation = orientation; auto model = AddComponent(ground_small); model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; auto blendmap = AddComponent(ground_small); @@ -1149,12 +979,51 @@ void GameWorld::CreateBase(glm::quat orientation) } { - auto ground_base = CreateEntity(); - auto transform = AddComponent(ground_base); - transform->Orientation = orientation; - auto model = AddComponent(ground_base); + auto road_small = CreateEntity(base); + auto transform = AddComponent(road_small); + auto model = AddComponent(road_small); + model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; + auto physics = AddComponent(road_small); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(road_small); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; + + + CommitEntity(groundshape); + CommitEntity(road_small); + } + + { + auto bridge_middle = CreateEntity(base); + auto transform = AddComponent(bridge_middle); + auto model = AddComponent(bridge_middle); + model->ModelFile = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj"; + auto physics = AddComponent(bridge_middle); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + { + auto shape = CreateEntity(bridge_middle); + auto transformshape = AddComponent(shape); + auto meshShape = AddComponent(shape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj"; + CommitEntity(shape); + } + CommitEntity(bridge_middle); + } + + { + auto terrain_base = CreateEntity(base); + auto transform = AddComponent(terrain_base); + auto model = AddComponent(terrain_base); model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; - auto blendmap = AddComponent(ground_base); + auto blendmap = AddComponent(terrain_base); blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; @@ -1163,25 +1032,43 @@ void GameWorld::CreateBase(glm::quat orientation) blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; blendmap->TextureRepeats = 30.f; + auto physics = AddComponent(terrain_base); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto shape = CreateEntity(terrain_base); + auto transformshape = AddComponent(shape); + auto meshShape = AddComponent(shape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj"; + + + CommitEntity(shape); + CommitEntity(terrain_base); + } + + { + auto ground_base = CreateEntity(base); + auto transform = AddComponent(ground_base); + auto model = AddComponent(ground_base); + model->ModelFile = "Models/TerrainFiveIstles/BaseGround.obj"; auto physics = AddComponent(ground_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; - auto groundshape = CreateEntity(ground_base); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj"; - - - CommitEntity(groundshape); + auto shape = CreateEntity(ground_base); + auto transformshape = AddComponent(shape); + auto meshShape = AddComponent(shape); + meshShape->ResourceName = "Models/TerrainFiveIstles/BaseGround.obj"; + + CommitEntity(shape); CommitEntity(ground_base); } { - auto road_base = CreateEntity(); + auto road_base = CreateEntity(base); auto transform = AddComponent(road_base); - transform->Orientation = orientation; auto model = AddComponent(road_base); model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; auto physics = AddComponent(road_base); @@ -1200,23 +1087,198 @@ void GameWorld::CreateBase(glm::quat orientation) } { - auto road_small = CreateEntity(); - auto transform = AddComponent(road_small); - transform->Orientation = orientation; - auto model = AddComponent(road_small); - model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; - auto physics = AddComponent(road_small); + auto bridge_base = CreateEntity(base); + auto transform = AddComponent(bridge_base); + auto model = AddComponent(bridge_base); + model->ModelFile = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj"; + auto physics = AddComponent(bridge_base); physics->Mass = 10; physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; physics->CollisionLayer = 1; - auto groundshape = CreateEntity(road_small); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/SmallRoad.obj"; - - - CommitEntity(groundshape); - CommitEntity(road_small); + { + auto shape = CreateEntity(bridge_base); + auto transformshape = AddComponent(shape); + auto meshShape = AddComponent(shape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj"; + CommitEntity(shape); + } + CommitEntity(bridge_base); } -} \ No newline at end of file + + CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), playerID); +} +EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID) +{ + auto garage = CreateEntity(parent); + auto transform = AddComponent(garage); + transform->Position = Position; + transform->Orientation = orientation; + + auto player = CreateEntity(garage); + auto playerComponent = AddComponent(player); + playerComponent->ID = playerID; + + auto ElevatorBase = CreateEntity(garage); + { + auto transform = AddComponent(ElevatorBase); + auto model = AddComponent(ElevatorBase); + model->ModelFile = "Models/SpawnRamp/Main/Main.obj"; + auto physics = AddComponent(ElevatorBase); + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; + + { + auto mainShape = CreateEntity(ElevatorBase); + auto transform = AddComponent(mainShape); + transform->Position = glm::vec3(0.f, 0, 0.f); + auto mesh = AddComponent(mainShape); + mesh->ResourceName = "Models/SpawnRamp/Main/CollisionShape.obj"; + CommitEntity(mainShape); + } + { + auto StairsShape = CreateEntity(ElevatorBase); + auto transform = AddComponent(StairsShape); + transform->Position = glm::vec3(-7.48639f, 0.4809f, 3.79166f); + auto box = AddComponent(StairsShape); + box->Width = 1.211f; + box->Height = 1.798f; + box->Depth = 3.229f; + CommitEntity(StairsShape); + } + } + CommitEntity(ElevatorBase); + + auto leftHatch = CreateEntity(garage); + { + auto transform = AddComponent(leftHatch); + transform->Position = glm::vec3(5.83103f, 1.3553f, -2.40268f); + auto model = AddComponent(leftHatch); + model->ModelFile = "Models/SpawnRamp/LeftHatch/LeftHatch.obj"; + auto physics = AddComponent(leftHatch); + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; + auto rotate = AddComponent(leftHatch); + rotate->StartRotation = transform->Orientation; + rotate->GoalRotation = transform->Orientation * glm::angleAxis(-glm::radians(110.f), glm::vec3(0, 0, 1)); + rotate->Time = 5.f; + { + auto shape = CreateEntity(leftHatch); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(-2.79331, 0, 0); + auto box = AddComponent(shape); + box->Width = 2.317f; + box->Height = 0.183f; + box->Depth = 6.987f; + CommitEntity(shape); + } + CommitEntity(leftHatch); + } + + auto rightHatch = CreateEntity(garage); + { + auto transform = AddComponent(rightHatch); + transform->Position = glm::vec3(-4.52423f, 1.3553f, -2.40268f); + auto model = AddComponent(rightHatch); + model->ModelFile = "Models/SpawnRamp/RightHatch/RightHatch.obj"; + auto physics = AddComponent(rightHatch); + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; + auto rotate = AddComponent(rightHatch); + rotate->StartRotation = transform->Orientation; + rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1)); + rotate->Time = 5.f; + { + auto shape = CreateEntity(rightHatch); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(2.79331, 0, 0); + auto box = AddComponent(shape); + box->Width = 2.317f; + box->Height = 0.183f; + box->Depth = 6.987f; + CommitEntity(shape); + } + CommitEntity(rightHatch); + } + + auto elevator = CreateEntity(garage); + { + auto transform = AddComponent(elevator); + transform->Position = glm::vec3(0.69385f, 1.25222f, -2.39938f) + glm::vec3(0, -9.5f, 0); + auto model = AddComponent(elevator); + model->ModelFile = "Models/SpawnRamp/Elevator/Elevator.obj"; + auto physics = AddComponent(elevator); + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; + auto move = AddComponent(elevator); + move->StartPosition = transform->Position; + move->GoalPosition = transform->Position + glm::vec3(0, 9.5f, 0); + move->Speed = 1.5f; + { + auto shape = CreateEntity(elevator); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0, 0, 0); + auto box = AddComponent(shape); + box->Width = 4.754f; + box->Height = 0.141f; + box->Depth = 6.86f; + CommitEntity(shape); + } + + auto spawnPoint = CreateEntity(elevator); + { + auto transform = AddComponent(spawnPoint); + transform->Position.y = 1.f; + auto spawnPointComponent = AddComponent(spawnPoint); + spawnPointComponent->Player = player; + } + CommitEntity(spawnPoint); + } + CommitEntity(elevator); + + auto garageComponent = AddComponent(garage); + garageComponent->DoorLeft = leftHatch; + garageComponent->DoorRight = rightHatch; + garageComponent->Elevator = elevator; + CommitEntity(garage); + + { + auto trigger = CreateEntity(garage); + SetProperty(trigger, "Name", "BoundsTrigger"); + auto transform = AddComponent(trigger); + transform->Position = glm::vec3(0, 44.87521f, 0); + auto triggerComponent = AddComponent(trigger); + { + auto shape = CreateEntity(trigger); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0, 0, 0); + auto box = AddComponent(shape); + box->Width = 72.98f; + box->Height = 54.53f; + box->Depth = 72.98f; + CommitEntity(shape); + } + CommitEntity(trigger); + } + + { + auto trigger = CreateEntity(garage); + SetProperty(trigger, "Name", "ElevatorShaftTrigger"); + auto transform = AddComponent(trigger); + transform->Position = glm::vec3(0.69385f, -6.7997f, -2.0f); + auto triggerComponent = AddComponent(trigger); + { + auto shape = CreateEntity(trigger); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0, 0, 0); + auto box = AddComponent(shape); + box->Width = 2.0f; + box->Height = 12.f; + box->Depth = 2.0f; + CommitEntity(shape); + } + CommitEntity(trigger); + } + + return garage; +} diff --git a/src/GameWorld.h b/src/GameWorld.h index 66dde65..20b3e98 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -82,9 +82,9 @@ private: void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering); EntityID CreateJeep(int playerID); EntityID CreateWall(glm::vec3 pos, glm::quat orientation); - EntityID CreateGarage(glm::vec3 Position, glm::quat orientation, int playerID); + EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID); void CreateTerrain(); - void CreateBase(glm::quat orientation); + void CreateBase(glm::quat orientation, int playerID); std::vector m_WallDebrisTemplates; }; diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 933780b..958fd1b 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -276,6 +276,7 @@ void Renderer::DrawFrame(RenderQueuePair &rq) //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glClearColor(0.0f, 0.5f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 465e498..3db178b 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -180,6 +180,12 @@ void Systems::PhysicsSystem::Update(double dt) rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation); velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity); } + + /*auto absoluteTransform = m_World->GetSystem()->AbsoluteTransform(entity); + position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position); + rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation); + velocity = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Velocity);*/ + m_PhysicsWorld->markForWrite(); m_RigidBodies[entity]->setPositionAndRotation(position, rotation); @@ -268,17 +274,33 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p else if(m_RigidBodies.find(entity) != m_RigidBodies.end()) { auto transformComponentParent = m_World->GetComponent(parent); + + /* if(transformComponentParent) + { + auto absoluteTransformParent = m_World->GetSystem()->AbsoluteTransform(parent); + transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); + transformComponent->Orientation = glm::inverse(HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation())) * absoluteTransformParent.Orientation; + transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); + } + else + { + auto transformComponentParent = m_World->GetComponent(parent); + transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); + transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation()); + transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); + }*/ + transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation()); transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); - // TODO: No support for Scale, MIGHT be possible // HACK: WTF IS THIS? if (transformComponentParent) { - transformComponent->Position -= transformComponentParent->Position; - transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation; - transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation); + auto absoluteTransformParent = m_World->GetSystem()->AbsoluteTransform(parent); + transformComponent->Position -= absoluteTransformParent.Position; + transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation; + transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation; } } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 9c8a7c0..9904446 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -128,11 +128,11 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit } { -// Events::PlaySFX e; -// e.Resource = "Sounds/SFX/TankShot.mp3"; -// e.Position = absoluteTransform.Position; -// e.Loop = false; -// EventBroker->Publish(e); + Events::PlaySFX e; + e.Resource = "Sounds/SFX/TankShot.mp3"; + e.Position = cloneTransform->Position; + e.Loop = false; + EventBroker->Publish(e); } auto clonePhysicsComponent = m_World->GetComponent(clone); @@ -256,11 +256,11 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) EventBroker->Publish(e); } { -// Events::PlaySFX e; -// e.MinDistance = 150.f; -// e.Position = shellTransform->Position; -// e.Resource = "Sounds/SFX/Explosion.wav"; -// EventBroker->Publish(e); + Events::PlaySFX e; + e.MinDistance = 150.f; + e.Position = shellTransform->Position; + e.Resource = "Sounds/SFX/Explosion.wav"; + EventBroker->Publish(e); } for (auto &physComponent : *physicsComponents) @@ -383,11 +383,11 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve return false; } - for (auto &spawnPointComponent : *spawnPointComponents) + for (auto &component : *spawnPointComponents) { - auto spawnPoint = spawnPointComponent->Entity; - auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint); - auto playerComponent = m_World->GetComponent(spawnPointBaseParent); + auto spawnPoint = component->Entity; + auto spawnPointComponent = std::dynamic_pointer_cast(component); + auto playerComponent = m_World->GetComponent(spawnPointComponent->Player); if (!playerComponent || playerComponent->ID != event.PlayerID) continue; @@ -430,6 +430,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) m_World->AddComponent(tank); auto health = m_World->AddComponent(tank); health->Amount = 100.f; + m_World->AddComponent(tank); { auto shape = m_World->CreateEntity(tank); diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index 7035825..3f2ee51 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -22,6 +22,7 @@ #include "Components/Health.h" #include "Components/TankShell.h" #include "Components/SphereShape.h" +#include "Components/Listener.h" #include "Events/EnableCollisions.h" #include "Events/DisableCollisions.h" diff --git a/src/Systems/TransformSystem.cpp b/src/Systems/TransformSystem.cpp index 5823d12..7265b7a 100755 --- a/src/Systems/TransformSystem.cpp +++ b/src/Systems/TransformSystem.cpp @@ -24,7 +24,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI if(m_MoveItems.find(entity) != m_MoveItems.end()) { auto transform = m_World->GetComponent(entity); - + glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position); glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt; @@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI if(m_RotationItems.find(entity) != m_RotationItems.end()) { auto transform = m_World->GetComponent(entity); + auto absolutetransform = AbsoluteTransform(entity); float percentage = dt/m_RotationItems[entity].Time; m_RotationItems[entity].Time -= dt;