From 1f0dbeeabdffff096908473168898c5fa63bcff0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 12 Nov 2008 19:01:51 +0000 Subject: make the corona act like a flare --- src/render/draw.cc | 69 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/render/draw.cc b/src/render/draw.cc index 96bc632..2975ecb 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -303,40 +303,47 @@ void draw_globe(core::EntityGlobe *globe) gl::translate(location); if(flag_is_set(globe->flags(), core::Entity::Bright)) { + + math::Vector3f v = globe->location() - Camera::eye(); + v.normalize(); + float a = dotproduct(v, Camera::axis().forward()); + if (a > 0.1f) { + // FIXME a corona is actually just a giant flare + if (!globe->render_texture) { + gl::enable(GL_TEXTURE_2D); + } + Textures::bind("bitmaps/fx/corona"); - if (!globe->render_texture) { - gl::enable(GL_TEXTURE_2D); - } - Textures::bind("bitmaps/fx/corona"); + if (globe->state()->distance() <= farplane) { + gl::depthmask(GL_FALSE); + } + math::Color color(globe->color()); + color.a = a - 0.1f; - if (globe->state()->distance() <= farplane) { - gl::depthmask(GL_FALSE); - } - gl::color(globe->color()); - globe->color().a = 1.0f; - gl::enable(GL_BLEND); - - gl::begin(gl::Quads); - glTexCoord2f(0,1); - gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(0,0); - gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(1,0); - gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 2.0f); - glTexCoord2f(1,1); - gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 2.0f); - gl::end(); - - Stats::quads++; - - gl::disable(GL_BLEND); - if (globe->state()->distance() <= farplane) { - gl::depthmask(GL_TRUE); - } - if (!globe->render_texture) { - gl::disable(GL_TEXTURE_2D); + gl::color(color); + gl::enable(GL_BLEND); + + gl::begin(gl::Quads); + glTexCoord2f(0,1); + gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(0,0); + gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(1,0); + gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 2.0f); + glTexCoord2f(1,1); + gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 2.0f); + gl::end(); + + Stats::quads++; + + gl::disable(GL_BLEND); + if (globe->state()->distance() <= farplane) { + gl::depthmask(GL_TRUE); + } + if (!globe->render_texture) { + gl::disable(GL_TEXTURE_2D); + } } - radius *= 0.5f; } -- cgit v1.2.3