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/mapwindow.cc | 6 ++++-- src/client/soundext.cc | 29 ++++++++++++++++++++++------- src/client/soundext.h | 2 -- src/client/targets.cc | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/client') diff --git a/src/client/mapwindow.cc b/src/client/mapwindow.cc index c8ebaa8..19cf687 100644 --- a/src/client/mapwindow.cc +++ b/src/client/mapwindow.cc @@ -238,8 +238,10 @@ void MapWindow::show_entity_info(const core::Entity *entity) mapwindow_modelview->set_colors(globe->color(), globe->color_second()); mapwindow_modelview->set_globetexturename( globe->texturename(), - globe->has_flag(core::Entity::Bright), - globe->coronaname() + globe->coronaname(), + globe->ringsname(), + globe->has_flag(core::Entity::Bright) + ); mapwindow_modelview->set_zoom(2.5f); if (globe->has_flag(core::Entity::Bright)) { 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++) { diff --git a/src/client/soundext.h b/src/client/soundext.h index cf5585e..2750afd 100644 --- a/src/client/soundext.h +++ b/src/client/soundext.h @@ -73,8 +73,6 @@ public: typedef std::list Sounds; private: - void clear(); - /// index of the audio buffer containing the thruster sound loop size_t state_thusterloopbuffer; /// index of the audio buffer containing the impulse sound loop diff --git a/src/client/targets.cc b/src/client/targets.cc index c76d621..6809939 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -341,7 +341,7 @@ void frame() core::Entity *entity = (*it); // render entity sound - if ((entity->type() == core::Entity::Controlable) || (entity->model() && entity->model()->sounds().size())) { + if ((entity->type() == core::Entity::Controlable) || (entity->type() == core::Entity::Projectile) || (entity->model() && entity->model()->sounds().size())) { render_entity_sound(entity); } -- cgit v1.2.3