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>2008-05-26 16:34:39 +0000
committerStijn Buys <ingar@osirion.org>2008-05-26 16:34:39 +0000
commitf71901eeab126bb4b7e2552dd2edf0b34632c683 (patch)
tree32e13b554bb5415d6f54d88a0826c52ec73e3801 /src/client
parentf7283b2b9a9bf305ac110ef00cd5c21d5304bfbb (diff)
radar, aux text functions, restore original frustum, documentation update
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am6
-rw-r--r--src/client/radar.cc79
-rw-r--r--src/client/radar.h26
-rw-r--r--src/client/view.cc11
4 files changed, 118 insertions, 4 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 8022dfa..7e0c9e9 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -2,11 +2,11 @@ METASOURCES = AUTO
INCLUDES = -I$(top_srcdir)/src
libclient_la_SOURCES = camera.cc chat.cc client.cc console.cc hud.cc input.cc \
- keyboard.cc video.cc view.cc
+ keyboard.cc radar.cc video.cc view.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_LTLIBRARIES = libclient.la
-noinst_HEADERS = camera.h chat.h client.h console.h input.h keyboard.h video.h \
- view.h
+noinst_HEADERS = camera.h chat.h client.h console.h input.h keyboard.h radar.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/radar.cc b/src/client/radar.cc
new file mode 100644
index 0000000..cc4257e
--- /dev/null
+++ b/src/client/radar.cc
@@ -0,0 +1,79 @@
+/*
+ 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 "core/core.h"
+#include "client/radar.h"
+#include "client/video.h"
+#include "render/draw.h"
+#include "render/render.h"
+namespace client
+{
+
+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
new file mode 100644
index 0000000..d3eee4d
--- /dev/null
+++ b/src/client/radar.h
@@ -0,0 +1,26 @@
+/*
+ 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/view.cc b/src/client/view.cc
index 174e1ed..d5f7d49 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -16,6 +16,7 @@
#include "client/chat.h"
#include "client/console.h"
#include "client/input.h"
+#include "client/radar.h"
#include "client/video.h"
#include "render/draw.h"
#include "render/render.h"
@@ -31,6 +32,7 @@ namespace client
core::Cvar *draw_ui = 0;
core::Cvar *draw_stats = 0;
core::Cvar *cl_crosshaircolor = 0;
+core::Cvar *draw_radar = 0;
namespace view
{
@@ -47,6 +49,9 @@ 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");
}
@@ -245,7 +250,7 @@ void frame(float seconds)
gl::loadidentity();
// FIXME width must always be one
- const float frustumsize = 0.4f;
+ const float frustumsize = .5f;
gl::frustum(-frustumsize*video::aspect, frustumsize*video::aspect, -frustumsize, frustumsize, 1.0f, 1024.0f);
gl::matrixmode(GL_MODELVIEW);
@@ -277,6 +282,10 @@ void frame(float seconds)
console()->draw();
chat::draw();
+ if (draw_radar->value()) {
+ Radar::draw();
+ }
+
if (draw_ui->value()) {
Text::setfont("bitmaps/fonts/gui", 16, 24);
draw_status();