Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-02-25 19:28:14 +0000
committerStijn Buys <ingar@osirion.org>2010-02-25 19:28:14 +0000
commit90fbc4c5caf5afd54920894319448b74967399ba (patch)
treed4a8fe5ccdcbe94f4a3e5e1115f5baed26e8c2e3 /src/client/soundext.cc
parent83757353860fa447c36d4078602efea36d7da94e (diff)
added initial support for model sound tags,
moved sound code from client/targets.cc to client/soundext.cc, added master volume cvar snd_volume
Diffstat (limited to 'src/client/soundext.cc')
-rw-r--r--src/client/soundext.cc52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index 1ea0c94..04c37f9 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -13,6 +13,7 @@
#include "core/entity.h"
#include "client/soundext.h"
#include "client/client.h"
+#include "render/camera.h"
#include <sstream>
#include <iomanip>
@@ -20,6 +21,52 @@
namespace client
{
+// cvars are initialized in client.cc
+core::Cvar *snd_doppler = 0;
+core::Cvar *snd_engines = 0;
+core::Cvar *snd_volume = 0;
+
+float master_volume = 0;
+void render_listener_sound()
+{
+ if (!(snd_engines && snd_engines->value()))
+ return;
+
+ math::Vector3f velocity(0, 0 , 0);
+ if (core::localcontrol()) {
+ velocity.assign(core::localcontrol()->axis().forward() * core::localcontrol()->speed());
+ }
+
+ if (master_volume != snd_volume->value()) {
+ master_volume = snd_volume->value();
+ math::clamp(master_volume, 0, 1);
+ (*snd_volume) = master_volume;
+ }
+
+ audio::update_listener(render::Camera::eye(), render::Camera::axis(), velocity, master_volume);
+}
+
+void render_entity_sound(core::Entity *entity)
+{
+ if (!(snd_engines && snd_engines->value())) {
+ if (ext_sound(entity))
+ delete ext_sound(entity);
+ return;
+ }
+
+ if (!ext_render(entity) || (ext_render(entity) && !ext_render(entity)->visible())) {
+ if (ext_sound(entity))
+ delete ext_sound(entity);
+ return;
+ } else {
+ if (!ext_sound(entity)) {
+ new SoundExt(entity);
+ }
+
+ ext_sound(entity)->frame(0.0f);
+ }
+}
+
SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Sound, entity)
{
state_thusterloopbuffer = 0;
@@ -103,7 +150,10 @@ void SoundExt::frame(float elapsed)
gain = 1.0f;
} else if (entity->thrust() > 0) {
pitch = 0.2f + entity->thrust() * 0.8f;
- gain = 0.8f;
+ gain = 1.0f;
+ if (entity->thrust() < 0.2f) {
+ gain *= entity->thrust() * 5.0f;
+ }
}
if (entity->state() == core::Entity::ImpulseInitiate) {