diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/Makefile.am | 4 | ||||
-rw-r--r-- | src/client/input.cc | 5 | ||||
-rw-r--r-- | src/client/radar.cc | 113 | ||||
-rw-r--r-- | src/client/radar.h | 26 | ||||
-rw-r--r-- | src/client/targets.cc | 114 | ||||
-rw-r--r-- | src/client/targets.h | 37 | ||||
-rw-r--r-- | src/client/view.cc | 77 |
7 files changed, 167 insertions, 209 deletions
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(); |