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')
-rw-r--r--src/render/draw.cc32
-rw-r--r--src/render/render.cc4
-rw-r--r--src/render/render.h2
3 files changed, 31 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);
}
diff --git a/src/render/render.cc b/src/render/render.cc
index ce23645..e37f5f2 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -34,6 +34,7 @@ core::Cvar *r_sky = 0;
core::Cvar *r_wireframe = 0;
core::Cvar *r_mipmap = 0;
core::Cvar *r_collision = 0;
+core::Cvar *r_normals = 0;
void func_list_textures(std::string const &args)
{
@@ -68,6 +69,9 @@ void init(int width, int height)
r_wireframe = core::Cvar::get("r_wireframe", "0", core::Cvar::Archive);
r_wireframe->set_info("[bool] render wireframe");
+ r_normals = core::Cvar::get("r_normals", "0", core::Cvar::Archive);
+ r_normals->set_info("[bool] render face normals");
+
r_grid = core::Cvar::get("r_grid", "0", core::Cvar::Archive);
r_grid->set_info("[bool] render the space grid");
diff --git a/src/render/render.h b/src/render/render.h
index 54205bc..a453464 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -48,6 +48,8 @@ namespace render {
extern core::Cvar *r_sky;
/// render wireframe models
extern core::Cvar *r_wireframe;
+ /// render vertex normals
+ extern core::Cvar *r_normals;
/// render collision
extern core::Cvar *r_collision;
/// use hardware generated mipmaps (requires OpenGL 1.4, does not work on all cards)