Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/render/draw.cc106
1 files changed, 82 insertions, 24 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 47f0d7a..01cddf3 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -611,6 +611,8 @@ void draw_pass_model_fx()
{
float t;
+ size_t circle_texture = Textures::load("bitmaps/fx/circle00");
+
size_t flare_texture = Textures::bind("bitmaps/fx/flare00");
gl::enable(GL_TEXTURE_2D);
@@ -721,32 +723,85 @@ void draw_pass_model_fx()
float u = static_cast<core::EntityControlable *>(entity)->thrust();
- for(model::Model::Engines::iterator eit = entity->model()->engines().begin(); eit != entity->model()->engines().end(); eit++) {
-
- model::Engine *engine = (*eit);
+ if (u > 0) {
+ float fraction = (core::application()->time() + entity->state()->fuzz()) * 4.0f * u;
+ fraction = fraction - floorf(fraction);
- math::Vector3f location = entity->state()->location() + (entity->state()->axis() * engine->location());
- float engine_size = 0.0625 * engine->radius();
- math::Color color(engine->color());
- color.a = 0.9f * u;
-
- if (flare_texture != engine->texture() ) {
- gl::end();
- flare_texture = Textures::bind(engine->texture());
- gl::begin(gl::Quads);
+ for(model::Model::Engines::iterator eit = entity->model()->engines().begin(); eit != entity->model()->engines().end(); eit++) {
+
+ model::Engine *engine = (*eit);
+
+ math::Vector3f location = entity->state()->location() + (entity->state()->axis() * engine->location());
+ float engine_size = 0.0625 * engine->radius();
+ math::Color color(engine->color());
+ color.a = 0.9f * u;
+
+ if (flare_texture != engine->texture() ) {
+ gl::end();
+ flare_texture = Textures::bind(engine->texture());
+ gl::begin(gl::Quads);
+ }
+
+ math::Vector3f quad[4];
+
+ quad[0].assign(entity->state()->axis().up() - entity->state()->axis().left());
+ quad[1].assign(entity->state()->axis().up() + entity->state()->axis().left());
+ quad[2].assign(entity->state()->axis().up() * -1 + entity->state()->axis().left());
+ quad[3].assign(entity->state()->axis().up() * -1 - entity->state()->axis().left());
+
+ gl::color(color);
+ glTexCoord2f(0,1);
+ gl::vertex(location + quad[0] * engine_size);
+ glTexCoord2f(0,0);
+ gl::vertex(location + quad[1] * engine_size);
+ glTexCoord2f(1,0);
+ gl::vertex(location + quad[2] * engine_size);
+ glTexCoord2f(1,1);
+ gl::vertex(location + quad[3] * engine_size);
+ Stats::quads++;
+
+ // draw the engine trail
+ if (flare_texture != circle_texture) {
+ gl::end();
+ flare_texture = Textures::bind(circle_texture);
+ gl::begin(gl::Quads);
+ }
+ color.assign(1.0f, 1.0f);
+ math::Vector3f offset = entity->state()->axis().forward() * engine_size;
+
+ if (fraction)
+ location -= offset * fraction;
+
+ const size_t count = 8;
+ for (size_t i = count; i > 0; i--) {
+ float size = engine_size * 0.8f * (0.4f + ((-fraction + (float) i) / (float) count) * 0.6f);
+ color.a = (0.1f + ((-fraction + (float) i) / (float) count) * 0.7f) * u;
+ gl::color(color);
+ glTexCoord2f(0,1);
+ gl::vertex(location + quad[0] * size);
+ glTexCoord2f(0,0);
+ gl::vertex(location + quad[1] * size);
+ glTexCoord2f(1,0);
+ gl::vertex(location + quad[2] * size);
+ glTexCoord2f(1,1);
+ gl::vertex(location + quad[3] * size);
+ Stats::quads++;
+
+
+ gl::color(color);
+ glTexCoord2f(1,1);
+ gl::vertex(location + quad[3] * size);
+ glTexCoord2f(1,0);
+ gl::vertex(location + quad[2] * size);
+ glTexCoord2f(0,0);
+ gl::vertex(location + quad[1] * size);
+ glTexCoord2f(0,1);
+ gl::vertex(location + quad[0] * size);
+ Stats::quads++;
+
+ location -= offset;
+ }
}
-
- gl::color(color);
- glTexCoord2f(0,1);
- gl::vertex(location + (entity->state()->axis().up() - entity->state()->axis().left()) * engine_size);
- glTexCoord2f(0,0);
- gl::vertex(location + (entity->state()->axis().up() + entity->state()->axis().left()) * engine_size);
- glTexCoord2f(1,0);
- gl::vertex(location + (entity->state()->axis().up() * -1 + entity->state()->axis().left()) * engine_size);
- glTexCoord2f(1,1);
- gl::vertex(location + (entity->state()->axis().up() * -1 - entity->state()->axis().left()) * engine_size);
-
- Stats::quads++;
}
}
}
@@ -899,10 +954,12 @@ void draw(float seconds)
gl::disable(GL_LIGHTING);
gl::enable(GL_BLEND);
+ gl::depthmask(GL_FALSE); // disable depth buffer writing
draw_pass_spacegrid(); // draw the blue spacegrid
Dust::draw(); // draw spacedust
+
draw_pass_model_fx(); // draw entity lights and engines
gl::enable(GL_LIGHTING);
@@ -919,6 +976,7 @@ void draw(float seconds)
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
// GL_BLEND must be enabled for the GUI
}