From 25bcd92706ce2cd6aee24cfb81e9ff2fd7dd4820 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 11 Aug 2009 11:49:12 +0000 Subject: misc_model support --- src/render/draw.cc | 28 ++++++++++++++++++++++------ src/render/draw.h | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/render') diff --git a/src/render/draw.cc b/src/render/draw.cc index c4c18c3..339f127 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -25,11 +25,13 @@ namespace render size_t Stats::tris = 0; size_t Stats::quads = 0; +size_t Stats::fragments = 0; void Stats::clear() { tris = 0; quads = 0; + fragments = 0; } math::Vector3f v0(1, -1, 1); @@ -556,6 +558,7 @@ void draw_fragment(model::Fragment *fragment, bool draw_details) gl::end(); } + Stats::fragments++; } void draw_model_fragments(model::Model *model, @@ -579,12 +582,25 @@ void draw_model_fragments(model::Model *model, model::FragmentGroup *group = (*git); - if (group->type() == model::FragmentGroup::Rotate) { + if (group->transform()) { gl::push(); - gl::translate(group->location()); - float rotation_angle = math::degrees360f(core::application()->time() * group->speed()); - gl::rotate(-rotation_angle, group->axis().forward()); - gl::translate(group->location()* -1.0f); + //gl::translate(group->location()); + // FIXME this will go wrong if a Rotate group is imported as submodel + if (group->type() == model::FragmentGroup::Rotate) { + gl::translate(group->location()); + float rotation_angle = math::degrees360f(core::application()->time() * group->speed()); + gl::rotate(-rotation_angle, group->axis().forward()); + gl::translate(group->location()* -1.0f); + } else { + float s = group->scale(); + if (s == 0.0f) + s = 1.0f; + gl::scale(s, s, s); + gl::translate(group->location() / s); + } + + + } for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) { @@ -731,7 +747,7 @@ void draw_model_fragments(model::Model *model, draw_fragment(fragment, detail); } - if (group->type() == model::FragmentGroup::Rotate) { + if (group->transform()) { gl::pop(); } } diff --git a/src/render/draw.h b/src/render/draw.h index 14a9767..382d7cd 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -37,6 +37,7 @@ public: static size_t tris; static size_t quads; + static size_t fragments; }; } -- cgit v1.2.3