From 97994f9af7385f65bba2531893e09149efd7d4d0 Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Thu, 5 Jun 2014 06:42:19 +0200 Subject: [PATCH] Collisions --- assets | 2 +- src/GameWorld.cpp | 40 +++++++++++++++++++++++++++--- src/Systems/DamageSystem.cpp | 3 --- src/Systems/GameStateSystem.cpp | 2 +- src/Systems/ParticleSystem.cpp | 1 - src/Systems/PhysicsSystem.cpp | 1 - src/Systems/PhysicsSystem.h | 1 - src/Systems/TankSteeringSystem.cpp | 2 +- 8 files changed, 40 insertions(+), 12 deletions(-) diff --git a/assets b/assets index 8ab7df0..c44c64d 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8ab7df0d7fdb3bd0a1355192670c28826a860bb1 +Subproject commit c44c64df2b51139aaf4d0ba70c84ed4db868ef9f diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 893039d..e50594c 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -8,7 +8,15 @@ void GameWorld::Initialize() ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/Plane.obj"); ResourceManager->Preload("Model", "Models/Placeholders/PhysicsTest/ArrowCube.obj"); - //Background Music + ResourceManager->Preload("Model", "Models/Tank/TankCollisionShape.obj"); + ResourceManager->Preload("Model", "Models/Tank/tankBody.obj"); + ResourceManager->Preload("Model", "Models/Tank/tankTop.obj"); + ResourceManager->Preload("Model", "Models/Tank/tankBarrel.obj"); + ResourceManager->Preload("Model", "Models/Jeep/Chassi/Chassi.OBJ"); + ResourceManager->Preload("Model", "Models/Jeep/WheelFront/wheelFront.obj"); + ResourceManager->Preload("Model", "Models/Jeep/WheelBack/wheelBack.obj"); + + //Background Music { Events::PlayBGM e; e.Resource = "Sounds/SFX/WUB.mp3"; @@ -23,6 +31,10 @@ void GameWorld::Initialize() BindGamepadButton(Gamepad::Button::Right, "interface_horizontal", 1.f); BindKey(GLFW_KEY_W, "interface_vertical", 1.f); BindKey(GLFW_KEY_S, "interface_vertical", -1.f); + + BindKey(GLFW_KEY_W, "jeep_vertical", 1.f); + BindKey(GLFW_KEY_S, "jeep_vertical", -1.f); + BindGamepadAxis(Gamepad::Axis::LeftY, "interface_vertical", 1.f); BindGamepadButton(Gamepad::Button::Up, "interface_vertical", 1.f); BindGamepadButton(Gamepad::Button::Down, "interface_vertical", -1.f); @@ -869,6 +881,18 @@ void GameWorld::CreateTerrain() auto transform = AddComponent(decoration_middle); auto model = AddComponent(decoration_middle); model->ModelFile = "Models/TerrainFiveIstles/Decoration/Middle.obj"; + auto physics = AddComponent(decoration_middle); + physics->Mass = 1.f; + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + + { + auto shape = CreateEntity(decoration_middle); + auto transform = AddComponent(shape); + auto mesh = AddComponent(shape); + mesh->ResourceName = "Models/TerrainFiveIstles/Decoration/Middle.obj"; + CommitEntity(shape); + } + CommitEntity(decoration_middle); } @@ -1184,6 +1208,16 @@ void GameWorld::CreateBase(glm::quat orientation, int teamID) auto transform = AddComponent(decoration_base); auto model = AddComponent(decoration_base); model->ModelFile = "Models/TerrainFiveIstles/Decoration/Base.obj"; + auto physics = AddComponent(decoration_base); + physics->MotionType = Components::Physics::MotionTypeEnum::Fixed; + physics->Mass = 1.f; + { + auto shape = CreateEntity(decoration_base); + auto transform = AddComponent(shape); + auto mesh = AddComponent(shape); + mesh->ResourceName = "Models/TerrainFiveIstles/Decoration/BaseCollision.obj"; + CommitEntity(shape); + } CommitEntity(decoration_base); } @@ -1439,10 +1473,10 @@ EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat { auto shape = CreateEntity(elevator); auto transform = AddComponent(shape); - transform->Position = glm::vec3(0, 0, 0); + transform->Position = glm::vec3(0, -2, 0); auto box = AddComponent(shape); box->Width = 4.754f; - box->Height = 0.141f; + box->Height = 2.141f; box->Depth = 6.86f; CommitEntity(shape); } diff --git a/src/Systems/DamageSystem.cpp b/src/Systems/DamageSystem.cpp index 775b1bd..87770ba 100644 --- a/src/Systems/DamageSystem.cpp +++ b/src/Systems/DamageSystem.cpp @@ -25,8 +25,5 @@ bool Systems::DamageSystem::OnDamage( const Events::Damage &event ) e.Entity = event.Entity; EventBroker->Publish(e); } - - - LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount); return true; } \ No newline at end of file diff --git a/src/Systems/GameStateSystem.cpp b/src/Systems/GameStateSystem.cpp index 8812bd1..00f3d73 100644 --- a/src/Systems/GameStateSystem.cpp +++ b/src/Systems/GameStateSystem.cpp @@ -12,7 +12,7 @@ bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event) m_InGame = false; Events::GameOver e1; - e.Player = event.Player; + e1.Player = event.Player; EventBroker->Publish(e1); Events::PlayBGM e2; e2.Resource = "Sounds/BGM/WilliamTellOverture.mp3"; diff --git a/src/Systems/ParticleSystem.cpp b/src/Systems/ParticleSystem.cpp index e9e6c56..9546f06 100644 --- a/src/Systems/ParticleSystem.cpp +++ b/src/Systems/ParticleSystem.cpp @@ -239,7 +239,6 @@ void Systems::ParticleSystem::ScalarInterpolation(double timeProgress, std::vect bool Systems::ParticleSystem::CreateExplosion(const Events::CreateExplosion &e) { - LOG_INFO("Spawning an explosion"); auto explosion = m_World->CreateEntity(); auto emitter = m_World->AddComponent(explosion); emitter->LifeTime = e.LifeTime; diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index d87b1f6..b031c87 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -787,7 +787,6 @@ void Systems::PhysicsSystem::OnComponentRemoved(EntityID entity, std::string typ if(m_RigidBodies.find(entity) != m_RigidBodies.end()) { - LOG_INFO("Removed Trigger of entity %i", entity); m_PhysicsWorld->markForWrite(); m_RigidBodyEntities.erase(m_RigidBodies[entity]); m_PhysicsWorld->removeEntity(m_RigidBodies[entity]); diff --git a/src/Systems/PhysicsSystem.h b/src/Systems/PhysicsSystem.h index ccaba19..1adc355 100644 --- a/src/Systems/PhysicsSystem.h +++ b/src/Systems/PhysicsSystem.h @@ -112,7 +112,6 @@ public: e.Entity1 = entity1; e.Entity2 = entity2; m_PhysicsSystem->EventBroker->Publish(e); - LOG_INFO("CollisionEvent!"); } private: diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 28a5a24..d6ffaa3 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -509,7 +509,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) m_World->AddComponent(tank); m_World->AddComponent(tank); auto health = m_World->AddComponent(tank); - health->Amount = 1.f; + health->Amount = 200.f;