From a5105e5859f15588e269bc5d14f6450b5e90fe29 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 19:44:33 +0200 Subject: [PATCH 01/14] tank modifications --- src/Components/SoundEmitter.h | 3 ++- src/GameWorld.cpp | 6 ++++++ src/Systems/TankSteeringSystem.cpp | 12 ++++++++++++ src/Systems/TankSteeringSystem.h | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Components/SoundEmitter.h b/src/Components/SoundEmitter.h index cc9b738..e969fba 100755 --- a/src/Components/SoundEmitter.h +++ b/src/Components/SoundEmitter.h @@ -10,13 +10,14 @@ namespace Components struct SoundEmitter : Component { + enum class SoundType { SOUND_3D, SOUND_2D }; - SoundEmitter() : Gain(1.f), MaxDistance(1.f), MinDistance(1.f), Pitch(1.f), Loop(false) {} + SoundEmitter() : Gain(1.f), MaxDistance(10000.f), MinDistance(1.f), Pitch(1.f), Loop(false) {} float Gain; float MaxDistance; float MinDistance; diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 4faebb7..19af11a 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -653,6 +653,7 @@ EntityID GameWorld::CreateTank(int playerID) barrelSteering->ShotSpeed = 70.f; barrelSteering->LowerRotationLimit = glm::radians(-10.f); barrelSteering->UpperRotationLimit = glm::radians(40.f); + { auto shot = CreateEntity(barrel); auto transform = AddComponent(shot); @@ -660,6 +661,11 @@ EntityID GameWorld::CreateTank(int playerID) transform->Orientation = glm::angleAxis(-glm::pi() / 2.f, glm::vec3(1, 0, 0)); transform->Scale = glm::vec3(3.f); AddComponent(shot); + auto soundEmitter = AddComponent(shot); + soundEmitter->MinDistance = 1000; + soundEmitter->Gain = 1; + soundEmitter->Loop = false; + auto physics = AddComponent(shot); physics->Mass = 25.f; physics->Static = false; diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index a04dbc8..41f17c9 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -108,6 +108,18 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt; } + + auto shot = m_World->GetComponent(entity); + if(shot) + { + if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5) + { + Events::PlaySFX e; + e.Resource = "Sounds/SFX/LongBoom.wav"; + e.Emitter = entity; + EventBroker->Publish(e); + } + } } bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e ) diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index 8c996fa..a4ed5a9 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -29,6 +29,8 @@ #include "Components/TriggerExplosion.h" #include "Components/FrameTimer.h" +#include "Events/PlaySFX.h" + #include "Events/Damage.h" #include "Components/Vehicle.h" #include "Components/Player.h" From 5265fb97342d3e040ff3e57bec73b66f4d618370 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 19:46:48 +0200 Subject: [PATCH 02/14] assets commit --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 4a7b5c2..c61526f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4a7b5c236d0177881b62cda56cb97300a329a06c +Subproject commit c61526f5fc5caf2773d61296727ecea29df51a2c From 87b02711f4cd0b5a314b95d2532bc88f8853a335 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 20:05:31 +0200 Subject: [PATCH 03/14] Doppler scale ruined everything --- src/GameWorld.cpp | 2 +- src/Systems/SoundSystem.cpp | 2 +- src/Systems/TankSteeringSystem.cpp | 24 +++++++++++++----------- src/Systems/TankSteeringSystem.h | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 19af11a..57b8dc8 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -661,7 +661,7 @@ EntityID GameWorld::CreateTank(int playerID) transform->Orientation = glm::angleAxis(-glm::pi() / 2.f, glm::vec3(1, 0, 0)); transform->Scale = glm::vec3(3.f); AddComponent(shot); - auto soundEmitter = AddComponent(shot); + auto soundEmitter = AddComponent(tank); soundEmitter->MinDistance = 1000; soundEmitter->Gain = 1; soundEmitter->Loop = false; diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index 7e0333e..c95ac88 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -20,7 +20,7 @@ void Systems::SoundSystem::Initialize() { LOG_INFO("FMOD initialized successfully"); } - FMOD_System_Set3DSettings(m_System, 1.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale + FMOD_System_Set3DSettings(m_System, 0.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 41f17c9..2836e74 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -95,6 +95,11 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit EventBroker->Publish(eSetVelocity); m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0; + Events::PlaySFX e; + e.Resource = "Sounds/SFX/LongBoom.wav"; + e.Emitter = entity; + e.Loop = false; + EventBroker->Publish(e); auto clonePhysicsComponent = m_World->GetComponent(clone); //1,670m/s @@ -109,17 +114,14 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt; } - auto shot = m_World->GetComponent(entity); - if(shot) - { - if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5) - { - Events::PlaySFX e; - e.Resource = "Sounds/SFX/LongBoom.wav"; - e.Emitter = entity; - EventBroker->Publish(e); - } - } +// auto shot = m_World->GetComponent(entity); +// if(shot) +// { +// if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5) +// { +// +// } +// } } bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e ) diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index a4ed5a9..3c2f58e 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -30,6 +30,7 @@ #include "Components/FrameTimer.h" #include "Events/PlaySFX.h" +#include "Events/PlayBGM.h" #include "Events/Damage.h" #include "Components/Vehicle.h" From 80846a29ad0798739e06273b7355a24026a8e9ec Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 3 Jun 2014 20:36:23 +0200 Subject: [PATCH 04/14] Terrain creation stuff --- src/GameWorld.cpp | 584 +++++++++++++++------------------- src/GameWorld.h | 4 +- src/Systems/PhysicsSystem.cpp | 2 +- 3 files changed, 269 insertions(+), 321 deletions(-) diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 2708b2e..6fe9f89 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -91,322 +91,7 @@ void GameWorld::Initialize() EventBroker->Publish(e); } - { - auto road_base = CreateEntity(); - auto transform = AddComponent(road_base); - transform->Position = glm::vec3(0, -50, 0); - auto model = AddComponent(road_base); - model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; - auto physics = AddComponent(road_base); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(road_base); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; - - - CommitEntity(groundshape); - CommitEntity(road_base); - } - - { - auto road_middle = CreateEntity(); - auto transform = AddComponent(road_middle); - transform->Position = glm::vec3(0, -50, 0); - auto model = AddComponent(road_middle); - model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; - auto physics = AddComponent(road_middle); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(road_middle); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; - - - CommitEntity(groundshape); - CommitEntity(road_middle); - } - - { - auto road_small = CreateEntity(); - auto transform = AddComponent(road_small); - transform->Position = glm::vec3(0, -50, 0); - 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 water = CreateEntity(); - auto transform = AddComponent(water); - transform->Position = glm::vec3(0, -35, 0); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - transform->Scale = glm::vec3(5000.f, 10.f, 5000.f); - auto model = AddComponent(water); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; - auto blendmap = AddComponent(water); - blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureRepeats = 1.f; - - auto physics = AddComponent(water); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - { - - auto groundshape = CreateEntity(water); - auto box = AddComponent(groundshape); - box->Depth = 250.f; - box->Height = 5.f; - box->Width = 250.f; - - - CommitEntity(groundshape); - } - CommitEntity(water); - } - - { - auto ground_middle = CreateEntity(); - auto transform = AddComponent(ground_middle); - transform->Position = glm::vec3(0, -50, 0); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - auto model = AddComponent(ground_middle); - model->ModelFile = "Models/TerrainFiveIstles/Middle.obj"; - auto blendmap = AddComponent(ground_middle); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_middle); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_middle); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj"; - - - CommitEntity(groundshape); - CommitEntity(ground_middle); - } - - { - auto ground_small = CreateEntity(); - auto transform = AddComponent(ground_small); - transform->Position = glm::vec3(0, -50, 0); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - auto model = AddComponent(ground_small); - model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; - auto blendmap = AddComponent(ground_small); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_small); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_small); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; - - - CommitEntity(groundshape); - CommitEntity(ground_small); - } - - { - auto ground_small_mirrored = CreateEntity(); - auto transform = AddComponent(ground_small_mirrored); - transform->Position = glm::vec3(0, -50, 0); - transform->Orientation = glm::angleAxis(glm::radians(180.f), glm::vec3(0, 1, 0)); - auto model = AddComponent(ground_small_mirrored); - model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; - auto blendmap = AddComponent(ground_small_mirrored); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_small_mirrored); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_small_mirrored); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; - - - CommitEntity(groundshape); - CommitEntity(ground_small_mirrored); - } - - { - auto ground_base = CreateEntity(); - auto transform = AddComponent(ground_base); - transform->Position = glm::vec3(0, -50, 0); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - auto model = AddComponent(ground_base); - model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; - auto blendmap = AddComponent(ground_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"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - 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); - CommitEntity(ground_base); - } - - { - auto ground_base_mirrored = CreateEntity(); - auto transform = AddComponent(ground_base_mirrored); - transform->Position = glm::vec3(0, -50, 0); - transform->Orientation = glm::angleAxis(glm::radians(180.f), glm::vec3(0, 1, 0)); - auto model = AddComponent(ground_base_mirrored); - model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; - auto blendmap = AddComponent(ground_base_mirrored); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_base_mirrored); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_base_mirrored); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj"; - - - CommitEntity(groundshape); - CommitEntity(ground_base_mirrored); - } - - { - auto tree = CreateEntity(); - auto transform = AddComponent(tree); - transform->Position = glm::vec3(0, -10, 0); - - auto physics = AddComponent(tree); - physics->Mass = 100.f; - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionEvent = false; - //physics->LinearDamping = 3.f; - physics->CalculateCenterOfMass = true; - - { - auto stem = CreateEntity(tree); - auto transform = AddComponent(stem); - transform->Position = glm::vec3(0, -2.40906f, 0); - auto model = AddComponent(stem); - model->ModelFile = "Models/Tree/Stem/Stem.obj"; - } - - { - auto leafs = CreateEntity(tree); - auto transform = AddComponent(leafs); - transform->Position = glm::vec3(0, -2.45511f, 0); - auto model = AddComponent(leafs); - model->ModelFile = "Models/Tree/Leafs/Leafs.obj"; - model->Transparent = true; - CommitEntity(leafs); - } - - { - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0.f, 0.f, 0.f); - auto mesh = AddComponent(shape); - mesh->ResourceName = "Models/Tree/Collision/Collision.obj"; - - CommitEntity(shape); - } - - - /*{ - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - auto box = AddComponent(shape); - transform->Position = glm::vec3(0.f, 0, 0.f); - box->Width = 0.296f; - box->Height = 2.511f; - box->Depth = 0.296f; - - CommitEntity(shape); - } - - { - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - auto sphere = AddComponent(shape); - transform->Position = glm::vec3(0, 2.04506f, 0.f); - sphere->Radius = 1.389f; - - CommitEntity(shape); - }*/ - - CommitEntity(tree); - } + //CreateTerrain(); #pragma region Wall_Debris_Template @@ -616,7 +301,8 @@ void GameWorld::Initialize() EventBroker->Publish(e); }*/ - CreateGarage(glm::vec3(-3.93076, -49, 0), 1); + 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(); @@ -1104,11 +790,12 @@ EntityID GameWorld::CreateJeep(int playerID) return jeep; } -EntityID GameWorld::CreateGarage(glm::vec3 Position, int playerID) +EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int playerID) { auto garage = CreateEntity(); auto transform = AddComponent(garage); - transform->Position = Position; + transform->Position = position; + transform->Orientation = orientation; auto player = AddComponent(garage); player->ID = playerID; @@ -1273,4 +960,263 @@ EntityID GameWorld::CreateGarage(glm::vec3 Position, int playerID) } return garage; +} + +void GameWorld::CreateTerrain() +{ + { + auto road_middle = CreateEntity(); + auto transform = AddComponent(road_middle); + auto model = AddComponent(road_middle); + model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; + auto physics = AddComponent(road_middle); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(road_middle); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; + + + CommitEntity(groundshape); + CommitEntity(road_middle); + } + + + + { + /*auto water = CreateEntity(); + auto transform = AddComponent(water); + transform->Position = glm::vec3(0, -35, 0); + transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); + transform->Scale = glm::vec3(5000.f, 10.f, 5000.f); + auto model = AddComponent(water); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; + auto blendmap = AddComponent(water); + blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureRepeats = 1.f; + + auto physics = AddComponent(water); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + { + + auto groundshape = CreateEntity(water); + auto box = AddComponent(groundshape); + box->Depth = 250.f; + box->Height = 5.f; + box->Width = 250.f; + + + CommitEntity(groundshape); + } + CommitEntity(water);*/ + } + + { + auto ground_middle = CreateEntity(); + auto transform = AddComponent(ground_middle); + auto model = AddComponent(ground_middle); + model->ModelFile = "Models/TerrainFiveIstles/Middle.obj"; + auto blendmap = AddComponent(ground_middle); + blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; + blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; + blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; + blendmap->TextureRepeats = 30.f; + + auto physics = AddComponent(ground_middle); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(ground_middle); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj"; + + + CommitEntity(groundshape); + CommitEntity(ground_middle); + } + + CreateBase(glm::quat()); + CreateBase(glm::quat(glm::vec3(0, glm::pi()/2.f, 0))); + + { + auto tree = CreateEntity(); + auto transform = AddComponent(tree); + transform->Position = glm::vec3(0, -10, 0); + + auto physics = AddComponent(tree); + physics->Mass = 100.f; + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionEvent = false; + //physics->LinearDamping = 3.f; + physics->CalculateCenterOfMass = true; + + { + auto stem = CreateEntity(tree); + auto transform = AddComponent(stem); + transform->Position = glm::vec3(0, -2.40906f, 0); + auto model = AddComponent(stem); + model->ModelFile = "Models/Tree/Stem/Stem.obj"; + } + + { + auto leafs = CreateEntity(tree); + auto transform = AddComponent(leafs); + transform->Position = glm::vec3(0, -2.45511f, 0); + auto model = AddComponent(leafs); + model->ModelFile = "Models/Tree/Leafs/Leafs.obj"; + model->Transparent = true; + CommitEntity(leafs); + } + + { + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0.f, 0.f, 0.f); + auto mesh = AddComponent(shape); + mesh->ResourceName = "Models/Tree/Collision/Collision.obj"; + + CommitEntity(shape); + } + + + /*{ + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + auto box = AddComponent(shape); + transform->Position = glm::vec3(0.f, 0, 0.f); + box->Width = 0.296f; + box->Height = 2.511f; + box->Depth = 0.296f; + + CommitEntity(shape); + } + + { + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + auto sphere = AddComponent(shape); + transform->Position = glm::vec3(0, 2.04506f, 0.f); + sphere->Radius = 1.389f; + + CommitEntity(shape); + }*/ + + CommitEntity(tree); + } +} + +void GameWorld::CreateBase(glm::quat orientation) +{ + { + auto ground_small = CreateEntity(); + auto transform = AddComponent(ground_small); + transform->Orientation = orientation; + auto model = AddComponent(ground_small); + model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; + auto blendmap = AddComponent(ground_small); + blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; + blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; + blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; + blendmap->TextureRepeats = 30.f; + + auto physics = AddComponent(ground_small); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(ground_small); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; + CommitEntity(groundshape); + + CommitEntity(ground_small); + } + + { + auto ground_base = CreateEntity(); + auto transform = AddComponent(ground_base); + transform->Orientation = orientation; + auto model = AddComponent(ground_base); + model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; + auto blendmap = AddComponent(ground_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"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; + blendmap->TextureRepeats = 30.f; + + 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); + CommitEntity(ground_base); + } + + { + auto road_base = CreateEntity(); + 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); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(road_base); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; + + + CommitEntity(groundshape); + CommitEntity(road_base); + } + + { + 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); + 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); + } } \ No newline at end of file diff --git a/src/GameWorld.h b/src/GameWorld.h index 52bdb91..66dde65 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -82,7 +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, int playerID); + EntityID CreateGarage(glm::vec3 Position, glm::quat orientation, int playerID); + void CreateTerrain(); + void CreateBase(glm::quat orientation); std::vector m_WallDebrisTemplates; }; diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index cba6c39..465e498 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -80,7 +80,7 @@ void Systems::PhysicsSystem::Initialize() worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY; // You must specify the size of the broad phase - objects should not be simulated outside this region - worldInfo.setBroadPhaseWorldSize(500.0f); + worldInfo.setBroadPhaseWorldSize(1000.0f); m_PhysicsWorld = new hkpWorld(worldInfo); // When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks From 0addc672b42aa2184559d33530aea7c5d675c614 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 3 Jun 2014 20:36:35 +0200 Subject: [PATCH 05/14] Multiple vehicle selection --- src/GUI/GameFrame.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/GUI/GameFrame.h b/src/GUI/GameFrame.h index c09239f..b0d446a 100644 --- a/src/GUI/GameFrame.h +++ b/src/GUI/GameFrame.h @@ -26,12 +26,14 @@ public: vp1->X = 0; vp1->Width = this->Width / 2.f; //new PlayerHUD(vp1, "PlayerHUD", m_World, 1); - auto vehicleSelection = new VehicleSelection(vp1, "VehicleSelection", m_World, 1); + new VehicleSelection(vp1, "VehicleSelection", m_World, 1); vp2 = new Viewport(worldFrame, "Viewport2", m_World); vp2->X = vp1->Right(); vp2->Width = this->Width / 2.f; //new PlayerHUD(vp2, "PlayerHUD", m_World, 2); + new VehicleSelection(vp2, "VehicleSelection", m_World, 2); + m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World); m_FreeCamViewport->Hide(); From df32a3b07ddbd49180bf589e2e58c849827b2d0e Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 21:02:39 +0200 Subject: [PATCH 06/14] PlaySFX now uses Position instead of Emitter ID for playing a sound. --- src/Events/PlaySFX.h | 11 ++++++++- src/Systems/DebugSystem.cpp | 2 +- src/Systems/SoundSystem.cpp | 37 +++++++++++++++--------------- src/Systems/TankSteeringSystem.cpp | 2 +- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/Events/PlaySFX.h b/src/Events/PlaySFX.h index e96f8cf..4df4ce3 100644 --- a/src/Events/PlaySFX.h +++ b/src/Events/PlaySFX.h @@ -9,8 +9,17 @@ namespace Events struct PlaySFX : Event { - EntityID Emitter; + PlaySFX() : + MinDistance(100.f), + MaxDistance(10000.f), + Volume(1.f), + Loop (false) {} + //EntityID Emitter; + glm::vec3 Position; std::string Resource; + float MinDistance; + float MaxDistance; + float Volume; bool Loop; }; diff --git a/src/Systems/DebugSystem.cpp b/src/Systems/DebugSystem.cpp index b8d6d28..ed4c0aa 100644 --- a/src/Systems/DebugSystem.cpp +++ b/src/Systems/DebugSystem.cpp @@ -20,7 +20,7 @@ bool Systems::DebugSystem::OnKeyDown(const Events::KeyDown &event) if (event.KeyCode == GLFW_KEY_ENTER) { Events::PlaySFX e; - e.Emitter = 0; + e.Position = glm::vec3(0); e.Resource = "Sounds/korvring.wav"; EventBroker->Publish(e); diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index c95ac88..b66d5d4 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -128,27 +128,28 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) { - auto emitter = m_World->GetComponent(event.Emitter); - if(!emitter) - { - LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter]; - return false; - } +// auto emitter = m_World->GetComponent(event.Emitter); +// if(!emitter) +// { +// LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter]; +// return false; +// } + + auto eEntity = m_World->CreateEntity(); + auto eTransform = m_World->AddComponent(eEntity); + eTransform->Position = event.Position; + auto eComponent = m_World->AddComponent(eEntity); + eComponent->MinDistance = event.MinDistance; + eComponent->MaxDistance= event.MaxDistance; + eComponent->Loop = event.Loop; + eComponent->Gain = event.Volume; - emitter->type = Components::SoundEmitter::SoundType::SOUND_3D; + eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = ResourceManager->Load("Sound3D", event.Resource); - m_Sounds[event.Emitter] = *sound; - FMOD_Sound_Set3DMinMaxDistance(*sound, emitter->MinDistance, emitter->MaxDistance); + m_Sounds[eEntity] = *sound; + FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance); - PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop); - FMOD_System_Update(m_System); - - FMOD_BOOL isPlaying = false; - FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying); - if(!isPlaying) - LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str()); - else - LOG_INFO("Now playing sound %s", event.Resource.c_str()); + PlaySound(&m_Channels[eEntity], m_Sounds[eEntity], 1.0, eComponent->Loop); return true; } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 43fcc17..429be74 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -98,7 +98,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit Events::PlaySFX e; e.Resource = "Sounds/SFX/LongBoom.wav"; - e.Emitter = entity; + e.Position = absoluteTransform.Position; e.Loop = false; EventBroker->Publish(e); From 909ee94e2631adf91903247c7522fb96300a4959 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 23:48:13 +0200 Subject: [PATCH 07/14] Billboarding working again --- assets | 2 +- src/GameWorld.cpp | 4 +-- src/Renderer.cpp | 15 ++++++++++- src/Systems/SoundSystem.cpp | 40 ++++++++++++++++-------------- src/Systems/SoundSystem.h | 2 +- src/Systems/TankSteeringSystem.cpp | 9 ++++++- 6 files changed, 48 insertions(+), 24 deletions(-) diff --git a/assets b/assets index c61526f..588da9c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c61526f5fc5caf2773d61296727ecea29df51a2c +Subproject commit 588da9ca0d0e6a3dd08f4373e03468f79082b359 diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 2708b2e..698e6f6 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -590,7 +590,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); @@ -616,7 +616,7 @@ void GameWorld::Initialize() EventBroker->Publish(e); }*/ - CreateGarage(glm::vec3(-3.93076, -49, 0), 1); + CreateGarage(glm::vec3(-3.93076, 0, 0), 1); { auto flag = CreateEntity(); diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 480e3dd..fd0eca3 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -531,7 +531,20 @@ void Renderer::ForwardRendering(RenderQueue &rq) if (spriteJob) { glm::mat4 modelMatrix = spriteJob->ModelMatrix; - MVP = cameraMatrix * modelMatrix; + MVP = cameraMatrix * modelMatrix * glm::inverse(glm::toMat4(glm::inverse(m_Camera->Orientation()))); + + + //auto spriteComponent = m_World->GetComponent(entity); + //if (transformComponent && spriteComponent) + //{ + // //TEMP + // Texture* texture = m_World->ResourceManager->Load("Texture", spriteComponent->SpriteFile); + // //glBindTexture(GL_TEXTURE_2D, texture); + // auto transform = m_World->GetComponent(spriteComponent->Entity); + // glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(transform->Orientation).z, glm::vec3(0, 0, -1)); + // m_Renderer->AddTextureToDraw(texture, transform->Position, orientation2D, transform->Scale); + //} + glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP))); glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4(modelMatrix))); diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index b66d5d4..5dd446b 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -44,20 +44,31 @@ void Systems::SoundSystem::Update(double dt) std::map::iterator it; for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();) { - FMOD_BOOL *isPlaying = false; - FMOD_Channel_IsPlaying(it->second, isPlaying); + FMOD_BOOL isPlaying = false; + FMOD_Channel_IsPlaying(it->second, &isPlaying); if(isPlaying) { it++; } else { - FMOD_Sound_Release(m_DeleteSounds[it->first]); - m_DeleteSounds.erase(it->first); +// FMOD_Sound_Release(m_DeleteSounds[it->first]); +// m_DeleteSounds.erase(it->first); it = m_DeleteChannels.erase(it); } } + //LOG_INFO("Antal emitters i listan: %i", m_Channels.size()); + for (auto channel : m_Channels) + { + FMOD_BOOL isPlaying = false; + FMOD_Channel_IsPlaying(channel.second, &isPlaying); + if(!isPlaying) + { + m_Channels.erase(channel.first); + } + } + } void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) @@ -86,7 +97,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par if(emitter) { FMOD_CHANNEL* channel = m_Channels[entity]; - FMOD_SOUND* sound = m_Sounds[entity]; + //FMOD_SOUND* sound = m_Sounds[entity]; auto eTransform = m_World->GetComponent(entity); glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity); @@ -121,20 +132,13 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev float pitch = emitter->Pitch; //LoadSound(sound, path, maxDist, minDist); m_Channels.insert(std::make_pair(emitter->Entity, channel)); - m_Sounds.insert(std::make_pair(emitter->Entity, sound)); +// m_Sounds.insert(std::make_pair(emitter->Entity, sound)); } return true; } bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) { -// auto emitter = m_World->GetComponent(event.Emitter); -// if(!emitter) -// { -// LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter]; -// return false; -// } - auto eEntity = m_World->CreateEntity(); auto eTransform = m_World->AddComponent(eEntity); eTransform->Position = event.Position; @@ -146,10 +150,10 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event) eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = ResourceManager->Load("Sound3D", event.Resource); - m_Sounds[eEntity] = *sound; + //m_Sounds[eEntity] = *sound; FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance); - PlaySound(&m_Channels[eEntity], m_Sounds[eEntity], 1.0, eComponent->Loop); + PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop); return true; } @@ -161,7 +165,7 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event) m_Channels[emitter] = m_BGMChannel; eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D; Sound* sound = ResourceManager->Load("Sound2D", event.Resource); - m_Sounds[emitter] = *sound; + //m_Sounds[emitter] = *sound; FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]); return true; @@ -200,8 +204,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type, if(emitter) { m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity])); - m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity])); + //m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity])); m_Channels.erase(entity); - m_Sounds.erase(entity); + //m_Sounds.erase(entity); } } \ No newline at end of file diff --git a/src/Systems/SoundSystem.h b/src/Systems/SoundSystem.h index 3f0b426..66ef6bc 100755 --- a/src/Systems/SoundSystem.h +++ b/src/Systems/SoundSystem.h @@ -52,7 +52,7 @@ private: std::vector m_Listeners; std::map m_Channels; std::map m_DeleteChannels; - std::map m_Sounds; + //std::map m_Sounds; std::map m_DeleteSounds; std::shared_ptr m_TransformSystem; diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 429be74..4034939 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -97,7 +97,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0; Events::PlaySFX e; - e.Resource = "Sounds/SFX/LongBoom.wav"; + e.Resource = "Sounds/SFX/TankShot.mp3"; e.Position = absoluteTransform.Position; e.Loop = false; EventBroker->Publish(e); @@ -193,6 +193,13 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) e.Color = glm::vec4(2, 2, 2, 0.2); 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) { From ac855f554b3f569d65b8053b823f3546e8e5fb7c Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Wed, 4 Jun 2014 00:45:43 +0200 Subject: [PATCH 08/14] Fixed local physics orientation --- assets | 2 +- src/GameWorld.cpp | 11 ++++++----- src/Systems/PhysicsSystem.cpp | 30 ++++++++++++++++++++++++++---- src/Systems/TransformSystem.cpp | 3 ++- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/assets b/assets index 75977fd..588da9c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 75977fd865557478a72053a93f08f10851838730 +Subproject commit 588da9ca0d0e6a3dd08f4373e03468f79082b359 diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 6fe9f89..ed130c7 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 @@ -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(); @@ -866,7 +865,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int 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->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1)); rotate->Time = 5.f; { auto shape = CreateEntity(rightHatch); @@ -1048,7 +1047,7 @@ void GameWorld::CreateTerrain() } CreateBase(glm::quat()); - CreateBase(glm::quat(glm::vec3(0, glm::pi()/2.f, 0))); + CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0))); { auto tree = CreateEntity(); @@ -1219,4 +1218,6 @@ void GameWorld::CreateBase(glm::quat orientation) CommitEntity(groundshape); CommitEntity(road_small); } + + CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi(), 0)), 1); // glm::vec3(0, glm::pi()/2.f, 0) } \ No newline at end of file diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 465e498..1e8e2dd 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 = absoluteTransformParent.Orientation * glm::inverse(transformComponent->Orientation); } } 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; From 397188b8557bb344be615e8a37856bf96405318d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 00:46:03 +0200 Subject: [PATCH 09/14] Fixed frame scissor test --- src/GUI/Frame.h | 4 ++++ src/Renderer.cpp | 1 + 2 files changed, 5 insertions(+) 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/Renderer.cpp b/src/Renderer.cpp index 480e3dd..381fde0 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); From 9f1d5206bddfc0c05cb00bbe6c4d6aaf5e617fcd Mon Sep 17 00:00:00 2001 From: Stiffly Date: Wed, 4 Jun 2014 01:23:15 +0200 Subject: [PATCH 10/14] Muzzle Flash --- assets | 2 +- src/Renderer.cpp | 16 ++-------- src/Systems/TankSteeringSystem.cpp | 51 ++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/assets b/assets index 588da9c..78ba667 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 588da9ca0d0e6a3dd08f4373e03468f79082b359 +Subproject commit 78ba667b37a553c8387bc2717032c284dbd14aa9 diff --git a/src/Renderer.cpp b/src/Renderer.cpp index fd0eca3..933780b 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -531,21 +531,9 @@ void Renderer::ForwardRendering(RenderQueue &rq) if (spriteJob) { glm::mat4 modelMatrix = spriteJob->ModelMatrix; - MVP = cameraMatrix * modelMatrix * glm::inverse(glm::toMat4(glm::inverse(m_Camera->Orientation()))); + glm::mat4 billboardingMatrix = glm::inverse(glm::toMat4(glm::inverse(m_Camera->Orientation()))); + MVP = cameraMatrix * modelMatrix * billboardingMatrix; - - //auto spriteComponent = m_World->GetComponent(entity); - //if (transformComponent && spriteComponent) - //{ - // //TEMP - // Texture* texture = m_World->ResourceManager->Load("Texture", spriteComponent->SpriteFile); - // //glBindTexture(GL_TEXTURE_2D, texture); - // auto transform = m_World->GetComponent(spriteComponent->Entity); - // glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(transform->Orientation).z, glm::vec3(0, 0, -1)); - // m_Renderer->AddTextureToDraw(texture, transform->Position, orientation2D, transform->Scale); - //} - - glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP))); glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4(modelMatrix))); glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4(m_Camera->ViewMatrix()))); diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 4034939..e6f301c 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -90,17 +90,48 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit auto cloneTransform = m_World->GetComponent(clone); cloneTransform->Position = templateAbsoluteTransform.Position; cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation; + Events::SetVelocity eSetVelocity; eSetVelocity.Entity = clone; eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed); EventBroker->Publish(eSetVelocity); m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0; - Events::PlaySFX e; - e.Resource = "Sounds/SFX/TankShot.mp3"; - e.Position = absoluteTransform.Position; - e.Loop = false; - EventBroker->Publish(e); + { + Events::CreateExplosion e; + e.LifeTime = 1.5; + e.ParticleScale.push_back(0.6); + e.ParticleScale.push_back(1.8); + e.ParticlesToSpawn = 5; + e.Position = cloneTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); + e.Speed = 1.7; + e.SpreadAngle = glm::pi()/10; + e.spritePath = "Textures/Sprites/Smoke1.png"; + e.Color = glm::vec4(0.6,0.6,0.6,1); + EventBroker->Publish(e); + } + { + Events::CreateExplosion e; + e.LifeTime = 0.2; + e.ParticleScale.push_back(1); + //e.ParticleScale.push_back(2); + e.ParticlesToSpawn = 1; + e.Position = cloneTransform->Position; + e.Speed = 0; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/MuzzleFlash.png"; + e.Color = glm::vec4(2, 2, 2, 0.2); + EventBroker->Publish(e); + } + + { +// Events::PlaySFX e; +// e.Resource = "Sounds/SFX/TankShot.mp3"; +// e.Position = absoluteTransform.Position; +// e.Loop = false; +// EventBroker->Publish(e); + } auto clonePhysicsComponent = m_World->GetComponent(clone); //1,670m/s @@ -194,11 +225,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) From e11f656b3d9b781e20276ba6f80aaa2f15512f0e Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 04:18:44 +0200 Subject: [PATCH 11/14] Fixed physics relative orientations! --- assets | 2 +- src/Components/SpawnPoint.h | 2 + src/GameWorld.cpp | 555 +++++++++++++++-------------- src/GameWorld.h | 4 +- src/Systems/PhysicsSystem.cpp | 2 +- src/Systems/TankSteeringSystem.cpp | 8 +- 6 files changed, 298 insertions(+), 275 deletions(-) diff --git a/assets b/assets index 588da9c..cc30e5f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 588da9ca0d0e6a3dd08f4373e03468f79082b359 +Subproject commit cc30e5fb5c32068ef973a15d0142899c0d3b9cf4 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/GameWorld.cpp b/src/GameWorld.cpp index ed130c7..a7b15bd 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -789,14 +789,295 @@ EntityID GameWorld::CreateJeep(int playerID) return jeep; } -EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int playerID) +void GameWorld::CreateTerrain() { - auto garage = CreateEntity(); - auto transform = AddComponent(garage); - transform->Position = position; + { + auto road_middle = CreateEntity(); + auto transform = AddComponent(road_middle); + auto model = AddComponent(road_middle); + model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; + auto physics = AddComponent(road_middle); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(road_middle); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; + + + CommitEntity(groundshape); + CommitEntity(road_middle); + } + + + + { + /*auto water = CreateEntity(); + auto transform = AddComponent(water); + transform->Position = glm::vec3(0, -35, 0); + transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); + transform->Scale = glm::vec3(5000.f, 10.f, 5000.f); + auto model = AddComponent(water); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; + auto blendmap = AddComponent(water); + blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg"; + blendmap->TextureRepeats = 1.f; + + auto physics = AddComponent(water); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + { + + auto groundshape = CreateEntity(water); + auto box = AddComponent(groundshape); + box->Depth = 250.f; + box->Height = 5.f; + box->Width = 250.f; + + + CommitEntity(groundshape); + } + CommitEntity(water);*/ + } + + { + auto ground_middle = CreateEntity(); + auto transform = AddComponent(ground_middle); + auto model = AddComponent(ground_middle); + model->ModelFile = "Models/TerrainFiveIstles/Middle.obj"; + auto blendmap = AddComponent(ground_middle); + blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; + blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; + blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; + blendmap->TextureRepeats = 30.f; + + auto physics = AddComponent(ground_middle); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(ground_middle); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj"; + + + CommitEntity(groundshape); + CommitEntity(ground_middle); + } + + CreateBase(glm::quat(), 1); + CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0)), 2); + + { + auto tree = CreateEntity(); + auto transform = AddComponent(tree); + transform->Position = glm::vec3(0, -10, 0); + + auto physics = AddComponent(tree); + physics->Mass = 100.f; + physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; + physics->CollisionEvent = false; + //physics->LinearDamping = 3.f; + physics->CalculateCenterOfMass = true; + + { + auto stem = CreateEntity(tree); + auto transform = AddComponent(stem); + transform->Position = glm::vec3(0, -2.40906f, 0); + auto model = AddComponent(stem); + model->ModelFile = "Models/Tree/Stem/Stem.obj"; + } + + { + auto leafs = CreateEntity(tree); + auto transform = AddComponent(leafs); + transform->Position = glm::vec3(0, -2.45511f, 0); + auto model = AddComponent(leafs); + model->ModelFile = "Models/Tree/Leafs/Leafs.obj"; + model->Transparent = true; + CommitEntity(leafs); + } + + { + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0.f, 0.f, 0.f); + auto mesh = AddComponent(shape); + mesh->ResourceName = "Models/Tree/Collision/Collision.obj"; + + CommitEntity(shape); + } + + + /*{ + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + auto box = AddComponent(shape); + transform->Position = glm::vec3(0.f, 0, 0.f); + box->Width = 0.296f; + box->Height = 2.511f; + box->Depth = 0.296f; + + CommitEntity(shape); + } + + { + auto shape = CreateEntity(tree); + auto transform = AddComponent(shape); + auto sphere = AddComponent(shape); + transform->Position = glm::vec3(0, 2.04506f, 0.f); + sphere->Radius = 1.389f; + + CommitEntity(shape); + }*/ + + CommitEntity(tree); + } +} + +void GameWorld::CreateBase(glm::quat orientation, int playerID) +{ + auto base = CreateEntity(); + auto transform = AddComponent(base); transform->Orientation = orientation; - auto player = AddComponent(garage); - player->ID = playerID; + + { + auto ground_small = CreateEntity(base); + auto transform = AddComponent(ground_small); + auto model = AddComponent(ground_small); + model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; + auto blendmap = AddComponent(ground_small); + blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; + blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; + blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; + blendmap->TextureRepeats = 30.f; + + auto physics = AddComponent(ground_small); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(ground_small); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; + CommitEntity(groundshape); + + CommitEntity(ground_small); + } + + { + 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 terrain_base = CreateEntity(base); + auto transform = AddComponent(terrain_base); + auto model = AddComponent(terrain_base); + model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; + 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"; + blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; + blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; + 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 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(base); + auto transform = AddComponent(road_base); + auto model = AddComponent(road_base); + model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; + auto physics = AddComponent(road_base); + physics->Mass = 10; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->CollisionLayer = 1; + + auto groundshape = CreateEntity(road_base); + auto transformshape = AddComponent(groundshape); + auto meshShape = AddComponent(groundshape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; + + + CommitEntity(groundshape); + CommitEntity(road_base); + } + + 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); { @@ -909,6 +1190,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int auto transform = AddComponent(spawnPoint); transform->Position.y = 1.f; auto spawnPointComponent = AddComponent(spawnPoint); + spawnPointComponent->Player = player; } CommitEntity(spawnPoint); } @@ -960,264 +1242,3 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int return garage; } - -void GameWorld::CreateTerrain() -{ - { - auto road_middle = CreateEntity(); - auto transform = AddComponent(road_middle); - auto model = AddComponent(road_middle); - model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; - auto physics = AddComponent(road_middle); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(road_middle); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj"; - - - CommitEntity(groundshape); - CommitEntity(road_middle); - } - - - - { - /*auto water = CreateEntity(); - auto transform = AddComponent(water); - transform->Position = glm::vec3(0, -35, 0); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - transform->Scale = glm::vec3(5000.f, 10.f, 5000.f); - auto model = AddComponent(water); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; - auto blendmap = AddComponent(water); - blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg"; - blendmap->TextureRepeats = 1.f; - - auto physics = AddComponent(water); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - { - - auto groundshape = CreateEntity(water); - auto box = AddComponent(groundshape); - box->Depth = 250.f; - box->Height = 5.f; - box->Width = 250.f; - - - CommitEntity(groundshape); - } - CommitEntity(water);*/ - } - - { - auto ground_middle = CreateEntity(); - auto transform = AddComponent(ground_middle); - auto model = AddComponent(ground_middle); - model->ModelFile = "Models/TerrainFiveIstles/Middle.obj"; - auto blendmap = AddComponent(ground_middle); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_middle); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_middle); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj"; - - - CommitEntity(groundshape); - CommitEntity(ground_middle); - } - - CreateBase(glm::quat()); - CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0))); - - { - auto tree = CreateEntity(); - auto transform = AddComponent(tree); - transform->Position = glm::vec3(0, -10, 0); - - auto physics = AddComponent(tree); - physics->Mass = 100.f; - physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed; - physics->CollisionEvent = false; - //physics->LinearDamping = 3.f; - physics->CalculateCenterOfMass = true; - - { - auto stem = CreateEntity(tree); - auto transform = AddComponent(stem); - transform->Position = glm::vec3(0, -2.40906f, 0); - auto model = AddComponent(stem); - model->ModelFile = "Models/Tree/Stem/Stem.obj"; - } - - { - auto leafs = CreateEntity(tree); - auto transform = AddComponent(leafs); - transform->Position = glm::vec3(0, -2.45511f, 0); - auto model = AddComponent(leafs); - model->ModelFile = "Models/Tree/Leafs/Leafs.obj"; - model->Transparent = true; - CommitEntity(leafs); - } - - { - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0.f, 0.f, 0.f); - auto mesh = AddComponent(shape); - mesh->ResourceName = "Models/Tree/Collision/Collision.obj"; - - CommitEntity(shape); - } - - - /*{ - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - auto box = AddComponent(shape); - transform->Position = glm::vec3(0.f, 0, 0.f); - box->Width = 0.296f; - box->Height = 2.511f; - box->Depth = 0.296f; - - CommitEntity(shape); - } - - { - auto shape = CreateEntity(tree); - auto transform = AddComponent(shape); - auto sphere = AddComponent(shape); - transform->Position = glm::vec3(0, 2.04506f, 0.f); - sphere->Radius = 1.389f; - - CommitEntity(shape); - }*/ - - CommitEntity(tree); - } -} - -void GameWorld::CreateBase(glm::quat orientation) -{ - { - auto ground_small = CreateEntity(); - auto transform = AddComponent(ground_small); - transform->Orientation = orientation; - auto model = AddComponent(ground_small); - model->ModelFile = "Models/TerrainFiveIstles/Small.obj"; - auto blendmap = AddComponent(ground_small); - blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg"; - blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png"; - blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - auto physics = AddComponent(ground_small); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(ground_small); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj"; - CommitEntity(groundshape); - - CommitEntity(ground_small); - } - - { - auto ground_base = CreateEntity(); - auto transform = AddComponent(ground_base); - transform->Orientation = orientation; - auto model = AddComponent(ground_base); - model->ModelFile = "Models/TerrainFiveIstles/Base.obj"; - auto blendmap = AddComponent(ground_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"; - blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png"; - blendmap->TextureBlue = "Textures/Ground/Cliffs2.png"; - blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png"; - blendmap->TextureRepeats = 30.f; - - 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); - CommitEntity(ground_base); - } - - { - auto road_base = CreateEntity(); - 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); - physics->Mass = 10; - physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; - physics->CollisionLayer = 1; - - auto groundshape = CreateEntity(road_base); - auto transformshape = AddComponent(groundshape); - auto meshShape = AddComponent(groundshape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj"; - - - CommitEntity(groundshape); - CommitEntity(road_base); - } - - { - 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); - 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); - } - - CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi(), 0)), 1); // glm::vec3(0, glm::pi()/2.f, 0) -} \ No newline at end of file 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/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 1e8e2dd..3db178b 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -300,7 +300,7 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p auto absoluteTransformParent = m_World->GetSystem()->AbsoluteTransform(parent); transformComponent->Position -= absoluteTransformParent.Position; transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation; - transformComponent->Orientation = absoluteTransformParent.Orientation * glm::inverse(transformComponent->Orientation); + transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation; } } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index e140f49..4bd4c91 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -300,11 +300,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; From 7f017bfaed19c9510a42c53ccdb79450ef4ee76e Mon Sep 17 00:00:00 2001 From: Stiffly Date: Wed, 4 Jun 2014 04:40:16 +0200 Subject: [PATCH 12/14] Tanks now have listeners. --- assets | 2 +- src/Systems/TankSteeringSystem.cpp | 21 +++++++++++---------- src/Systems/TankSteeringSystem.h | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/assets b/assets index 78ba667..a6e3f12 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 78ba667b37a553c8387bc2717032c284dbd14aa9 +Subproject commit a6e3f120fd90e4c2c3983cf0098bb9c3ebdc4b39 diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 88d05a3..312eafc 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -126,11 +126,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); @@ -225,11 +225,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) @@ -399,6 +399,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" From 3c17ab603772149c997ad03ddf498513fe003f2d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 05:12:06 +0200 Subject: [PATCH 13/14] Bridges --- assets | 2 +- src/GameWorld.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) 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/GameWorld.cpp b/src/GameWorld.cpp index a7b15bd..4f3d9fd 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -998,6 +998,26 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) 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); @@ -1066,6 +1086,26 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) CommitEntity(road_base); } + { + 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 shape = CreateEntity(bridge_base); + auto transformshape = AddComponent(shape); + auto meshShape = AddComponent(shape); + meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj"; + CommitEntity(shape); + } + CommitEntity(bridge_base); + } + 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) From 62dd85349f2e336744ae5a422be8ed8c329260f6 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 05:47:29 +0200 Subject: [PATCH 14/14] A gate and better bridges. --- assets | 2 +- src/GameWorld.cpp | 61 +++++++++++++++++++++++++---------------------- src/GameWorld.h | 2 +- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/assets b/assets index 637f866..c2ee1b0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 637f866e2d220a1c063f7de2d9f64863643d686f +Subproject commit c2ee1b0198931f1fc62f07533aa5d25dfa86ecc8 diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 4f3d9fd..acf8db1 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -513,12 +513,15 @@ void GameWorld::BindGamepadButton(Gamepad::Button button, std::string command, f EventBroker->Publish(e); } -void GameWorld::CreateGate(glm::vec3 Position) +void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation) { + auto gateParent = CreateEntity(parent); + auto transform = AddComponent(gateParent); + transform->Position = position; + transform->Orientation = orientation; { - auto gateBase = CreateEntity(); + auto gateBase = CreateEntity(gateParent); auto transform = AddComponent(gateBase); - transform->Position = Position; auto model = AddComponent(gateBase); model->ModelFile = "Models/Gate/Lift/Lift.obj"; auto physics = AddComponent(gateBase); @@ -577,10 +580,9 @@ void GameWorld::CreateGate(glm::vec3 Position) CommitEntity(gateBase); } + auto gate = CreateEntity(gateParent); { - auto gate = CreateEntity(); auto transform = AddComponent(gate); - transform->Position = Position; auto model = AddComponent(gate); model->ModelFile = "Models/Gate/Gate/Gate.obj"; auto physics = AddComponent(gate); @@ -588,8 +590,8 @@ void GameWorld::CreateGate(glm::vec3 Position) physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC; auto move = AddComponent(gate); move->Speed = 5.f; - move->GoalPosition = glm::vec3(Position.x, Position.y + 9.02345f, Position.z); - move->StartPosition = glm::vec3(Position.x, Position.y, Position.z); + move->GoalPosition = glm::vec3(0, 9.02345f, 0); + move->StartPosition = glm::vec3(0, 0, 0); { auto mainShape = CreateEntity(gate); auto transform = AddComponent(mainShape); @@ -611,29 +613,27 @@ void GameWorld::CreateGate(glm::vec3 Position) CommitEntity(lowerShape); } CommitEntity(gate); + } + + { + auto gateTrigger = CreateEntity(gateParent); + auto transform = AddComponent(gateTrigger); + transform->Position = glm::vec3(0, 2.8241, 0); + auto trigger = AddComponent(gateTrigger); + auto triggerMove = AddComponent(gateTrigger); + triggerMove->Entity = gate; { - auto gateTrigger = CreateEntity(); - auto transform = AddComponent(gateTrigger); - transform->Position = glm::vec3(Position.x, Position.y + 2.8241, Position.z); - auto trigger = AddComponent(gateTrigger); - auto triggerMove = AddComponent(gateTrigger); - triggerMove->Entity = gate; - - - { - auto shape = CreateEntity(gateTrigger); - auto transform = AddComponent(shape); - transform->Position = glm::vec3(0.f, 2.8241f, 0.f); - auto box = AddComponent(shape); - box->Width = 6.963f; - box->Height = 3.104f; - box->Depth = 10.356f; - CommitEntity(shape); - } - CommitEntity(gateTrigger); + auto shape = CreateEntity(gateTrigger); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(0.f, 2.8241f, 0.f); + auto box = AddComponent(shape); + box->Width = 6.963f; + box->Height = 3.104f; + box->Depth = 10.356f; + CommitEntity(shape); } - + CommitEntity(gateTrigger); } } @@ -949,7 +949,7 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) auto base = CreateEntity(); auto transform = AddComponent(base); transform->Orientation = orientation; - +#pragma region Terrain { auto ground_small = CreateEntity(base); auto transform = AddComponent(ground_small); @@ -1012,7 +1012,7 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) auto shape = CreateEntity(bridge_middle); auto transformshape = AddComponent(shape); auto meshShape = AddComponent(shape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj"; + meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridgeCollision.obj"; CommitEntity(shape); } CommitEntity(bridge_middle); @@ -1105,6 +1105,9 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) } CommitEntity(bridge_base); } +#pragma endregion Terrain + + CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), playerID); } diff --git a/src/GameWorld.h b/src/GameWorld.h index 20b3e98..15a4fd9 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -78,7 +78,7 @@ private: void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value); void BindGamepadButton(Gamepad::Button button, std::string command, float value); - void CreateGate(glm::vec3 Position); + void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation); void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering); EntityID CreateJeep(int playerID); EntityID CreateWall(glm::vec3 pos, glm::quat orientation);