diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 61 | ||||
-rw-r--r-- | src/render/textures.cc | 9 | ||||
-rw-r--r-- | src/render/textures.h | 3 |
3 files changed, 63 insertions, 10 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 5627ac6..7342b69 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -385,7 +385,7 @@ void draw_pass_model_fx() { gl::translate(entity->location()); gl::multmatrix(entity->axis()); - draw_model_engines((core::EntityControlable *)entity); +// draw_model_engines((core::EntityControlable *)entity); draw_model_shield((core::EntityControlable *)entity); gl::pop(); } @@ -397,8 +397,11 @@ void draw_pass_model_fx() { /* draw model lights */ void draw_pass_model_lights() { - //glPointSize(10); + 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); gl::begin(gl::Quads); @@ -406,11 +409,13 @@ void draw_pass_model_lights() for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { core::Entity *entity = (*it).second; - if (test_drawfx_distance(entity) && (entity->model()->model_light.size())) { - + if (test_drawfx_distance(entity)) { + + // draw model lights for (std::list<model::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) { + // strobe frequency - float t = 1.0f; + t = 1.0f; if ((*lit)->strobe()) t = (core::application()->time() + entity->fuzz() + (*lit)->offset()) * (*lit)->frequency(); @@ -432,22 +437,58 @@ void draw_pass_model_lights() gl::vertex(location + (camera_axis.up() - camera_axis.left()) * light_size); glTexCoord2f(0,0); gl::vertex(location + (camera_axis.up() + camera_axis.left()) * light_size); - glTexCoord2f(-1,0); + glTexCoord2f(1,0); gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size); - glTexCoord2f(-1,1); + glTexCoord2f(1,1); gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size); Stats::quads++; } - } + } + + // 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->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->location() + (entity->axis() * (*eit)->location()); + float engine_size = 0.0625 * (*eit)->radius() * t; + + math::Color color(1.0f, 0.0f, 0.0f, 0.9f * u); + + gl::color(color); + glTexCoord2f(0,1); + gl::vertex(location + (camera_axis.up() - camera_axis.left()) * engine_size); + glTexCoord2f(0,0); + gl::vertex(location + (camera_axis.up() + camera_axis.left()) * engine_size); + glTexCoord2f(1,0); + gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * engine_size); + glTexCoord2f(1,1); + gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * engine_size); + + Stats::quads++; + } + } } } gl::end(); gl::disable(GL_TEXTURE_2D); - //glPointSize(1); - } void draw_pass_model_radius() diff --git a/src/render/textures.cc b/src/render/textures.cc index 6880d87..eef5f1d 100644 --- a/src/render/textures.cc +++ b/src/render/textures.cc @@ -110,6 +110,15 @@ size_t Textures::load(std::string name) return id; } +size_t Textures::find(std::string name) +{ + size_t id = 0; + iterator it = registry.find(name); + if (it != registry.end()) + id = (*it).second; + return id; +} + size_t Textures::bind(std::string name) { size_t id = 0; diff --git a/src/render/textures.h b/src/render/textures.h index ad38451..f8e35b3 100644 --- a/src/render/textures.h +++ b/src/render/textures.h @@ -39,6 +39,9 @@ public: /// bind a texture for OpenGL usage static size_t bind(size_t texture); + /// find the texture index for a given name + static size_t find(std::string name); + private: static void clear(); |