Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 52933b7..4392f87 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -535,6 +535,27 @@ void draw_fragment(model::Fragment *fragment, bool draw_details)
Stats::quads += vertex_count / 4;
break;
}
+
+ if (r_normals->value()) {
+ gl::begin(gl::Lines );
+
+ gl::color(1.0f, 0.0f, 0.0f);
+
+ const float s = 0.1f;
+
+ const float *n = core::game()->vertexarray()->normal() + index * 3;
+ const float *v = core::game()->vertexarray()->vertex() + index * 3;
+
+ for (size_t i = 0; i < vertex_count; i++) {
+ gl::normal(-n[i*3], -n[i*3 +1 ], -n[i*3 +2]);
+ gl::vertex(v[i*3], v[i*3 +1 ], v[i*3 +2]);
+
+ gl::normal(n[i*3], n[i*3 +1 ], n[i*3 +2]);
+ gl::vertex(v[i*3] + n[i*3] * s, v[i*3 +1] + n[i*3 +1] * s, v[i*3 +2] + n[i*3+2] * s);
+ }
+ gl::end();
+ }
+
}
void draw_model_fragments(model::Model *model,
@@ -543,6 +564,7 @@ void draw_model_fragments(model::Model *model,
{
// default material, lighted and geometry color
const model::Material *material = 0;
+ math::Color color(1.0f, 0.0f, 1.0f); // current drawing color
bool use_light = true; // gl::disable(GL_LIGHTING) is set
bool use_env = false; // environment mapping
//bool use_color_array = true; // glEnableClientState(GL_COLOR_ARRAY) is set
@@ -587,8 +609,6 @@ void draw_model_fragments(model::Model *model,
glDisableClientState(GL_COLOR_ARRAY);
}*/
- math::Color color;
-
if ((material->flags() & model::Material::Tertiary) == model::Material::Tertiary) {
for (size_t i = 0; i < 3; i++)
color[i] = (color_primary[i] + color_secondary[i]) / 2;
@@ -603,15 +623,12 @@ void draw_model_fragments(model::Model *model,
color.r *= material->color().r;
color.g *= material->color().g;
color.b *= material->color().b;
-
- gl::color(color);
-
} else {
/* if (!use_color_array) {
glEnableClientState(GL_COLOR_ARRAY);
use_color_array = true;
}*/
- gl::color(material->color());
+ color.assign(material->color());
}
if (power && (material->flags() & model::Material::Bright)) {
@@ -671,10 +688,11 @@ void draw_model_fragments(model::Model *model,
glEnableClientState(GL_COLOR_ARRAY);
use_color_array = true;
}*/
- gl::color(1.0f, 0.0f, 1.0f);
+ color.assign(1.0f, 0.0f, 1.0f);
}
}
+ gl::color(color);
draw_fragment(fragment, detail);
}