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-08-15 14:03:22 +0000
committerStijn Buys <ingar@osirion.org>2008-08-15 14:03:22 +0000
commit8a4eb790261737104be262cdeab4b0e7d0f5566d (patch)
tree506c094bda41d934fae5bdb7d253c147c1d62964 /src/client/targets.cc
parent62de0496836e729ff955274cf153914709775bfb (diff)
render dock locations on active targets, fix star texture loading and rendering
Diffstat (limited to 'src/client/targets.cc')
-rw-r--r--src/client/targets.cc146
1 files changed, 2 insertions, 144 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index b87f056..e53e530 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -24,9 +24,7 @@
#include "core/range.h"
#include "math/axis.h"
#include "math/vector3f.h"
-#include "render/gl.h"
-#include "render/render.h"
-#include "render/text.h"
+#include "render/camera.h"
namespace client {
@@ -377,145 +375,8 @@ void render_entity_sound(core::EntityControlable *entity)
state->location() - state->axis().forward() * entity->model()->maxbbox().y , state->axis().forward() * speed);
}
-void draw_entity_offscreen_target(core::Entity *entity, bool is_active_target)
-{
-
- math::Vector3f target(entity->state()->location() - render::Camera::eye());
- target = render::Camera::axis().transpose() * target;
-
- float cx = 0;
- float cy = 0;
-
- if ( target.y*target.y + target.z*target.z < 0.0001 ) {
- // X - bound, behind (front is visible)
- cx = 0.0f;
- cy = -0.5f;
-
- } else if (fabs(target.y) > fabs(target.z)) {
- // Y-bound
- cx = math::sgnf(target.y) * 0.5f;
- cy = 0.5f * target.z / fabs(target.y);
- } else {
- // Z-bound
- cx = 0.5f * target.y / fabs(target.z);
- cy = math::sgnf(target.z) * 0.5f;
- }
-
- const float r = 16;
- cx = (0.5f - cx) * (float) video::width;
- cy = (0.5f - cy) * (float)video::height;
-
- render::gl::disable(GL_TEXTURE_2D);
- render::gl::color(0, 0, 0, 1);
- render::gl::begin(render::gl::LineLoop);
- glVertex3f(cx+r, cy+2, 0);
- glVertex3f(cx, cy+r+2, 0);
- glVertex3f(cx-r, cy+2, 0);
- glVertex3f(cx, cy-r+2, 0);
- render::gl::end();
-
- if (entity->type() == core::Entity::Controlable) {
- render::gl::color(0, 1, 0, 1);
- } else {
- render::gl::color(1, 1, 1, 1);
- }
-
- render::gl::begin(render::gl::LineLoop);
- glVertex3f(cx+r, cy, 0);
- glVertex3f(cx, cy+r, 0);
- glVertex3f(cx-r, cy, 0);
- glVertex3f(cx, cy-r, 0);
- render::gl::end();
- render::gl::enable(GL_TEXTURE_2D);
-}
-
-void draw_entity_target(core::Entity *entity, bool is_active_target)
-{
- using math::Vector3f;
-
- // don't draw target if we're very close to it
- if (entity->state()->distance() < 0.001f)
- return;
-
- // don't draw target if it is outside the visible cone
- Vector3f target(entity->state()->location() - render::Camera::eye());
- if (math::dotproduct(render::Camera::axis().forward(), Vector3f::normalized(target)) < 0.75 ) {
- draw_entity_offscreen_target(entity, is_active_target);
- return;
- }
-
- // transform the target into the camera coordinate system
- target = render::Camera::axis().transpose() * target;
-
- // calculate the intersection between the line (0,0,0)-target and the frustum front
- float t = (render::Camera::frustum_front() + 0.001f) / target.x;
- Vector3f center(target *t);
-
- float cx = video::width * (0.5 - center.y);
- float cy = video::height * (0.5 - center.z * render::Camera::aspect());
-
- if ((cx < 0 ) || (cy < 0) || (cx > video::width) || (cy > video::height)) {
- draw_entity_offscreen_target(entity, is_active_target);
- return;
- }
-
- const float pointer_size = 48.0f;
- float r = pointer_size;
- if (!is_active_target)
- r *= 0.5;
-
- render::gl::disable(GL_TEXTURE_2D);
- // outer square shadow
- render::gl::color(0, 0, 0, 1);
- render::gl::begin(render::gl::LineLoop);
- glVertex3f(cx+r, cy+2, 0);
- glVertex3f(cx, cy+r+2, 0);
- glVertex3f(cx-r, cy+2, 0);
- glVertex3f(cx, cy-r+2, 0);
- render::gl::end();
-
- if (entity->type() == core::Entity::Controlable) {
- render::gl::color(0, 1, 0, 1);
- } else {
- render::gl::color(1, 1, 1, 1);
- }
- // outer square0
- render::gl::begin(render::gl::LineLoop);
- glVertex3f(cx+r, cy, 0);
- glVertex3f(cx, cy+r, 0);
- glVertex3f(cx-r, cy, 0);
- glVertex3f(cx, cy-r, 0);
- render::gl::end();
-
- render::gl::enable(GL_TEXTURE_2D);
-
- if (is_active_target) {
- // entity name and distance
- std::stringstream strdistance;
- float d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius();
- if (d > 0 ) {
- if (d > 100.0f) {
- strdistance << roundf(d * 0.1f) << "km";
- } else {
- strdistance << roundf(d * 100.0f) << "m";
- }
- } else {
- strdistance << "--";
- }
- if (entity->type() == core::Entity::Controlable) {
- render::Text::setcolor('B');
- } else {
- render::Text::setcolor('N');
- }
- render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f,
- cy-r-4-render::Text::fontheight(), entity->name());
-
- render::Text::draw(cx - aux::text_length(strdistance.str()) * render::Text::fontwidth() * 0.5f,
- cy+r+4, strdistance);
- }
-}
-// render targets and sounds
+// render targets and sounds (in world coordinates)
void draw()
{
core::Zone *zone = core::localplayer()->zone();
@@ -564,9 +425,6 @@ void draw()
if (entity->id() == current_target_id) {
current_target = entity;
- draw_entity_target(current_target, true);
- } else if (entity->type() == core::Entity::Controlable) {
- draw_entity_target(entity, false);
}
// check if the mouse is hovering the entity