From f36ec64b08c791e7b907ed8efd9a2baa44e7f8fd Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 20 Dec 2008 14:54:17 +0000 Subject: initial support for func_rotate and friends --- src/render/draw.cc | 133 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 58 deletions(-) (limited to 'src/render') diff --git a/src/render/draw.cc b/src/render/draw.cc index 35b9956..2566dd0 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -575,72 +575,89 @@ void draw_model_fragments(core::Entity *entity) } } - for (model::FragmentGroup::iterator fit = model->worldspawn().begin(); fit != model->worldspawn().end(); fit++) { + for (model::Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { - Fragment *fragment = (*fit); + model::FragmentGroup *group = (*git); - if (fragment->material() != material) { - material = fragment->material(); - - if (material & Material::Engine) { - - if (use_color_array) { - glDisableClientState(GL_COLOR_ARRAY); - use_color_array = false; - } - - gl::color(model->enginecolor() * thrust); - - } else if (material & Material::Tertiary) { - if (use_color_array) { - use_color_array = false; - glDisableClientState(GL_COLOR_ARRAY); - } - - math::Color color; - - if ((material & Material::Tertiary) == Material::Tertiary) { - for (size_t i = 0; i < 3; i++) - color[i] = (entity->color()[i] + entity->color_second()[i]) / 2; - - } else if ((material & Material::Secondary) == Material::Secondary) { - color.assign(entity->color_second()); - - } if ((material & Material::Primary) == Material::Primary) { - color.assign(entity->color()); - } - - if (material & Material::Dark) - color *= 0.5f; - - gl::color(color); - - } else { - if (!use_color_array) { - glEnableClientState(GL_COLOR_ARRAY); - use_color_array = true; - } - } + if (group->type() == model::FragmentGroup::Rotate) { + gl::push(); + gl::translate(group->location() * -1.0f); + float angle = math::degrees360f(core::application()->time() * 90.0f); + gl::rotate(angle, math::Vector3f::Xaxis()); + gl::translate(group->location()); + } - if (power && (material & Material::Light)) { - if (use_light) { - gl::disable(GL_LIGHTING); - use_light = false; - } - } else if (power && (material & Material::Engine)) { - if (use_light) { - gl::disable(GL_LIGHTING); - use_light = false; + for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) { + + Fragment *fragment = (*fit); + + if (fragment->material() != material) { + material = fragment->material(); + + if (material & Material::Engine) { + + if (use_color_array) { + glDisableClientState(GL_COLOR_ARRAY); + use_color_array = false; + } + + gl::color(model->enginecolor() * thrust); + + } else if (material & Material::Tertiary) { + if (use_color_array) { + use_color_array = false; + glDisableClientState(GL_COLOR_ARRAY); + } + + math::Color color; + + if ((material & Material::Tertiary) == Material::Tertiary) { + for (size_t i = 0; i < 3; i++) + color[i] = (entity->color()[i] + entity->color_second()[i]) / 2; + + } else if ((material & Material::Secondary) == Material::Secondary) { + color.assign(entity->color_second()); + + } if ((material & Material::Primary) == Material::Primary) { + color.assign(entity->color()); + } + + if (material & Material::Dark) + color *= 0.5f; + + gl::color(color); + + } else { + if (!use_color_array) { + glEnableClientState(GL_COLOR_ARRAY); + use_color_array = true; + } } - } else { - if (!use_light) { - gl::enable(GL_LIGHTING); - use_light = true; + + if (power && (material & Material::Light)) { + if (use_light) { + gl::disable(GL_LIGHTING); + use_light = false; + } + } else if (power && (material & Material::Engine)) { + if (use_light) { + gl::disable(GL_LIGHTING); + use_light = false; + } + } else { + if (!use_light) { + gl::enable(GL_LIGHTING); + use_light = true; + } } } + + draw_fragment(fragment, ext_render(entity)->detailvisible()); } - draw_fragment(fragment, ext_render(entity)->detailvisible()); + if (group->type() == model::FragmentGroup::Rotate) { + gl::pop(); + } } if (!use_light) { -- cgit v1.2.3