diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-30 19:46:10 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-30 19:46:10 +0000 |
commit | 360e51a9e672e301e2147eb06100f7e68dd74654 (patch) | |
tree | 0ba3a91c7b1c7ddc81baa2e18a1bdb4f05b2ae45 /src/ui | |
parent | bdac0333cd47e87442c52c2cd5edb83b3e7b4b5b (diff) |
Render lights and flares in ui::ModelView.
Diffstat (limited to 'src/ui')
-rwxr-xr-x | src/ui/modelview.cc | 100 |
1 files changed, 39 insertions, 61 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index 0b01fb2..8d8adfc 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -13,6 +13,8 @@ #include "render/camera.h" #include "render/draw.h" #include "render/render.h" +#include <sstream> +#include <iomanip> namespace ui { @@ -169,14 +171,9 @@ void ModelView::draw() // 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 - gl::enable(GL_DEPTH_TEST); + gl::enable(GL_DEPTH_TEST); // enable depth test gl::enable(GL_CULL_FACE); // enable culling gl::enable(GL_COLOR_MATERIAL); // enable color tracking @@ -186,73 +183,54 @@ void ModelView::draw() glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); + // apply manipulation + gl::push(); + gl::multmatrix(modelview_axis); + gl::scale(modelscale, modelscale, modelscale); + render::State::set_normalize(true); + + const float thrust = 1.0f; - render::draw_model_fragments(model, core::localplayer()->color(), core::localplayer()->color_second(), core::application()->time(), true, true, 0.0f); + render::draw_model_fragments(model, core::localplayer()->color(), core::localplayer()->color_second(), core::application()->time(), true, true, thrust); render::State::set_normalize(false); + + gl::pop(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); gl::disable(GL_LIGHTING); - gl::disable(GL_COLOR_MATERIAL); // disable color tracking - gl::disable(GL_CULL_FACE); // disable culling + gl::enable(GL_TEXTURE_2D); + gl::enable(GL_BLEND); + gl::depthmask(GL_FALSE); // disable depth buffer writing + + // load model light textures + for (model::Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) { + model::Light *light = (*lit); + + // load light texture + std::stringstream texturename; + texturename << "textures/fx/flare" << std::setfill('0') << std::setw(2) << light->flare(); + light->set_texture(render::Textures::load(texturename.str())); + } + + for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); flit++) { + model::Flare *flare = (*flit); + + // load flare texture + std::stringstream texturename; + texturename << "textures/fx/flare" << std::setfill('0') << std::setw(2) << flare->flare(); + flare->set_texture(render::Textures::load(texturename.str())); + } - gl::enable(GL_BLEND); // enable alpha blending - gl::pop(); + render::draw_model_lights(model, modelscale, math::Vector3f(), modelview_axis, core::localplayer()->color(), thrust, 0.0f); - /* - // draw manipulation marker - if (has_mouse_focus() && modelview_dragging) { - - gl::push(); - gl::multmatrix(modelview_manipaxis); - - const float r = model->radius(); - glAlphaFunc(GL_GREATER, 0.5f); - gl::enable(GL_ALPHA_TEST); - - gl::color(1.0f, 1.0f, 1.0f, 1.0f); - render::Textures::bind("bitmaps/ui/rotate"); - gl::enable(GL_TEXTURE_2D); - - gl::begin(gl::Quads); - - gl::texcoord(0.0f, 0.0f); - gl::vertex(r, 0.0f, r); - - gl::texcoord(1.0f, 0.0f); - gl::vertex(r, 0.0f, -r); - - gl::texcoord(1.0f, 1.0f); - gl::vertex(-r, 0.0f, -r); - - gl::texcoord(0.0f, 1.0f); - gl::vertex(-r, 0.0f, r); - - - gl::texcoord(1.0f, 1.0f); - gl::vertex(r, r, 0.0f); - - gl::texcoord(0.0f, 1.0f); - gl::vertex(r, -r, 0.0f); - - gl::texcoord(0.0f, 0.0f); - gl::vertex(-r, -r, 0.0f); - - gl::texcoord(1.0f, 0.0f); - gl::vertex(-r, r, 0.0f); - - gl::end(); - - gl::disable(GL_TEXTURE_2D); - gl::disable(GL_ALPHA_TEST); - - gl::pop(); - } - */ + gl::disable(GL_TEXTURE_2D); + gl::disable(GL_COLOR_MATERIAL); // disable color tracking + gl::disable(GL_CULL_FACE); // disable culling gl::depthmask(GL_TRUE); // enable depth buffer writing gl::disable(GL_DEPTH_TEST); // disable depth buffer testing |