Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-11-16 13:53:44 +0000
committerStijn Buys <ingar@osirion.org>2008-11-16 13:53:44 +0000
commit315a8c2dff9b76ac5e1ebbef265f13ac19d65e3d (patch)
treedec6de0bcf7f19dd95b7121f27b185da67cee4e2 /src/render/draw.cc
parent28ba97bdd8fb6ca352dc49dba01a66bd155ad523 (diff)
engine trails
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc114
1 files changed, 75 insertions, 39 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 4f58f3d..a700d14 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -225,8 +225,19 @@ void draw_globe(core::EntityGlobe *globe)
glLightfv(GL_LIGHT1, GL_POSITION, fake_light);
}
}
+
gl::push();
gl::translate(location);
+ gl::multmatrix(globe->axis());
+
+ if (globe->rotationspeed()) {
+ float angle = math::degrees360f(core::application()->time() * globe->rotationspeed());
+ gl::rotate(angle, math::Vector3f::Zaxis());
+ }
+
+ draw_sphere(globe->color(), radius);
+ gl::pop();
+
if(flag_is_set(globe->flags(), core::Entity::Bright)) {
@@ -234,19 +245,16 @@ void draw_globe(core::EntityGlobe *globe)
v.normalize();
float a = dotproduct(v, Camera::axis().forward());
if (a > 0.1f) {
- // FIXME a corona is actually just a giant flare
+ // FIXME a corona is actually just a giant flare
if (!globe->render_texture) {
gl::enable(GL_TEXTURE_2D);
}
Textures::bind("bitmaps/fx/corona");
-
+ /*
if (ext_render(globe)->distance() <= farplane) {
gl::depthmask(GL_FALSE);
- }
-
- //glDisableClientState(GL_VERTEX_ARRAY);
- //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- //glDisableClientState(GL_NORMAL_ARRAY);
+ }*/
+ gl::disable(GL_DEPTH_TEST);
math::Color color(globe->color());
color.a = a - 0.1f;
@@ -256,42 +264,30 @@ void draw_globe(core::EntityGlobe *globe)
gl::begin(gl::Quads);
glTexCoord2f(0,1);
- gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 4.0f);
+ gl::vertex(location+ (Camera::axis().up() - Camera::axis().left()) * radius * 4.0f);
glTexCoord2f(0,0);
- gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 4.0f);
+ gl::vertex(location+ (Camera::axis().up() + Camera::axis().left()) * radius * 4.0f);
glTexCoord2f(1,0);
- gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 4.0f);
+ gl::vertex(location+ (Camera::axis().up() * -1 + Camera::axis().left()) * radius * 4.0f);
glTexCoord2f(1,1);
- gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 4.0f);
+ gl::vertex(location+ (Camera::axis().up() * -1 - Camera::axis().left()) * radius * 4.0f);
gl::end();
Stats::quads++;
-
- //glEnableClientState(GL_VERTEX_ARRAY);
- //glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- //glEnableClientState(GL_NORMAL_ARRAY);
gl::disable(GL_BLEND);
+ /*
if (ext_render(globe)->distance() <= farplane) {
gl::depthmask(GL_TRUE);
- }
+ }*/
if (!globe->render_texture) {
gl::disable(GL_TEXTURE_2D);
}
- }
- }
-
- gl::multmatrix(globe->axis());
-
- if (globe->rotationspeed()) {
- float angle = math::degrees360f(core::application()->time() * globe->rotationspeed());
- gl::rotate(angle, math::Vector3f::Zaxis());
+ gl::enable(GL_DEPTH_TEST);
+ }
}
- draw_sphere(globe->color(), radius);
-
- gl::pop();
if (ext_render(globe)->distance() > farplane) {
@@ -713,28 +709,29 @@ void draw_pass_model_fragments()
void draw_pass_model_fx(float elapsed)
{
- const size_t count = 8; // number of engine trail particles
+ //const size_t count = 8; // number of engine trail particles
float t = 0.0f;
- float u = 0.0f;
+ //float u = 0.0f;
float a = 0.0f;
float light_size = 0.0f;
- float engine_size = 0.0f;
- float trail_size = 0.0f;
+ //float engine_size = 0.0f;
+ //float trail_size = 0.0f;
bool power = true;
+ float thrust;
- math::Vector3f quad[4];
+ //math::Vector3f quad[4];
math::Vector3f location;
math::Vector3f offset;
math::Color color;
model::Light *light;
model::Flare *flare;
- model::Engine *engine;
+ //model::Engine *engine;
math::Axis flare_axis;
- size_t circle_texture = Textures::load("bitmaps/fx/circle01");
+ //size_t circle_texture = Textures::load("bitmaps/fx/circle01");
size_t current_texture = Textures::bind("bitmaps/fx/flare00");
gl::enable(GL_TEXTURE_2D);
@@ -744,6 +741,7 @@ void draw_pass_model_fx(float elapsed)
core::Entity *entity = (*it);
power = true;
+
if ((entity->type() == core::Entity::Dynamic) &&
(static_cast<core::EntityDynamic *>(entity)->eventstate() == core::Entity::NoPower)) {
power = false;
@@ -794,13 +792,24 @@ void draw_pass_model_fx(float elapsed)
// draw flares
for (model::Model::Flares::iterator flit = entity->model()->flares().begin(); flit != entity->model()->flares().end(); flit++) {
flare = (*flit);
-
+
+ // engine flares
+ thrust = 1.0f;
+ if (flare->engine() && ( entity->type() == core::Entity::Controlable)) {
+ core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
+ if ((ec->eventstate() == core::Entity::ImpulseInitiate) || (ec->eventstate() == core::Entity::Impulse)) {
+ thrust = 1.0f;
+ } else {
+ thrust = ec->thrust();
+ }
+ }
+
// strobe frequency
t = 1.0f;
if (flare->strobe())
t = (core::application()->time() + ext_render(entity)->fuzz() - flare->offset()) * flare->frequency();
- if ((!flare->strobe()) || (( t - floorf(t)) <= flare->time())) {
+ if ((thrust > 0 ) && ((!flare->strobe()) || (( t - floorf(t)) <= flare->time()))) {
flare_axis.assign(entity->axis());
if (flare->angle())
flare_axis.change_direction(flare->angle());
@@ -819,10 +828,19 @@ void draw_pass_model_fx(float elapsed)
} else {
color.assign(flare->color());
}
-
+
a = dotproduct(flare_axis.forward(), Camera::axis().forward());
if (a < -0.1f) {
- color.a = -a - 0.1f;
+ a = -a - 0.1f;
+ if (flare->entity()) {
+ color.assign(entity->color());
+ } else if (flare->engine()) {
+ color.assign(entity->model()->enginecolor());
+ a *= thrust;
+ } else {
+ color.assign(flare->color());
+ }
+ color.a = a;
gl::color(color);
glTexCoord2f(0,1);
@@ -840,6 +858,7 @@ void draw_pass_model_fx(float elapsed)
}
}
+/*
// draw model engines for Controlable entities
if ((entity->type() == core::Entity::Controlable) && entity->model()->engines().size()) {
core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
@@ -936,10 +955,27 @@ void draw_pass_model_fx(float elapsed)
}
}
}
- }
+ */
+
+ // draw particles
+ if (ext_render(entity)->particles().size()) {
+ gl::end();
+ gl::disable(GL_CULL_FACE);
+
+ for (RenderExt::Particles::iterator it = ext_render(entity)->particles().begin(); it != ext_render(entity)->particles().end(); it++) {
+ ParticleStream *particles = (*it);
+ particles->draw();
+ }
+
+ gl::enable(GL_CULL_FACE);
+ current_texture = Textures::bind("bitmaps/fx/flare00");
+ gl::begin(gl::Quads);
+ }
+ }
}
gl::end();
+
gl::disable(GL_TEXTURE_2D);
}