Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index f3df6c0..448b2ce 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -232,14 +232,26 @@ void pass_prepare(float seconds)
for (std::list<model::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
model::Light *light = (*lit);
- // load flare texture
+ // load light texture
// FIXME optimize
std::stringstream flarename;
flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << light->flare();
light->render_texture = Textures::load(flarename.str());
}
- for (std::list<model::Flare *>::iterator flit = entity->model()->model_flare.begin(); flit != entity->model()->model_flare.end(); flit++) {
+ for(std::list<model::Engine*>::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) {
+ model::Engine *engine = (*eit);
+
+ if (!engine->flare()) engine->engine_flare = 1;
+
+ // load engine texture
+ // FIXME optimize
+ std::stringstream flarename;
+ flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << engine->flare();
+ engine->render_texture = Textures::load(flarename.str());
+ }
+
+ for (std::list<model::Flare *>::iterator flit = entity->model()->model_flare.begin(); flit != entity->model()->model_flare.end(); flit++) {
model::Flare *flare = (*flit);
// load flare texture
@@ -444,7 +456,6 @@ void draw_pass_model_fx()
float t;
size_t flare_texture = Textures::bind("bitmaps/fx/flare00");
- size_t engine_texture = Textures::find("bitmaps/fx/flare01");
gl::enable(GL_TEXTURE_2D);
@@ -464,20 +475,22 @@ void draw_pass_model_fx()
t = (core::application()->time() + entity->state()->fuzz() - (*lit)->offset()) * (*lit)->frequency();
if (!(*lit)->strobe() || (( t - floorf(t)) <= (*lit)->time())) {
- math::Vector3f location = entity->state()->location() + (entity->state()->axis() * (*lit)->location());
+ model::Light *light = (*lit);
+
+ math::Vector3f location = entity->state()->location() + (entity->state()->axis() * light->location());
float light_size = 0.0625 * (*lit)->radius();
- if ((*lit)->render_texture != flare_texture) {
+ if (flare_texture != light->texture()) {
gl::end();
- flare_texture = Textures::bind((*lit)->render_texture);
+ flare_texture = Textures::bind(light->texture());
gl::begin(gl::Quads);
}
math::Color color;
- if ((*lit)->entity()) {
+ if (light->entity()) {
color.assign(entity->color());
} else {
- color.assign((*lit)->color());
+ color.assign(light->color());
}
color.a = 0.8;
gl::color(color);
@@ -514,9 +527,9 @@ void draw_pass_model_fx()
math::Vector3f location = entity->state()->location() + (entity->state()->axis() * flare->location());
float light_size = 0.0625 * flare->radius();
- if (flare->render_texture != flare_texture) {
+ if (flare_texture != flare->texture()) {
gl::end();
- flare_texture = Textures::bind(flare->render_texture);
+ flare_texture = Textures::bind(flare->texture());
gl::begin(gl::Quads);
}
@@ -550,26 +563,22 @@ void draw_pass_model_fx()
// draw model engines for Controlable entities
if (entity->type() == core::Entity::Controlable && entity->model()->model_engine.size()) {
- if (flare_texture != engine_texture) {
- gl::end();
- flare_texture = Textures::bind(engine_texture);
- gl::begin(gl::Quads);
- }
-
float u = static_cast<core::EntityControlable *>(entity)->thrust();
- t = entity->state()->fuzz() + core::application()->time() * 4;
-
- t = t - floorf(t);
- if (t > 0.5)
- t = 1-t;
- t = 0.75f + t/2;
-
for(std::list<model::Engine*>::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) {
- math::Vector3f location = entity->state()->location() + (entity->state()->axis() * (*eit)->location());
- float engine_size = 0.0625 * (*eit)->radius() * t;
- math::Color color(1.0f, 0.0f, 0.0f, 0.9f * u);
+ 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);
+ }
gl::color(color);
glTexCoord2f(0,1);