Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-11-30 15:43:27 +0000
committerStijn Buys <ingar@osirion.org>2008-11-30 15:43:27 +0000
commit37c0f3b6a793495c95f6cf08c2c45d3030b539c4 (patch)
tree55f03ffb62e2d5f77ec936191c4009cd2ba6f57b /src
parentca4fe4bc148be0ecae828585c650391b9f7c35c6 (diff)
improved camera handling and dust rendering
Diffstat (limited to 'src')
-rw-r--r--src/render/camera.cc45
-rw-r--r--src/render/dust.cc3
2 files changed, 30 insertions, 18 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc
index f97ea96..d9821a3 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -4,6 +4,8 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include <cmath>
+
#include "core/core.h"
#include "math/mathlib.h"
#include "math/matrix4f.h"
@@ -19,8 +21,10 @@ namespace render
{
const float MIN_DELTA = 10e-10;
+const float COS_PI_4 = sqrt(2.0f) * 0.5f;
-const float pitch_track = -15.0f;
+const float pitch_free = -30.0f;
+const float pitch_track = -5.0f;
const float pitch_overview = -5.0f;
float Camera::camera_frustum_size = 0.5f;
@@ -107,7 +111,7 @@ void Camera::set_mode(Mode newmode) {
case Free:
// switch camera to Free mode
camera_mode = Free;
- pitch_target = 2.0 * pitch_track;
+ pitch_target = pitch_free;
pitch_current = pitch_target;
break;
@@ -138,21 +142,21 @@ void Camera::view_next()
// switch camera to Track mode
set_mode(Track);
//con_print << "view: track" << std::endl;
- //core::application()->notify_message(core::Message::Info, std::string("view: track"));
+ core::application()->notify_message(core::Message::Info, std::string("view: track"));
break;
case Track:
// switch camera to Cockpit mode
set_mode(Cockpit);
//con_print << "view: cockpit" << std::endl;
- //core::application()->notify_message(core::Message::Info, std::string("view: cockpit"));
+ core::application()->notify_message(core::Message::Info, std::string("view: cockpit"));
break;
case Cockpit:
// switch camera to Free mode
set_mode(Free);
//con_print << "view: free" << std::endl;
- //core::application()->notify_message(core::Message::Info, std::string("view: free"));
+ core::application()->notify_message(core::Message::Info, std::string("view: free"));
break;
default:
@@ -173,21 +177,21 @@ void Camera::view_previous()
// switch camera to Track mode
set_mode(Track);
//con_print << "view: track" << std::endl;
- //core::application()->notify_message(std::string("view: track"));
+ core::application()->notify_message(core::Message::Info, std::string("view: track"));
break;
case Free:
// switch camera to Cockpit mode
set_mode(Cockpit);
//con_print << "view: cockpit" << std::endl;
- //core::application()->notify_message(std::string("view: cockpit"));
+ core::application()->notify_message(core::Message::Info, std::string("view: cockpit"));
break;
case Track:
// switch camera to Free mode
set_mode(Free);
//con_print << "view: free" << std::endl;
- //core::application()->notify_message(std::string("view: free"));
+ core::application()->notify_message(core::Message::Info, std::string("view: free"));
break;
default:
@@ -254,8 +258,6 @@ void Camera::frame(float seconds)
if (mode() == Track) {
- distance *= camera_zoom;
-
float cosangle; // cosine of an angle
float angle; // angle in radians
math::Vector3f n; // normal of a plane
@@ -286,15 +288,19 @@ void Camera::frame(float seconds)
if (angle > MIN_DELTA)
camera_axis.rotate(n, -angle);
}
-
+/*
if (core::localcontrol()->model()) {
camera_target -= (core::localcontrol()->model()->maxbbox().x + core::localcontrol()->model()->radius() + 0.1f) * 0.5f * camera_axis.forward();
camera_target += (core::localcontrol()->model()->maxbbox().z + core::localcontrol()->model()->radius() + 0.1f) * 0.5f * camera_axis.up();
}
-
+*/
+ float f = ( camera_frustum_size/State::aspect() );
+ camera_target += target_axis.up() * math::max(f, core::localcontrol()->radius());
+ distance = math::max(f, core::localcontrol()->radius()) + camera_zoom * core::localcontrol()->radius();
} else if (mode() == Free) {
- camera_axis.assign(target_axis);
+ camera_axis.assign(target_axis);
+
direction_target = direction_current - 90 * target_direction;
pitch_target = pitch_current - 90 * target_pitch;
@@ -307,9 +313,16 @@ void Camera::frame(float seconds)
d = degrees180f(pitch_current - pitch_target);
pitch_current = degrees360f(pitch_current - d * seconds);
camera_axis.change_pitch(pitch_current);
-
- distance = 1.5f * core::localcontrol()->radius() * camera_zoom;
-
+ /*
+ // set distance and location
+ distance = camera_zoom * core::localcontrol()->radius();
+ //distance += (2.0f*core::localcontrol()->radius()) / ( camera_frustum_size/State::aspect() );
+
+ camera_target -= COS_PI_4 * (core::localcontrol()->model() ? core::localcontrol()->model()->maxbbox().x : core::localcontrol()->radius()) * camera_axis.forward();
+ camera_target += COS_PI_4 * (core::localcontrol()->model() ? core::localcontrol()->model()->maxbbox().z : core::localcontrol()->radius()) * camera_axis.up(); camera_target += camera_frustum_size/State::aspect() * target_axis.up();
+ */
+ float f = ( camera_frustum_size/State::aspect() );
+ distance = f + camera_zoom * core::localcontrol()->radius();
} else if (mode() == Cockpit) {
camera_axis.assign(target_axis);
diff --git a/src/render/dust.cc b/src/render/dust.cc
index cb48137..f84460d 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -112,8 +112,7 @@ void Dust::draw(math::Color const &dustcolor)
math::Color color(dustcolor);
alpha = math::max(core::localcontrol()->movement(), core::localcontrol()->speed() * 0.5f);
math::clamp(alpha, 0.0f, 1.0f);
- alpha = 0.1f + alpha * 0.5f;
- color.a = alpha;
+ color.a = 0.25f * alpha;
gl::begin(gl::Lines);
gl::color(color);