Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Goers <mega@osirion.org>2012-01-06 06:38:05 +0000
committerEvan Goers <mega@osirion.org>2012-01-06 06:38:05 +0000
commit6a61bb6ff7847f020c5c53f0cb70b9ba4f35856a (patch)
tree721cb07f19cda8d514019285e411ff57ef09f669 /src/ui/modelview.cc
parent45382662a6835e6d4d6000544cc32119394f49a2 (diff)
Re-enabled modelview lighting, separate from game lighting.
Diffstat (limited to 'src/ui/modelview.cc')
-rwxr-xr-xsrc/ui/modelview.cc35
1 files changed, 33 insertions, 2 deletions
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);