From a5105e5859f15588e269bc5d14f6450b5e90fe29 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 19:44:33 +0200 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 df32a3b07ddbd49180bf589e2e58c849827b2d0e Mon Sep 17 00:00:00 2001 From: Stiffly Date: Tue, 3 Jun 2014 21:02:39 +0200 Subject: [PATCH 4/6] 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 5/6] 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 9f1d5206bddfc0c05cb00bbe6c4d6aaf5e617fcd Mon Sep 17 00:00:00 2001 From: Stiffly Date: Wed, 4 Jun 2014 01:23:15 +0200 Subject: [PATCH 6/6] 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)