From f71901eeab126bb4b7e2552dd2edf0b34632c683 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 26 May 2008 16:34:39 +0000 Subject: radar, aux text functions, restore original frustum, documentation update --- src/client/radar.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/client/radar.cc (limited to 'src/client/radar.cc') 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::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); +} + +} -- cgit v1.2.3