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
parentf7283b2b9a9bf305ac110ef00cd5c21d5304bfbb (diff)
radar, aux text functions, restore original frustum, documentation update
-rw-r--r--MODELS12
-rw-r--r--osirion.kdevelop2
-rw-r--r--osirion.kdevelop.pcsbin720726 -> 728934 bytes
-rw-r--r--osirion.kdevses27
-rw-r--r--src/auxiliary/functions.cc32
-rw-r--r--src/auxiliary/functions.h7
-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
-rw-r--r--src/core/gameserver.cc2
-rw-r--r--src/render/draw.h3
12 files changed, 199 insertions, 8 deletions
diff --git a/MODELS b/MODELS
index 4a876c4..4ecd03a 100644
--- a/MODELS
+++ b/MODELS
@@ -153,6 +153,17 @@ Lights
In short, the green light should be on the right side, the red light
on the left side.
+Flares
+
+ The default light entity creates omnidirectional lights. To create
+ a directional flare, use the target_flare entity. Values for a
+ target_flare are the same as those for a default light, with one
+ small diference: the size of the flare is set through the radius
+ value. The default flare radius is 100. Rotate the entity or set the
+ angle value to point the flare in a different direction.
+
+ target_flares can only be rotated in the XY-plane.
+
Engines
Add a target_engine entity to add an engine exhaust to a ship model.
@@ -167,4 +178,3 @@ Other entities
target_cockpit, target_turret and target_cannon are not yet implemented.
-
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 82878a1..58a8bfc 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/game/libgame.la</activetarget>
+ <activetarget>src/client/libclient.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index f8f5974..cb82248 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index e8415d1..2b16c97 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,7 +1,32 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="0" />
+ <DocsAndViews NumberOfDocuments="8" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/radar.h" >
+ <View0 Encoding="" Type="Source" />
+ </Doc0>
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/chat.h" >
+ <View0 Encoding="" Type="Source" />
+ </Doc1>
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/radar.cc" >
+ <View0 Encoding="" Type="Source" />
+ </Doc2>
+ <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/chat.cc" >
+ <View0 Encoding="" Type="Source" />
+ </Doc3>
+ <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/view.cc" >
+ <View0 Encoding="" line="252" Type="Source" />
+ </Doc4>
+ <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/console.cc" >
+ <View0 Encoding="" Type="Source" />
+ </Doc5>
+ <Doc6 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/draw.cc" >
+ <View0 Encoding="" Type="Source" />
+ </Doc6>
+ <Doc7 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/draw.h" >
+ <View0 Encoding="" line="18" Type="Source" />
+ </Doc7>
+ </DocsAndViews>
<pluginList>
<kdevdebugger>
<breakpointList/>
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc
index b417a4a..e9861ac 100644
--- a/src/auxiliary/functions.cc
+++ b/src/auxiliary/functions.cc
@@ -64,6 +64,38 @@ size_t text_length(const std::string &text)
return len;
}
+const std::string text_strip(const std::string &text)
+{
+ const char *c = text.c_str();
+ std::string r;
+ while (*c) {
+ if (is_color_code(c)) {
+ c++;
+ } else {
+ r += *c;
+ }
+ c++;
+ }
+
+ return r;
+}
+
+const std::string text_strip_lowercase(const std::string &text)
+{
+ const char *c = text.c_str();
+ std::string r;
+ while (*c) {
+ if (is_color_code(c)) {
+ c++;
+ } else {
+ r += tolower(*c);
+ }
+ c++;
+ }
+
+ return r;
+}
+
const std::string spaces(const std::string &text,size_t n)
{
size_t l = text_length(text);
diff --git a/src/auxiliary/functions.h b/src/auxiliary/functions.h
index 2202b87..90eb2ed 100644
--- a/src/auxiliary/functions.h
+++ b/src/auxiliary/functions.h
@@ -42,6 +42,13 @@ void to_lowercase(std::string &text);
/// return text, converted to lowercase
const std::string lowercase(const std::string &text);
+
+/// return text, stripped of color codes
+const std::string text_strip(const std::string &text);
+
+/// return text, stripped of color codes and converted to lowercase
+const std::string text_strip_lowercase(const std::string &text);
+
}
#endif // __INCLUDED_AUX_FUNCTIONS_H__
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();
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 5d973f1..46cb742 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -131,7 +131,7 @@ Player *GameServer::find_player(std::string const search)
return 0;
for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
- if (lowercase((*it)->name()).find(lowercase(search)) != std::string::npos)
+ if (aux::text_strip_lowercase((*it)->name()).find(lowercase(search)) != std::string::npos)
return (*it);
}
diff --git a/src/render/draw.h b/src/render/draw.h
index c7d68b1..a260f34 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -16,6 +16,9 @@ namespace render
/// draw the world
void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f const &target, float seconds);
+/// draw a sphere
+void draw_sphere(math::Color const & color, float radius);
+
class Stats {
public:
static void clear();