From f416e6b792e5dda143f60b7a2724db6b3ec33d75 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 28 Dec 2012 22:55:35 +0000 Subject: Support for rendering globes with rings, removed hardcoded 'corona' prefix for corona textures, added support for projectile fire sounds. --- src/client/soundext.cc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/client/soundext.cc') diff --git a/src/client/soundext.cc b/src/client/soundext.cc index aeb3bd1..477919c 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -11,6 +11,7 @@ #include "auxiliary/functions.h" #include "core/gameinterface.h" #include "core/entity.h" +#include "core/entityprojectile.h" #include "client/soundext.h" #include "client/client.h" #include "render/camera.h" @@ -128,6 +129,18 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun state_engineloopsource = audio::Sources::get(); state_engineeventsource = audio::Sources::get(); + + + } else if (entity->type() == core::Entity::Projectile) { + core::EntityProjectile *projectile = static_cast(entity); + + state_engineeventsource = audio::Sources::get(); + if (state_engineeventsource) { + state_impulsestartbuffer = audio::Buffers::load("projectiles/" + projectile->projectile_soundname()); + + audio::update_source(state_engineeventsource, entity->location(), math::Vector3f()); + audio::play(state_engineeventsource, state_impulsestartbuffer); + } } // load model sounds @@ -151,11 +164,6 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun } SoundExt::~SoundExt() -{ - clear(); -} - -void SoundExt::clear() { for (Sounds::iterator it = state_soundlist.begin(); it != state_soundlist.end(); it++) { client::Sound *sound = *it; @@ -193,11 +201,11 @@ void SoundExt::frame(float elapsed) float pitch = 1.0f; float gain = 0.0; - float r = (entity()->model() ? entity()->model()->box().max().x() * entity()->radius() / entity()->model()->radius() : entity()->radius()); - + float r = (entity()->model() ? entity()->model()->box().max().x() * entity()->radius() / entity()->model()->radius() : entity()->radius()); math::Vector3f velocity; if (entity()->type() == core::Entity::Controlable) { + // update engine sounds core::EntityControlable *entity = static_cast(this->entity()); speed = entity->speed(); @@ -271,6 +279,13 @@ void SoundExt::frame(float elapsed) audio::update_source(state_engineeventsource, entity->location() - entity->axis().forward() * r , velocity); + + } else if (entity()->type() == core::Entity::Projectile) { + + if (state_engineeventsource && !audio::Sources::is_playing(state_engineeventsource)) { + audio::Sources::remove(state_engineeventsource); + state_engineeventsource = 0; + } } for (Sounds::iterator it = state_soundlist.begin(); it != state_soundlist.end(); it++) { -- cgit v1.2.3