Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/soundext.cc110
1 files changed, 56 insertions, 54 deletions
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index 9b15597..4b3e1c7 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -56,10 +56,10 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun
state_impulseloopbuffer = audio::Buffers::load("engines/impulse_loop00");
state_impulsestartbuffer = audio::Buffers::load("engines/impulse_start00");
state_impulsestopbuffer = audio::Buffers::load("engines/impulse_stop00");
- }
- state_engineloopsource = audio::Sources::get();
- state_engineeventsource = audio::Sources::get();
+ state_engineloopsource = audio::Sources::get();
+ state_engineeventsource = audio::Sources::get();
+ }
}
SoundExt::~SoundExt()
@@ -91,59 +91,61 @@ void SoundExt::clear()
void SoundExt::frame(float elapsed)
{
- core::EntityControlable *entity = static_cast<core::EntityControlable *>(this->entity());
-
- float speed = entity->speed();
- float pitch = 1.0f;
- float gain = 0.0;
- if (entity->eventstate() == core::Entity::Impulse) {
- pitch = 1.0f;
- gain = 1.0f;
- } else if (entity->thrust() > 0 ) {
- pitch = 0.2f + entity->thrust() * 0.8f;
- gain = 0.8f;
- }
-
- if (entity->eventstate() == core::Entity::ImpulseInitiate ) {
-
- if (state_engineeventbuffer != state_impulsestartbuffer) {
- audio::update_source(state_engineeventsource,
- entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed);
- state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestartbuffer);
- }
- } else if (entity->eventstate() == core::Entity::Impulse) {
-
- state_engineeventbuffer = state_impulseloopbuffer;
-
- if (state_engineloopbuffer != state_impulseloopbuffer) {
- state_engineloopbuffer = audio::loop(state_engineloopsource, state_impulseloopbuffer, pitch, 0);
- }
- pitch = 1.0f;
- } else {
-
- if (state_engineeventbuffer == state_impulseloopbuffer) {
- audio::update_source(state_engineeventsource,
- entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed);
- state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestopbuffer);
- }
- state_engineeventbuffer = 0;
-
- if (state_engineloopbuffer != state_thusterloopbuffer) {
- state_engineloopbuffer = audio::loop(state_engineloopsource, state_thusterloopbuffer, pitch, 0);
+ if (entity()->type() == core::Entity::Controlable)
+ {
+ core::EntityControlable *entity = static_cast<core::EntityControlable *>(this->entity());
+
+ float speed = entity->speed();
+ float pitch = 1.0f;
+ float gain = 0.0;
+ if (entity->eventstate() == core::Entity::Impulse) {
+ pitch = 1.0f;
+ gain = 1.0f;
+ } else if (entity->thrust() > 0 ) {
+ pitch = 0.2f + entity->thrust() * 0.8f;
+ gain = 0.8f;
+ }
+
+ if (entity->eventstate() == core::Entity::ImpulseInitiate ) {
+
+ if (state_engineeventbuffer != state_impulsestartbuffer) {
+ audio::update_source(state_engineeventsource,
+ entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed);
+ state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestartbuffer);
+ }
+ } else if (entity->eventstate() == core::Entity::Impulse) {
+
+ state_engineeventbuffer = state_impulseloopbuffer;
+
+ if (state_engineloopbuffer != state_impulseloopbuffer) {
+ state_engineloopbuffer = audio::loop(state_engineloopsource, state_impulseloopbuffer, pitch, 0);
+ }
+ pitch = 1.0f;
+ } else {
+
+ if (state_engineeventbuffer == state_impulseloopbuffer) {
+ audio::update_source(state_engineeventsource,
+ entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed);
+ state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestopbuffer);
+ }
+ state_engineeventbuffer = 0;
+
+ if (state_engineloopbuffer != state_thusterloopbuffer) {
+ state_engineloopbuffer = audio::loop(state_engineloopsource, state_thusterloopbuffer, pitch, 0);
+ }
}
+
+
+ float x = entity->radius();
+ if (entity->model())
+ x = entity->model()->maxbbox().x;
+
+ audio::update_source(state_engineloopsource,
+ entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed, pitch, gain);
+
+ audio::update_source(state_engineeventsource,
+ entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed);
}
-
-
- float x = entity->radius();
- if (entity->model())
- x = entity->model()->maxbbox().x;
-
- audio::update_source(state_engineloopsource,
- entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed, pitch, gain);
-
- audio::update_source(state_engineeventsource,
- entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed);
-
}
} // namespace client