From 6c2075993d68dbacf011756508f957cea1bde845 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 27 Mar 2011 15:19:19 +0000 Subject: Corrected rotating fragmentgroups imported from submodels. --- src/render/draw.cc | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'src/render') diff --git a/src/render/draw.cc b/src/render/draw.cc index 48e53a2..ecabe21 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -662,30 +662,26 @@ void draw_model_fragments(model::Model *model, for (model::Model::Groups::const_iterator git = model->groups().begin(); git != model->groups().end(); git++) { const model::FragmentGroup *group = (*git); + gl::push(); - if (group->transform()) { - gl::push(); - - gl::translate(group->location()); - - if (group->type() == model::FragmentGroup::Rotate) { - const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::application()->time()) * group->speed()); - gl::rotate(-rotation_angle, group->axis().forward()); - - } else if (group->type() == model::FragmentGroup::Move ) { - const float speed = group->distance() / group->speed(); // units per second - math::Vector3f translation(group->axis().forward() * group->distance()); - translation *= sinf((group->engine() ? enginetime : core::application()->time()) * M_PI * speed) * 0.5f + 0.5f; - gl::translate(translation); - } else { - gl::multmatrix(group->axis()); - } + gl::translate(group->location()); + gl::multmatrix(group->axis()); + const float s = group->scale(); + if (s) + gl::scale(s, s, s); + + if (group->type() == model::FragmentGroup::Rotate) { + const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::game()->time()) * group->speed()); + gl::rotate(-rotation_angle, group->movement()); - const float s = group->scale(); - if (s) - gl::scale(s, s, s); + } else if (group->type() == model::FragmentGroup::Move ) { + const float speed = group->distance() / group->speed(); // units per second + math::Vector3f translation(group->movement() * group->distance()); + translation *= sinf((group->engine() ? enginetime : core::application()->time()) * M_PI * speed) * 0.5f + 0.5f; + gl::translate(translation); } + for (model::FragmentGroup::Fragments::const_iterator fit = group->fragments().begin(); fit != group->fragments().end(); fit++) { const model::Fragment *fragment = (*fit); @@ -861,9 +857,7 @@ void draw_model_fragments(model::Model *model, } } - if (group->transform()) { - gl::pop(); - } + gl::pop(); } if (!use_light) { -- cgit v1.2.3