Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/draw.cc2
-rwxr-xr-xsrc/ui/modelview.cc35
-rwxr-xr-xsrc/ui/modelview.h2
3 files changed, 36 insertions, 3 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 989bca7..c25a84a 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -124,7 +124,7 @@ void pass_prepare(float seconds)
diffuse_light[3] = 1.0f;
specular_light[3] = 1.0f;
- glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0001);
+ glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, ((globe->color()[0] + globe->color()[1] + globe->color()[2]) / 3.0f) * 0.0001f);
glLightfv(GL_LIGHT0, GL_POSITION, zone_light);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light);
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index 0fb8555..7ac8ef3 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -19,6 +19,8 @@
namespace ui
{
+float modelview_light[] = { 1, 0, 0, 1 };
+
ModelView::ModelView(Widget *parent, const char *modelname) : Widget(parent)
{
set_border(false);
@@ -114,14 +116,20 @@ void ModelView::on_mousemove(const math::Vector2f &cursor)
const math::Vector3f up(0.0f, 0.0f, 1.0f);
const float zrot = 2.0f * M_PI * pos.x() / width();
modelview_axis.rotate(up, -zrot);
-
+
const math::Vector3f left(0.0f, 1.0f, 0.0f);
const float yrot = 2.0f * M_PI * pos.y() / height();
modelview_axis.rotate(left, yrot);
modelview_cursor.assign(cursor);
+
}
modelview_cursor.assign(cursor);
+
+ //FIXME this is perhaps not the best way to do this
+ for(size_t i = 0; i<3; i++) {
+ modelview_light[i] = (-modelview_axis[i][0] / modelscale * 2);
+ }
}
void ModelView::on_mouseover(const math::Vector2f &cursor)
@@ -159,7 +167,7 @@ void ModelView::draw()
const float minscreen(math::min(root()->width(),root()->height()));
const float minwidget(math::min(width(), height()));
const float reference_radius = radius() * minwidget / minscreen;
- const float modelscale = reference_radius / model->radius();
+ modelscale = reference_radius / model->radius();
// gl 3d mode
render::Camera::frustum_default(modelview_zoom, center.x(), center.y());
@@ -187,6 +195,9 @@ void ModelView::draw()
// apply manipulation
gl::push();
+
+
+
gl::multmatrix(modelview_axis);
gl::scale(modelscale, modelscale, modelscale);
@@ -200,12 +211,32 @@ void ModelView::draw()
thrust = 1.0f;
}
+ // let there be ModelView:: light!
+ GLfloat ambient_light[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ GLfloat diffuse_light[4];
+ GLfloat specular_light[4];
+ for (size_t i = 0; i < 3; i++) {
+ diffuse_light[i] = render::r_diffuse->value() * 0.6f;
+ specular_light[i] = render::r_specular->value() * 0.2f;
+ }
+ diffuse_light[3] = 1.0f;
+ specular_light[3] = 1.0f;
+
+ glLightfv(GL_LIGHT1, GL_POSITION, modelview_light);
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light);
+ glLightfv(GL_LIGHT1, GL_SPECULAR, specular_light);
+
+ gl::enable(GL_LIGHT1);
+
render::draw_model_fragments(model, modelview_color_primary, modelview_color_secondary, core::application()->time(), true, true, thrust);
render::State::set_normalize(false);
gl::pop();
+ gl::disable(GL_LIGHT1);
+
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
diff --git a/src/ui/modelview.h b/src/ui/modelview.h
index f63dfa8..eb1385e 100755
--- a/src/ui/modelview.h
+++ b/src/ui/modelview.h
@@ -85,6 +85,8 @@ private:
math::Axis modelview_axis;
math::Vector2f modelview_cursor;
bool modelview_dragging;
+
+ float modelscale;
};
}