From 37a8c7aa64bdded36f452e6f95c829165d44e792 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 30 Oct 2010 12:38:41 +0000 Subject: moved clientside thrust and power state into render::RenderExt, added engine spawnflag to func_rotate --- src/render/draw.cc | 75 +++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 63 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index ed2c8f7..945e04b 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -565,7 +565,7 @@ void draw_fragment(const model::Fragment *fragment, bool draw_details) void draw_model_fragments(model::Model *model, const math::Color & color_primary, const math::Color & color_secondary, - const bool detail, const bool power, const float thrust) + const float time, const bool detail, const bool power, const float thrust) { // default material, lighted and geometry color const model::Material *material = 0; @@ -588,7 +588,7 @@ void draw_model_fragments(model::Model *model, gl::translate(group->location()); if (group->type() == model::FragmentGroup::Rotate) { - float rotation_angle = math::degrees360f(core::application()->time() * group->speed()); + float rotation_angle = math::degrees360f(time * group->speed()); gl::rotate(-rotation_angle, group->axis().forward()); } else { gl::multmatrix(group->axis()); @@ -609,21 +609,9 @@ void draw_model_fragments(model::Model *model, if (material) { if (material->flags() & model::Material::Engine) { - /* - if (use_color_array) { - glDisableClientState(GL_COLOR_ARRAY); - use_color_array = false; - } - */ color.assign(model->enginecolor() * thrust); } else if (material->flags() & model::Material::Tertiary) { - /* - if (use_color_array) { - use_color_array = false; - glDisableClientState(GL_COLOR_ARRAY); - } - */ if ((material->flags() & model::Material::Tertiary) == model::Material::Tertiary) { for (size_t i = 0; i < 3; i++) @@ -641,12 +629,7 @@ void draw_model_fragments(model::Model *model, color.g *= material->color().g; color.b *= material->color().b; } else { - /* - if (!use_color_array) { - glEnableClientState(GL_COLOR_ARRAY); - use_color_array = true; - } - */ + color.assign(material->color()); } @@ -740,12 +723,6 @@ void draw_model_fragments(model::Model *model, use_texture = false; } - /* - if (!use_color_array) { - glEnableClientState(GL_COLOR_ARRAY); - use_color_array = true; - } - */ color.assign(1.0f, 0.0f, 1.0f); } } @@ -775,42 +752,6 @@ void draw_model_fragments(model::Model *model, use_texture = false; } - /* - if (!use_color_array) { - glEnableClientState(GL_COLOR_ARRAY); - } - */ -} - -void draw_model_fragments(core::Entity *entity) -{ - model::Model *model = entity->model(); - if (!model) - return; - - bool power = true; - float thrust = 0.0f; - - if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) { - - int state = static_cast(entity)->state(); - - if ((state == core::Entity::NoPower) || (state == core::Entity::Destroyed)) { - power = false; - - } else if (entity->type() == core::Entity::Controlable) { - - core::EntityControlable *ec = static_cast(entity); - - if ((ec->state() == core::Entity::Impulse) || (ec->state() == core::Entity::ImpulseInitiate)) { - thrust = 1.0f; - } else { - thrust = ec->thrust(); - } - } - } - - draw_model_fragments(model, entity->color(), entity->color_second(), ext_render(entity)->detailvisible(), power, thrust); } // draw bounding box @@ -892,7 +833,15 @@ void draw_pass_model_fragments() gl::translate(entity->location()); gl::multmatrix(entity->axis()); - draw_model_fragments(entity); + draw_model_fragments( + entity->model(), + entity->color(), + entity->color_second(), + ext_render(entity)->enginetime(), + ext_render(entity)->detailvisible(), + ext_render(entity)->power(), + ext_render(entity)->thrust() + ); if (r_bbox->value()) { gl::color(entity->color()); -- cgit v1.2.3