diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-29 13:37:16 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-29 13:37:16 +0000 |
commit | 409d3ce47d8a4d48947c7b19fc2460fd801b742c (patch) | |
tree | 3a6a029bcd1041a9bd88f8868bf11372c91ac5a7 /src/ui/modelview.cc | |
parent | a7808ebdf39b549f4e0df38e6d897caa2dbb24bd (diff) |
Added 'testmodel' function, enabled autoscaling on ui::ModelView
Diffstat (limited to 'src/ui/modelview.cc')
-rwxr-xr-x | src/ui/modelview.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index 1485d79..e715119 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -8,6 +8,7 @@ #include "core/application.h" #include "ui/modelview.h" #include "ui/paint.h" +#include "ui/ui.h" #include "sys/sys.h" #include "render/camera.h" #include "render/draw.h" @@ -53,6 +54,8 @@ void ModelView::set_modelname(const char *modelname) modelview_axis.clear(); modelview_axis.change_direction(180); modelview_axis.change_pitch(-15); + modelview_zoom = 1.0f; + modelview_radius = 0.75f; } void ModelView::set_color(const math::Color & color) @@ -147,13 +150,25 @@ void ModelView::draw() math ::Vector2f center(global_location() + size() * 0.5f); gl::clear(GL_DEPTH_BUFFER_BIT); + + 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(); // gl 3d mode - render::Camera::frustum_default(modelview_zoom * model->radius(), center.x(), center.y()); + render::Camera::frustum_default(modelview_zoom, center.x(), center.y()); + + // reset lighting + render::pass_reset_lights(); + // enable lighting + gl::enable(GL_LIGHTING); + // apply manipulation gl::push(); gl::multmatrix(modelview_axis); + gl::scale(modelscale, modelscale, modelscale); gl::disable(GL_BLEND); gl::depthmask(GL_TRUE); // enable writing to the depth buffer @@ -162,15 +177,16 @@ void ModelView::draw() gl::enable(GL_CULL_FACE); // enable culling gl::enable(GL_COLOR_MATERIAL); // enable color tracking - // FIXME - initialize lights - gl::enable(GL_LIGHTING); - // enable vertex arrays glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); + + render::State::set_normalize(true); render::draw_model_fragments(model, core::localplayer()->color(), core::localplayer()->color_second(), core::application()->time(), true, true, 0.0f); + + render::State::set_normalize(false); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); |