Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
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/ui
parent26c8cf4d74062fb12871ae9d5298d8ceaab7a2cf (diff)
Reimplemented camera handling enabling 360-degree freelook.
Diffstat (limited to 'src/ui')
-rwxr-xr-xsrc/ui/modelview.cc20
-rwxr-xr-xsrc/ui/modelview.h3
2 files changed, 17 insertions, 6 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index f1676b1..25a3865 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -38,6 +38,8 @@ ModelView::ModelView(Widget *parent) : Widget(parent)
modelview_axis.change_direction(180);
modelview_axis.change_pitch(-15);
+ modelview_camera.set_mode(render::Camera::Free);
+
modelview_mode = Model;
}
@@ -54,6 +56,8 @@ void ModelView::reset()
{
set_background(false);
+ modelview_camera.set_mode(render::Camera::Free);
+
modelview_axis.clear();
modelview_axis.change_direction(180);
modelview_axis.change_pitch(-15);
@@ -104,13 +108,13 @@ bool ModelView::on_mousewheel(const math::Vector2f & direction)
{
if (direction.y() > 0 )
{
- modelview_zoom -= 0.25f;
+ modelview_zoom -= 0.1f;
if (modelview_zoom < 1.0f)
modelview_zoom = 1.0f;
return true;
} else if (direction.y() < 0 )
{
- modelview_zoom += 0.25f;
+ modelview_zoom += 0.1f;
if (modelview_zoom > 5.0f)
modelview_zoom = 5.0f;
return true;
@@ -203,7 +207,9 @@ void ModelView::draw_globe()
const float reference_radius = radius() * minwidget / minscreen;
// gl 3d mode
- render::Camera::frustum_default(modelview_zoom, center.x(), center.y());
+ modelview_camera.set_multiplier(modelview_zoom);
+ modelview_camera.frame(0);
+ modelview_camera.draw(center.x(), center.y());
// set up light environment
render::Light *light = new render::Light(
@@ -246,7 +252,7 @@ void ModelView::draw_globe()
if (modelview_globecoronaname.size()) {
size_t corona_id = render::Textures::load("textures/" + modelview_globecoronaname);
- render::draw_globe_corona(math::Vector3f(0.0f, 0.0f, 0.0f), modelview_color_primary, reference_radius, corona_id);
+ render::draw_globe_corona(modelview_camera, math::Vector3f(0.0f, 0.0f, 0.0f), modelview_color_primary, reference_radius, corona_id);
}
}
@@ -311,8 +317,10 @@ void ModelView::draw_model()
const float modelscale = reference_radius / model->radius();
// gl 3d mode
- render::Camera::frustum_default(modelview_zoom, center.x(), center.y());
-
+ modelview_camera.set_multiplier(modelview_zoom);
+ modelview_camera.frame(0);
+ modelview_camera.draw(center.x(), center.y());
+
// set up light environment
render::Light *light = new render::Light(
math::Vector3f(LIGHT_DISTANCE * reference_radius, 0, 0),
diff --git a/src/ui/modelview.h b/src/ui/modelview.h
index f9566cd..7fd11a9 100755
--- a/src/ui/modelview.h
+++ b/src/ui/modelview.h
@@ -9,6 +9,7 @@
#include "math/axis.h"
#include "ui/widget.h"
+#include "render/camera.h"
namespace ui
{
@@ -137,6 +138,8 @@ private:
math::Axis modelview_axis;
math::Vector2f modelview_cursor;
bool modelview_dragging;
+
+ render::Camera modelview_camera;
};
}