Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-12-20 14:54:17 +0000
committerStijn Buys <ingar@osirion.org>2008-12-20 14:54:17 +0000
commitf36ec64b08c791e7b907ed8efd9a2baa44e7f8fd (patch)
treed86d6d948fa35b58b0955d994291e27910355a40 /src/render/draw.cc
parent34747fcb6a29ee573cf432611359ef34fe680dec (diff)
initial support for func_rotate and friends
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc133
1 files changed, 75 insertions, 58 deletions
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) {