From c68a2899dc63850d77f79eaa65125f6d503fc83a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 17 Nov 2013 15:17:04 +0000 Subject: Added support for explosion sounds, updated list of attributions, updated starsystem roadmap. --- doc/attributions.html | 39 +++++++++++++++++++++++--- doc/starsystem_roadmap.html | 44 +++++++++++++++++------------ src/audio/audio.cc | 15 ++++++++++ src/audio/audio.h | 3 ++ src/client/soundext.cc | 67 +++++++++++++++++++++++++++++++-------------- src/client/soundext.h | 2 ++ 6 files changed, 128 insertions(+), 42 deletions(-) diff --git a/doc/attributions.html b/doc/attributions.html index 3330b2c..fe90294 100644 --- a/doc/attributions.html +++ b/doc/attributions.html @@ -70,6 +70,7 @@ +

Maps

@@ -388,6 +389,7 @@ +

Models

@@ -421,9 +423,18 @@ +

Sounds

+ + sounds/game + mount.wav + + doorslam2a.wav by The Berklee College of Music, + from the OLPC Free Sound Samples, edited by Ingar + + sounds/engines loop00.wav @@ -450,7 +461,8 @@ sounds/engines jump_start00.wav - juskiddink Freesound + Gliss FX 01.wav by Gregory Tripi, + from the OLPC Free Sound Samples, edited by Ingar @@ -488,8 +500,8 @@ sounds/projectiles metrion.wav - laser4.wav by Matt Lange, edited by Ingar - from the OLPC Free Sound Samples + laser4.wav by Matt Lange, + from the OLPC Free Sound Samples, edited by Ingar @@ -505,6 +517,7 @@ +

Textures

@@ -578,6 +591,15 @@ Duael Designs LLC & Robert Stein III + + textures/planets + dagon.png + + Golivani from + Boliverius Alvera Sagittarii by + kristoffer + + textures/planets finnmark.png @@ -621,7 +643,16 @@ Denirona from the Edin system by kikinho - + + + textures/planets + rasheen.png + + Moon2 from + Boliverius Alvera Sagittarii by + kristoffer + + textures/planets seymour.png diff --git a/doc/starsystem_roadmap.html b/doc/starsystem_roadmap.html index 9a3efac..cbf5e9c 100644 --- a/doc/starsystem_roadmap.html +++ b/doc/starsystem_roadmap.html @@ -106,15 +106,22 @@

Praetoria system

Carthagio system

Hellas system

- +

Phoenicia system

+ @@ -156,7 +163,7 @@ Planet Brogha is the largest exporter of agricultural products in the Independent Colonies.

@@ -165,15 +172,15 @@ Planet Antwerp is the headquarters of the Colonial Militia.

Kronenbaden system

Khorsand system

@@ -275,11 +282,10 @@

Camorra is a system claimed by pirates

- - +
@@ -296,16 +302,16 @@

Rinn system

Amiras system

- +

Tsu-Khan Empire

Kiana system

- +

Alpha Kosiya

@@ -328,9 +334,12 @@ @@ -347,7 +356,7 @@

- Copyright © 2007-2012 Project::OSiRiON + Copyright © 2007-2013 Project::OSiRiON

@@ -356,4 +365,3 @@ - diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 304174c..3f505c0 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -193,6 +193,21 @@ size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain) return buffer_index; } +size_t stop(size_t source_index) +{ + if (!audio_initialized) + return 0; + + ALuint source = Sources::source(source_index); + ALint srcstate = 0; + alGetSourcei(source , AL_SOURCE_STATE , &srcstate); + if (srcstate == AL_PLAYING) { + alSourceStop(source); + } + + return source_index; +} + size_t loop(size_t source_index, const char *name, float pitch, float gain) { if (!audio_initialized) diff --git a/src/audio/audio.h b/src/audio/audio.h index bab3402..f95e872 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -54,6 +54,9 @@ size_t loop(size_t source_index, const char *name, float pitch = 1.0f, float gai /// play a looping sound from a specified buffer on a specified source size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain); +/// stop playback of a specific source +size_t stop(size_t source_index); + /// update source parameters void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch = 1.0f, float gain = 1.0f); diff --git a/src/client/soundext.cc b/src/client/soundext.cc index ed22612..397a420 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -56,7 +56,7 @@ void render_entity_sound(core::Entity *entity) return; } - if (!ext_render(entity) || (ext_render(entity)->distance() > core::range::fxdistance) || (!ext_render(entity)->power())) { + if (!ext_render(entity) || (ext_render(entity)->distance() > core::range::fxdistance)) { if (ext_sound(entity)) delete ext_sound(entity); return; @@ -97,6 +97,7 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun state_impulsestopbuffer = 0; state_jumpstartbuffer = 0; state_jumpstopbuffer = 0; + state_explosionbuffer = 0; state_engineloopbuffer = 0; state_engineloopsource = 0; @@ -126,6 +127,8 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun state_impulsestopbuffer = audio::Buffers::load("engines/impulse_stop00"); state_jumpstartbuffer = audio::Buffers::load("engines/jump_start00"); state_jumpstopbuffer = audio::Buffers::load("engines/jump_stop00"); + + state_explosionbuffer = audio::Buffers::load("fx/explosion01"); state_engineloopsource = audio::Sources::get(); state_engineeventsource = audio::Sources::get(); @@ -192,6 +195,7 @@ SoundExt::~SoundExt() state_impulsestopbuffer = 0; state_jumpstartbuffer = 0; state_jumpstopbuffer = 0; + state_explosionbuffer = 0; state_engineloopbuffer = 0; state_engineloopsource = 0; @@ -211,52 +215,52 @@ void SoundExt::frame(float elapsed) if (entity()->type() == core::Entity::Controlable) { // update engine sounds - core::EntityControlable *entity = static_cast(this->entity()); + core::EntityControlable *controlable = static_cast(this->entity()); - speed = entity->speed(); + speed = controlable->speed(); if (snd_doppler->value()) - velocity.assign(entity->axis().forward() * speed); + velocity.assign(controlable->axis().forward() * speed); - if (entity->state() == core::Entity::Impulse) { + if (controlable->state() == core::Entity::Impulse) { pitch = 1.0f; gain = 1.0f; } else { - pitch = 0.2f + entity->thrust() * 0.8f; + pitch = 0.2f + controlable->thrust() * 0.8f; gain = 1.0f; } - if (entity->state() == core::Entity::ImpulseInitiate) { + if (controlable->state() == core::Entity::ImpulseInitiate) { if (state_engineeventbuffer != state_impulsestartbuffer) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * r , - entity->axis().forward() * speed); + controlable->location() - controlable->axis().forward() * r , + controlable->axis().forward() * speed); state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestartbuffer); } - } else if (entity->state() == core::Entity::JumpInitiate) { + } else if (controlable->state() == core::Entity::JumpInitiate) { if (state_engineeventbuffer != state_jumpstartbuffer) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * r , - entity->axis().forward() * speed); + controlable->location() - controlable->axis().forward() * r , + controlable->axis().forward() * speed); state_engineeventbuffer = audio::play(state_engineeventsource, state_jumpstartbuffer); } - } else if (entity->state() == core::Entity::Jump) { + } else if (controlable->state() == core::Entity::Jump) { if (state_engineeventbuffer != state_jumpstopbuffer) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * r , - entity->axis().forward() * speed); + controlable->location() - controlable->axis().forward() * r , + controlable->axis().forward() * speed); state_engineeventbuffer = audio::play(state_engineeventsource, state_jumpstopbuffer); } - } else if (entity->state() == core::Entity::Impulse) { + } else if (controlable->state() == core::Entity::Impulse) { state_engineeventbuffer = state_impulseloopbuffer; @@ -264,12 +268,35 @@ void SoundExt::frame(float elapsed) state_engineloopbuffer = audio::loop(state_engineloopsource, state_impulseloopbuffer, pitch, 0); } pitch = 1.0f; + + } else if (controlable->state() == core::Entity::Destroyed) { + + if (state_engineloopbuffer) { + audio::stop(state_engineloopbuffer); + state_engineloopbuffer = 0; + } + if (state_engineeventbuffer != state_explosionbuffer) { + audio::update_source(state_engineeventsource, + controlable->location() - controlable->axis().forward() * r , + controlable->axis().forward() * speed); + + // pack random explosion sound + if (math::randomf(100.0f) < 50.0f) { + state_explosionbuffer = audio::Buffers::load("fx/explosion01"); + } else { + state_explosionbuffer = audio::Buffers::load("fx/explosion02"); + } + state_engineeventbuffer = audio::play(state_engineeventsource, state_explosionbuffer); + } + pitch = 1.0f; + gain = 0.0f; // loop buffer gain + } else { if ((state_engineeventbuffer == state_impulsestartbuffer) || (state_engineeventbuffer == state_impulseloopbuffer)) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * r , - entity->axis().forward() * speed); + controlable->location() - controlable->axis().forward() * r , + controlable->axis().forward() * speed); state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestopbuffer); } state_engineeventbuffer = 0; @@ -280,10 +307,10 @@ void SoundExt::frame(float elapsed) } audio::update_source(state_engineloopsource, - entity->location() - entity->axis().forward() * r ,velocity, pitch, gain); + controlable->location() - controlable->axis().forward() * r ,velocity, pitch, gain); audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * r , velocity); + controlable->location() - controlable->axis().forward() * r , velocity); } else if (entity()->type() == core::Entity::Projectile) { diff --git a/src/client/soundext.h b/src/client/soundext.h index 2750afd..1cadae6 100644 --- a/src/client/soundext.h +++ b/src/client/soundext.h @@ -85,6 +85,8 @@ private: size_t state_jumpstartbuffer; /// index of the audio buffer containing the jump engine stop sound size_t state_jumpstopbuffer; + /// index of the audio buffer containing the explosion sound + size_t state_explosionbuffer; /// index of the audio buffer currently looping in enginesource size_t state_engineloopbuffer; -- cgit v1.2.3