Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/audio.cc5
-rw-r--r--src/audio/sources.cc2
-rw-r--r--src/client/Makefile.am4
-rw-r--r--src/client/input.cc5
-rw-r--r--src/client/radar.cc113
-rw-r--r--src/client/radar.h26
-rw-r--r--src/client/targets.cc114
-rw-r--r--src/client/targets.h37
-rw-r--r--src/client/view.cc77
-rw-r--r--src/render/draw.cc6
-rw-r--r--src/render/draw.h3
-rw-r--r--src/render/dust.cc36
-rw-r--r--src/render/dust.h2
13 files changed, 201 insertions, 229 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index 20f6b1d..8b65879 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -84,6 +84,9 @@ void play(const char *name)
Buffers::bind(source, buffer);
alSourcef(source, AL_PITCH, 1.0);
alSourcef(source, AL_GAIN, 1.0);
+ alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
+ ALfloat location[] = {0.0f, 0.0f, 0.0f};
+ alSourcefv(source, AL_POSITION, location);
alSourceRewind(source);
alSourcePlay(source);
return;
@@ -108,6 +111,8 @@ void loop( size_t source_index, const char *name, float pitch, float gain)
ALuint source = Sources::source(source_index);
Buffers::bind(source, Buffers::load(std::string(name)));
+ alSourcef(source, AL_REFERENCE_DISTANCE, 4.0f);
+ alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
alSourcef(source, AL_PITCH, pitch);
alSourcef(source, AL_GAIN, gain);
diff --git a/src/audio/sources.cc b/src/audio/sources.cc
index 3a6b3fc..b52c5a4 100644
--- a/src/audio/sources.cc
+++ b/src/audio/sources.cc
@@ -59,7 +59,7 @@ size_t Sources::get()
if (source_available[i]) {
source_available[i] = false;
alSourcef(sources[i], AL_PITCH, 1.0);
- alSourcef(sources[i], AL_GAIN, 1.0);
+ alSourcef(sources[i], AL_GAIN, 0.0);
//con_debug << "reserved source " << i << std::endl;
return i;
}
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 629102f..39b53cf 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -8,11 +8,11 @@ noinst_LTLIBRARIES = libclient.la
endif
libclient_la_SOURCES = chat.cc client.cc console.cc hud.cc input.cc key.cc \
- keyboard.cc radar.cc video.cc view.cc
+ keyboard.cc targets.cc video.cc view.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
-noinst_HEADERS = chat.h client.h console.h input.h key.h keyboard.h radar.h \
+noinst_HEADERS = chat.h client.h console.h input.h key.h keyboard.h targets.h \
video.h view.h
libclient_la_LIBADD = $(top_builddir)/src/render/librender.la \
$(top_builddir)/src/core/libcore.la
diff --git a/src/client/input.cc b/src/client/input.cc
index da20456..3d9caa5 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -15,7 +15,7 @@
#include "render/camera.h"
#include "math/functions.h"
#include "render/text.h"
-
+#include "render/draw.h"
#include "SDL/SDL.h"
namespace client
@@ -346,6 +346,7 @@ void action_release(std::string const &action)
void frame(float seconds)
{
if (core::localcontrol() && (last_control != core::localcontrol()->id())) {
+
local_direction = 0.0f;
local_pitch = 0.0f;
local_roll = 0.0f;
@@ -357,6 +358,8 @@ void frame(float seconds)
mouse_y = video::height / 2;
render::Camera::reset();
cl_mousecontrol_override = false;
+
+ render::reset();
}
SDL_Event event;
diff --git a/src/client/radar.cc b/src/client/radar.cc
deleted file mode 100644
index cdf5391..0000000
--- a/src/client/radar.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- client/rader.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
-*/
-
-#include "auxiliary/functions.h"
-#include "core/core.h"
-#include "client/radar.h"
-#include "client/video.h"
-#include "render/draw.h"
-#include "render/render.h"
-#include "render/text.h"
-
-namespace client
-{
-
-void Radar::draw() {
- using namespace render;
-
- if (!core::localcontrol())
- return;
-
- float y = 4 + Text::fontheight();
- Text::draw(4, y, "^N------------ ^BRadar test ^N--------------");
- y += Text::fontheight();
-
- gl::color(1.0f, 1.0f, 1.0f, 1.0f);
-
- std::map<unsigned int, core::Entity *>::iterator it;
- for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
- core::Entity *entity = (*it).second;
- core::ClientState *state = entity->state();
-
- if (state && state->targetable() && entity->label().size()) {
- gl::color(entity->color());
- std::ostringstream line;
- line << aux::pad_right(entity->name(), 24) <<
- state->state_screenlocation[0] << " " <<
- state->state_screenlocation[1] << " " <<
- state->state_screenlocation[2] << " ";
- Text::draw(4, y, line.str());
- y += Text::fontheight();
- }
- }
-
-}
-/*
-void Radar::draw()
-{
- using namespace render;
-
- if (!core::localcontrol())
- return;
-
- const float width = (float) video::width/4;
- const float height = (float) video::height/4;
-
- const float margin = 16;
- const float xscale = 128;
- const float yscale = xscale * height / width;
-
- const float left = video::width - margin - width;
- const float top = video::height -margin - height;
-
- gl::disable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- //glEnableClientState(GL_COLOR_ARRAY);
-
- // draw the transparent radar background
- gl::color(0.0f, 0.0f, 0.0f, 0.2f);
- gl::begin(gl::Quads);
- gl::vertex(left, top, 0.0f);
- gl::vertex(left + width, top, 0.0f);
- gl::vertex(left + width, top + height, 0.0f);
- gl::vertex(left, top + height, 0.0f);
- gl::end();
-
- math::Vector3f center(core::localcontrol()->location());
-
- gl::begin(gl::Points);
- std::map<unsigned int, core::Entity *>::iterator it;
- for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
- core::Entity *entity = (*it).second;
-
- math::Vector3f position(entity->state()->location() - center);
- if ((position.x > -yscale) && (position.x < yscale) && (position.y > -xscale) && (position.y < xscale)) {
- float x = left + width/2 - position.y / xscale * width/2;
- float y = top + height/2 - position.x / xscale * width/2;
- if (entity->type() == core::Entity::Globe) {
- gl::end();
- gl::push();
- gl::translate(x, y, 0);
- float r = entity->radius() / xscale * width/2;
- draw_sphere(entity->color(), r);
- gl::pop();
- gl::begin(gl::Points);
- } else {
- gl::color(entity->color());
- gl::vertex(x , y , 0);
- }
- }
- }
- gl::end();
-
- gl::enable(GL_TEXTURE_2D);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- //glDisableClientState(GL_COLOR_ARRAY);
-}
-*/
-}
diff --git a/src/client/radar.h b/src/client/radar.h
deleted file mode 100644
index d3eee4d..0000000
--- a/src/client/radar.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- client/rader.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
-*/
-
-#ifndef __INCLUDED_CLIENT_RADAR_H__
-#define __INCLUDED_CLIENT_RADAR_H__
-
-#include "render/render.h"
-#include "render/gl.h"
-#include "render/text.h"
-
-namespace client {
-
-/// Class to draw the radar view
-class Radar {
-
-public:
- /// draw the radar view
- static void draw();
-};
-
-}
-
-#endif // __INCLUDED_CLIENT_RADAR_H__
diff --git a/src/client/targets.cc b/src/client/targets.cc
new file mode 100644
index 0000000..a6699b0
--- /dev/null
+++ b/src/client/targets.cc
@@ -0,0 +1,114 @@
+/*
+ client/targets.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_TARGET_H__
+#define __INCLUDED_CLIENT_TARGET_H__
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <iomanip>
+
+#include "audio/audio.h"
+#include "audio/sources.h"
+#include "client/view.h"
+#include "core/gameinterface.h"
+#include "core/entity.h"
+#include "render/render.h"
+#include "render/gl.h"
+#include "render/text.h"
+
+namespace client {
+
+core::Cvar *draw_target = 0;
+
+core::Cvar *snd_engines = 0;
+
+namespace targets {
+
+void init()
+{
+ snd_engines = core::Cvar::get("snd_engines", "1", core::Cvar::Archive);
+ snd_engines->set_info("[bool] enable or disable engine sounds");
+
+ draw_target = core::Cvar::get("draw_target", "1", core::Cvar::Archive);
+ draw_target->set_info("[bool] draw target information");
+}
+
+void shutdown()
+{
+}
+
+void render_listener_sound()
+{
+ if (!(snd_engines && snd_engines->value()))
+ return;
+
+ math::Vector3f velocity(0, 0 ,0);
+ if (core::localcontrol()) {
+ velocity.assign(core::localcontrol()->state()->axis().forward() * core::localcontrol()->speed());
+ }
+
+ audio::update_listener(render::Camera::eye(), render::Camera::axis(), velocity);
+}
+
+void render_entity_sound(core::Entity *entity)
+{
+ if (!(entity->type() == core::Entity::Controlable))
+ return;
+
+ if (!(snd_engines && snd_engines->value())) {
+ entity->state()->clearsound();
+ return;
+ }
+
+ core::EntityControlable *entitycontrolable = (core::EntityControlable *) entity;
+ core::ClientState *state = entity->state();
+
+ if (entity->model() && state->detailvisible() && entitycontrolable->thrust() > 0 ) {
+
+ float speed = entitycontrolable->speed();
+ float pitch = 0.2f + entitycontrolable->thrust() * 0.8f;
+
+ if (!state->state_enginesound) {
+ if ((state->state_enginesound = audio::Sources::get()) > 0 ) {
+
+ size_t enginesound = 0;
+ if (entity->model())
+ enginesound = entity->model()->enginesound();
+
+ std::stringstream soundname;
+ soundname << "engines/loop" << std::setfill('0') << std::setw(2) << enginesound;
+ audio::loop(state->state_enginesound, soundname.str().c_str(), pitch, 0);
+ }
+ }
+
+ if (state->state_enginesound) {
+ audio::update_source(state->state_enginesound,
+ state->location() - state->axis().forward() * entity->model()->maxbbox().y , state->axis().forward() * speed, pitch);
+ }
+ } else {
+ entity->state()->clearsound();
+ }
+}
+
+// render ingame sounds
+void draw()
+{
+ render_listener_sound();
+
+ for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
+ core::Entity *entity = (*it).second;
+
+ render_entity_sound(entity);
+ }
+}
+
+}
+
+}
+
+#endif // __INCLUDED_CLIENT_RADAR_H__
diff --git a/src/client/targets.h b/src/client/targets.h
new file mode 100644
index 0000000..7e7ce26
--- /dev/null
+++ b/src/client/targets.h
@@ -0,0 +1,37 @@
+/*
+ client/targets.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_TARGETS_H__
+#define __INCLUDED_CLIENT_TARGETS_H__
+
+#include "render/render.h"
+#include "render/gl.h"
+#include "render/text.h"
+
+namespace client {
+
+namespace targets {
+
+void init();
+
+void shutdown();
+
+
+/// render client side entity properties
+void draw();
+
+/// render sound listener properties
+void render_listener_sound();
+
+/// render the sound for one entity
+void render_entity_sound(core::Entity *Entity);
+
+}
+
+}
+
+#endif
+
diff --git a/src/client/view.cc b/src/client/view.cc
index 34fe3fa..8f01ad5 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -11,13 +11,11 @@
#include <sstream>
#include <iomanip>
-#include "audio/audio.h"
-#include "audio/sources.h"
#include "client/client.h"
#include "client/chat.h"
#include "client/console.h"
#include "client/input.h"
-#include "client/radar.h"
+#include "client/targets.h"
#include "client/video.h"
#include "render/draw.h"
#include "render/render.h"
@@ -34,9 +32,7 @@ namespace client
core::Cvar *draw_ui = 0;
core::Cvar *draw_stats = 0;
core::Cvar *draw_location = 0;
-core::Cvar *draw_radar = 0;
-core::Cvar *snd_engines = 0;
core::Cvar *cl_crosshaircolor = 0;
namespace view
@@ -55,18 +51,15 @@ void init()
draw_ui = core::Cvar::get("draw_ui", "1", core::Cvar::Archive);
draw_ui->set_info("[bool] draw the user interface");
- draw_radar = core::Cvar::get("draw_radar", "1", core::Cvar::Archive);
- draw_radar->set_info("[bool] draw the radar view");
-
cl_crosshaircolor = core::Cvar::get("cl_crosshaircolor", "1 1 1", core::Cvar::Archive);
cl_crosshaircolor->set_info("[r g b] crosshairs color");
- snd_engines = core::Cvar::get("snd_engines", "1", core::Cvar::Archive);
- snd_engines->set_info("[bool] enable or disable engine sounds");
+ targets::init();
}
void shutdown()
{
+ targets::shutdown();
}
void draw_loader()
@@ -288,56 +281,6 @@ void reset()
}
-// render ingame sounds
-void render_sound()
-{
- if (!(snd_engines && snd_engines->value()))
- return;
-
- math::Vector3f velocity(0, 0 ,0);
-
- if (core::localcontrol()) {
- velocity.assign(core::localcontrol()->state()->axis().forward() * core::localcontrol()->speed());
- }
-
- audio::update_listener(render::Camera::eye(), render::Camera::axis(), velocity);
-
- for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
- core::Entity *entity = (*it).second;
- core::ClientState *state = entity->state();
-
- if ((entity->type() == core::Entity::Controlable)) {
- core::EntityControlable *entitycontrolable = (core::EntityControlable *) entity;
-
- if (entity->model() && state->detailvisible() && entitycontrolable->thrust() > 0 ) {
-
- float speed = entitycontrolable->speed();
- float pitch = 0.2f + entitycontrolable->thrust() * 0.8f;
-
- if (!state->state_enginesound) {
- if ((state->state_enginesound = audio::Sources::get()) > 0 ) {
-
- size_t enginesound = 0;
- if (entity->model())
- enginesound = entity->model()->enginesound();
-
- std::stringstream soundname;
- soundname << "engines/loop" << std::setfill('0') << std::setw(2) << enginesound;
- audio::loop(state->state_enginesound, soundname.str().c_str(), pitch, 0);
- }
- }
-
- if (state->state_enginesound) {
- audio::update_source(state->state_enginesound,
- state->location() - state->axis().forward() * entity->model()->maxbbox().y , state->axis().forward() * speed, pitch);
- }
- } else {
- entity->state()->clearsound();
- }
- }
- }
-}
-
void frame(float seconds)
{
using namespace render;
@@ -356,8 +299,6 @@ void frame(float seconds)
if (core::application()->connected() && core::game()->serverframetime()) {
render::draw(seconds); // draw the world
-
- render_sound();
}
// switch to ortographic projection to draw the GUI
@@ -387,16 +328,18 @@ void frame(float seconds)
if (draw_ui->value()) {
Text::setfont("bitmaps/fonts/gui", 16, 24);
-
- draw_status();
- if (draw_radar->value()) {
- Radar::draw();
- }
+ // draw the player status
+ draw_status();
// draw the mouse cursor
draw_cursor();
}
+
+ // render sound and gui targets
+ if (core::application()->connected() && core::game()->serverframetime()) {
+ targets::draw();
+ }
Text::setfont("bitmaps/fonts/console", 12, 18);
chat::draw();
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 1f920b0..8855343 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -889,4 +889,10 @@ void draw(float seconds)
// GL_BLEND must be enabled for the GUI
}
+// reset drawing parameters for a new localcontrol
+void reset()
+{
+ Dust::reset();
+}
+
}
diff --git a/src/render/draw.h b/src/render/draw.h
index ee9db26..89c5ea7 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -16,6 +16,9 @@ namespace render
/// draw the world
void draw(float seconds);
+/// reset
+void reset();
+
/// draw a sphere
void draw_sphere(math::Color const & color, float radius);
diff --git a/src/render/dust.cc b/src/render/dust.cc
index b9e53a5..37dd217 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -17,11 +17,11 @@ namespace render
core::Cvar *r_dust;
core::Cvar *r_dustsize;
-const float MAXDUSTDISTANCE = 8.0f;
-const float MINDUSTDISTANCE = 6.0f;
const float LOWSPEEDLIMIT = 5.0f;
const float TRAILLENGHT = 0.25f;
-const float MAXDUSTALPHA = 0.8f;
+const float DUSTMAXALPHA = 0.8f;
+const float DUSTDISTANCE = 8.0f;
+
float *dust;
size_t dustsize;
@@ -46,6 +46,12 @@ void Dust::shutdown()
}
}
+void Dust::reset()
+{
+ delete dust;
+ dust = 0;
+}
+
void Dust::draw()
{
if (!r_dust->value()) {
@@ -83,9 +89,9 @@ void Dust::draw()
dust = new float[dustsize*3];
for (size_t i = 0; i < dustsize; i++) {
- dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * MINDUSTDISTANCE;
- dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * MINDUSTDISTANCE;
- dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * MINDUSTDISTANCE;
+ dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
+ dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
+ dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
}
}
@@ -96,7 +102,7 @@ void Dust::draw()
if (core::localcontrol()->speed() < LOWSPEEDLIMIT) {
color.a = core::localcontrol()->speed() / LOWSPEEDLIMIT;
}
- color.a *= MAXDUSTALPHA;
+ color.a *= DUSTMAXALPHA;
gl::color(color);
gl::begin(gl::Lines);
@@ -107,19 +113,11 @@ void Dust::draw()
for (size_t j = 0; j < 3; j++)
v[j] -= dust[i*3+j];
- if (v.lengthsquared() > (core::localcontrol()->radius() + MAXDUSTDISTANCE)*(core::localcontrol()->radius() + MAXDUSTDISTANCE)) {
-/*
- v.assign(core::localcontrol()->state()->location());
- v += core::localcontrol()->state()->axis().forward() * (core::localcontrol()->radius() + math::randomf(MAXDUSTDISTANCE));
- v += core::localcontrol()->state()->axis().left() * (math::randomf(2*MINDUSTDISTANCE) - MINDUSTDISTANCE);
- v += core::localcontrol()->state()->axis().up() * (math::randomf(2*MINDUSTDISTANCE) - MINDUSTDISTANCE);
+ if (v.lengthsquared() > (core::localcontrol()->radius() + DUSTDISTANCE)*(core::localcontrol()->radius() + DUSTDISTANCE)) {
- for (size_t j = 0; j < 3; j++)
- dust[i*3+j] = v[j];
-*/
- dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius());
- dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius());
- dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (MAXDUSTDISTANCE + core::localcontrol()->radius());
+ dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
+ dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
+ dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
}
glVertex3fv(dust+3*i);
diff --git a/src/render/dust.h b/src/render/dust.h
index 031743e..6a4b455 100644
--- a/src/render/dust.h
+++ b/src/render/dust.h
@@ -20,6 +20,8 @@ public:
static void shutdown();
static void draw();
+
+ static void reset();
};
}