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>2015-02-28 20:46:53 +0000
committerStijn Buys <ingar@osirion.org>2015-02-28 20:46:53 +0000
commitcffe02f49b66a70d40816ffc8dea42f9e52da57f (patch)
tree110471c23944d09899d4cacb3cdd40508f359f72 /src/client/targets.cc
parent26c8cf4d74062fb12871ae9d5298d8ceaab7a2cf (diff)
Reimplemented camera handling enabling 360-degree freelook.
Diffstat (limited to 'src/client/targets.cc')
-rw-r--r--src/client/targets.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index b320b08..ae2afb0 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -25,7 +25,7 @@
#include "core/range.h"
#include "math/axis.h"
#include "math/vector3f.h"
-#include "render/camera.h"
+#include "render/draw.h"
#include "render/state.h"
namespace client
@@ -395,19 +395,19 @@ void func_target_center(std::string const &args)
// this is essentialy the hover algorithm with the cursor in the center
const core::Entity *new_target = 0;
- math::Vector3f center = render::Camera::eye() + render::Camera::axis().forward() * (render::FRUSTUMFRONT + 0.001);
+ math::Vector3f center = render::camera().location() + render::camera().axis().forward() * (render::FRUSTUMFRONT + 0.001);
float smallest_d = -1;
for (core::Zone::Content::const_iterator it = core::localcontrol()->zone()->content().begin(); it != core::localcontrol()->zone()->content().end(); it++) {
const core::Entity *entity = (*it);
- math::Vector3f v(entity->location() - render::Camera::eye());
+ math::Vector3f v(entity->location() - render::camera().location());
v.normalize();
- if (is_valid_hud_target(entity) && math::dotproduct(render::Camera::axis().forward(), v) > 0.85) {
+ if (is_valid_hud_target(entity) && math::dotproduct(render::camera().axis().forward(), v) > 0.85) {
// calculate the distance from entity location to the line [eye - cursor]
- float d = math::Vector3f::length(math::crossproduct((center - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(center - render::Camera::eye());
+ float d = math::Vector3f::length(math::crossproduct((center - render::camera().location()) , (render::camera().location() - entity->location()))) / math::Vector3f::length(center - render::camera().location());
// the entity closer to the center beam
if (smallest_d < 0 || d < smallest_d) {
@@ -495,7 +495,7 @@ void frame()
float x = 0;
float y = 0;
- if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
+ if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && (render::camera().mode() == render::Camera::Cockpit || render::camera().mode() == render::Camera::Track)) {
x = 0;
y = 0;
} else {
@@ -503,13 +503,13 @@ void frame()
y = (float)(input::mouse_position_y() - render::State::height() / 2) / (float)render::State::height() / render::State::aspect();
}
- cursor_aim.assign(render::Camera::eye() + render::Camera::axis().forward() * (render::FRUSTUMFRONT + 0.001));
- cursor_aim -= render::Camera::axis().left() * x;
- cursor_aim -= render::Camera::axis().up() * y;
+ cursor_aim.assign(render::camera().location() + render::camera().axis().forward() * (render::FRUSTUMFRONT + 0.001));
+ cursor_aim -= render::camera().axis().left() * x;
+ cursor_aim -= render::camera().axis().up() * y;
float aim_distance = core::range::fxdistance;
- //math::Vector3f center = render::Camera::eye() + (render::Camera::axis().forward() * (render::FRUSTUMFRONT + 0.001f));
+ //math::Vector3f center = render::camera().location() + (render::camera().axis().forward() * (render::FRUSTUMFRONT + 0.001f));
for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
core::Entity *entity = (*it);
@@ -526,13 +526,13 @@ void frame()
}
// check if the mouse is hovering the entity
- Vector3f v(entity->location() - render::Camera::eye());
+ Vector3f v(entity->location() - render::camera().location());
v.normalize();
- if (math::dotproduct(render::Camera::axis().forward(), v) > 0.75) {
+ if (math::dotproduct(render::camera().axis().forward(), v) > 0.75) {
// calculate the distance from entity location to the line [eye - cursor]
- float d = math::Vector3f::length(math::crossproduct((cursor_aim - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(cursor_aim - render::Camera::eye());
+ float d = math::Vector3f::length(math::crossproduct((cursor_aim - render::camera().location()) , (render::camera().location() - entity->location()))) / math::Vector3f::length(cursor_aim - render::camera().location());
float r = entity->radius();
@@ -549,7 +549,7 @@ void frame()
if (z < 0 || myz < z) {
current_hover = entity->id();
// aim slightly behind target to prevent colliding projectiles
- aim_distance = entity->radius() + math::distance(render::Camera::eye(), entity->location());
+ aim_distance = entity->radius() + math::distance(render::camera().location(), entity->location());
z = myz;
}
}
@@ -559,7 +559,7 @@ void frame()
}
}
- cursor_aim = render::Camera::eye() + (cursor_aim - render::Camera::eye()) * aim_distance / math::distance(render::Camera::eye(), cursor_aim);
+ cursor_aim = render::camera().location() + (cursor_aim - render::camera().location()) * aim_distance / math::distance(render::camera().location(), cursor_aim);
if (!current_target) {
current_target_id = 0;