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>2009-04-14 20:21:03 +0000
committerStijn Buys <ingar@osirion.org>2009-04-14 20:21:03 +0000
commit4f33f59571f10019c1e7a0e3640b2f69c159a8cf (patch)
tree1e96585325b966efc550a164ab63a519d08144ea
parenta6ecef211a84542b4a68a92e647c8d801fe14a37 (diff)
split entity and model rendering into two functions
-rw-r--r--src/render/draw.cc86
-rw-r--r--src/render/state.cc2
2 files changed, 48 insertions, 40 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 6629ca9..6762b64 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -537,41 +537,18 @@ void draw_fragment(model::Fragment *fragment, bool draw_details)
}
}
-void draw_model_fragments(core::Entity *entity)
+void draw_model_fragments(model::Model *model,
+ const math::Color & color_primary, const math::Color & color_secondary,
+ const bool detail = true, const bool power = true, const float thrust = 0.0f)
{
- using namespace model;
- Model *model = entity->model();
if (!model)
return;
// default material, lighted and geometry color
const model::Material *material = 0;
-
- //bool use_color_array = true; // glEnableClientState(GL_COLOR_ARRAY) is set
bool use_light = true; // gl::disable(GL_LIGHTING) is set
-
- bool power = true;
- float thrust = 0;
-
- if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) {
-
- int state = static_cast<core::EntityDynamic *>(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<core::EntityControlable *>(entity);
-
- if ((ec->state() == core::Entity::Impulse) || (ec->state() == core::Entity::ImpulseInitiate)) {
- thrust = 1.0f;
- } else {
- thrust = ec->thrust();
- }
- }
- }
+ //bool use_color_array = true; // glEnableClientState(GL_COLOR_ARRAY) is set
for (model::Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) {
@@ -587,13 +564,13 @@ void draw_model_fragments(core::Entity *entity)
for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {
- Fragment *fragment = (*fit);
+ model::Fragment *fragment = (*fit);
if (fragment->material() != material) {
material = fragment->material();
if (material) {
- if (material->flags() & Material::Engine) {
+ if (material->flags() & model::Material::Engine) {
/* if (use_color_array) {
glDisableClientState(GL_COLOR_ARRAY);
@@ -602,7 +579,7 @@ void draw_model_fragments(core::Entity *entity)
gl::color(model->enginecolor() * thrust);
- } else if (material->flags() & Material::Tertiary) {
+ } else if (material->flags() & model::Material::Tertiary) {
/* if (use_color_array) {
use_color_array = false;
glDisableClientState(GL_COLOR_ARRAY);
@@ -610,15 +587,15 @@ void draw_model_fragments(core::Entity *entity)
math::Color color;
- if ((material->flags() & Material::Tertiary) == Material::Tertiary) {
+ if ((material->flags() & model::Material::Tertiary) == model::Material::Tertiary) {
for (size_t i = 0; i < 3; i++)
- color[i] = (entity->color()[i] + entity->color_second()[i]) / 2;
+ color[i] = (color_primary[i] + color_secondary[i]) / 2;
- } else if ((material->flags() & Material::Secondary) == Material::Secondary) {
- color.assign(entity->color_second());
+ } else if ((material->flags() & model::Material::Secondary) == model::Material::Secondary) {
+ color.assign(color_secondary);
- } if ((material->flags() & Material::Primary) == Material::Primary) {
- color.assign(entity->color());
+ } if ((material->flags() & model::Material::Primary) == model::Material::Primary) {
+ color.assign(color_primary);
}
color.r *= material->color().r;
@@ -635,12 +612,12 @@ void draw_model_fragments(core::Entity *entity)
gl::color(material->color());
}
- if (power && (material->flags() & Material::Bright)) {
+ if (power && (material->flags() & model::Material::Bright)) {
if (use_light) {
gl::disable(GL_LIGHTING);
use_light = false;
}
- } else if (power && (material->flags() & Material::Engine)) {
+ } else if (power && (material->flags() & model::Material::Engine)) {
if (use_light) {
gl::disable(GL_LIGHTING);
use_light = false;
@@ -665,7 +642,7 @@ void draw_model_fragments(core::Entity *entity)
}
}
- draw_fragment(fragment, ext_render(entity)->detailvisible());
+ draw_fragment(fragment, detail);
}
if (group->type() == model::FragmentGroup::Rotate) {
@@ -682,6 +659,37 @@ void draw_model_fragments(core::Entity *entity)
}*/
}
+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<core::EntityDynamic *>(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<core::EntityControlable *>(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
void draw_model_bbox(model::Model *model)
{
diff --git a/src/render/state.cc b/src/render/state.cc
index cc402ff..2bf50af 100644
--- a/src/render/state.cc
+++ b/src/render/state.cc
@@ -37,7 +37,7 @@ void State::init(int width, int height)
if (major > 1) {
render_has_generate_mipmaps = true;
} else if (major == 1) {
- if (minor >3)
+ if (minor > 3)
render_has_generate_mipmaps = true;
}