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-07-26 15:12:00 +0000
committerStijn Buys <ingar@osirion.org>2008-07-26 15:12:00 +0000
commit7090f5cafe38946e0f6bd9756dca8a14f0ea056d (patch)
tree4512e93e779fec311985d5dc46151c229d410dfa
parent88b3db1776759611950ed7c82e00c753c7481a22 (diff)
don't render target selection bitmap with draw_ui 0
-rw-r--r--src/client/targets.cc78
-rw-r--r--src/client/targets.h5
-rw-r--r--src/client/view.cc5
3 files changed, 49 insertions, 39 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index 5b8e9ab..a39943f 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -4,9 +4,6 @@
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>
@@ -261,7 +258,7 @@ void render_entity_sound(core::Entity *entity)
}
// render client targets
-void draw()
+void frame()
{
/* Notes
@@ -321,44 +318,51 @@ void draw()
if (!current_target) {
current_target_id = 0;
-
} else {
- core::Entity *entity = current_target;
-
- // if target is in visible space
- Vector3f v(entity->state()->location() - render::Camera::eye());
- v.normalize();
- if (math::dotproduct(render::Camera::axis().forward(), v) > 0.75 ) {
-
- // find the intersection of the line [ eye - target ] in the frustum front plane
- Vector3f const &plane_normal = render::Camera::axis().forward();
- Vector3f const &plane_point = render::Camera::eye() + render::Camera::axis().forward() * (render::Camera::frustum_front() + 0.001);
-
- float d = (plane_normal.x * plane_point.x + plane_normal.y * plane_point.y + plane_normal.z * plane_point.z);
- float t = d - plane_normal.x * render::Camera::eye().x
- - plane_normal.y * render::Camera::eye().y
- - plane_normal.z * render::Camera::eye().z;
- t /= plane_normal.x * (entity->state()->location().x - render::Camera::eye().x)
- + plane_normal.y * (entity->state()->location().y - render::Camera::eye().y)
- + plane_normal.z * (entity->state()->location().z - render::Camera::eye().z);
-
- Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t;
-
- // draw the target cursor in the frustum front plane, but in real world coordinates
- const float r = 0.05;
- render::gl::color(1, 1, 1, 1);
- render::gl::begin(render::gl::LineLoop);
- render::gl::vertex(intersection + render::Camera::axis().up() * r);
- render::gl::vertex(intersection + render::Camera::axis().left() * r);
- render::gl::vertex(intersection - render::Camera::axis().up() * r);
- render::gl::vertex(intersection - render::Camera::axis().left() * r);
- render::gl::end();
- }
+ current_target_id = current_target->id();
}
}
+void draw_target()
+{
+ using math::Vector3f;
+
+ if (!current_target)
+ return;
+
+ core::Entity *entity = current_target;
+
+ // if target is in visible space
+ Vector3f v(entity->state()->location() - render::Camera::eye());
+ v.normalize();
+ if (math::dotproduct(render::Camera::axis().forward(), v) > 0.75 ) {
+
+ // find the intersection of the line [ eye - target ] in the frustum front plane
+ Vector3f const &plane_normal = render::Camera::axis().forward();
+ Vector3f const &plane_point = render::Camera::eye() + render::Camera::axis().forward() * (render::Camera::frustum_front() + 0.001);
+
+ float d = (plane_normal.x * plane_point.x + plane_normal.y * plane_point.y + plane_normal.z * plane_point.z);
+ float t = d - plane_normal.x * render::Camera::eye().x
+ - plane_normal.y * render::Camera::eye().y
+ - plane_normal.z * render::Camera::eye().z;
+ t /= plane_normal.x * (entity->state()->location().x - render::Camera::eye().x)
+ + plane_normal.y * (entity->state()->location().y - render::Camera::eye().y)
+ + plane_normal.z * (entity->state()->location().z - render::Camera::eye().z);
+
+ Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t;
+
+ // draw the target cursor in the frustum front plane, but in real world coordinates
+ const float r = 0.05;
+ render::gl::color(1, 1, 1, 1);
+ render::gl::begin(render::gl::LineLoop);
+ render::gl::vertex(intersection + render::Camera::axis().up() * r);
+ render::gl::vertex(intersection + render::Camera::axis().left() * r);
+ render::gl::vertex(intersection - render::Camera::axis().up() * r);
+ render::gl::vertex(intersection - render::Camera::axis().left() * r);
+ render::gl::end();
+ }
}
}
-#endif // __INCLUDED_CLIENT_RADAR_H__
+}
diff --git a/src/client/targets.h b/src/client/targets.h
index fc2d861..0df9df7 100644
--- a/src/client/targets.h
+++ b/src/client/targets.h
@@ -23,7 +23,10 @@ void shutdown();
void reset();
/// render client side entity properties
-void draw();
+void frame();
+
+/// draw target box
+void draw_target();
/// render sound listener properties
void render_listener_sound();
diff --git a/src/client/view.cc b/src/client/view.cc
index dc17cce..eda5cf8 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -347,7 +347,10 @@ void frame(float seconds)
if (core::application()->connected() && core::game()->serverframetime()) {
render::draw(seconds); // draw the world
- targets::draw();
+ targets::frame();
+ if (draw_ui->value()) {
+ targets::draw_target();
+ }
}
// switch to ortographic projection to draw the GUI