diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-30 16:43:24 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-30 16:43:24 +0000 |
commit | bdac0333cd47e87442c52c2cd5edb83b3e7b4b5b (patch) | |
tree | 07974b062ea421101e59872ca0eaf28ed74e8cd7 /src/render | |
parent | b9a97161e947995fc5c708a1e61b89785e08feef (diff) |
Disable lighting and texturing while drawing model normals.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 22ff90f..ac74c9c 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -514,6 +514,29 @@ void draw_pass_default() /* ---- Model Fragments -------------------------------------------- */ +void draw_fragment_normals(const model::Fragment *fragment, bool draw_details) +{ + size_t index = fragment->index(); + size_t vertex_count = fragment->structural_size(); + if (draw_details) + vertex_count += fragment->detail_size(); + + gl::begin(gl::Lines); + + const float s = 0.05f; + for (size_t i = 0; i < vertex_count; i++) { + const float *n = &core::game()->vertexarray()->ptr()[(index+i) * 8 + 2]; + const float *v = &core::game()->vertexarray()->ptr()[(index+i) * 8 + 5]; + + //gl::normal(-n[0], -n[1], -n[2]); + gl::vertex(v[0], v[1], v[2]); + + //gl::normal(n[0], n[1], n[2]); + gl::vertex(v[0] + n[0] * s, v[1] + n[1] * s, v[2] + n[2] * s); + } + gl::end(); +} + void draw_fragment(const model::Fragment *fragment, bool draw_details) { size_t index = fragment->index(); @@ -725,6 +748,31 @@ void draw_model_fragments(model::Model *model, gl::color(color); draw_fragment(fragment, detail); + + if (r_normals->value()) { + // force reset of material settings for the next fragment + material = 0; + if (use_light) { + // disable lighting + gl::disable(GL_LIGHTING); + use_light = false; + } + + if (use_env) { + // disable env mapping + gl::disable(GL_TEXTURE_GEN_S); + gl::disable(GL_TEXTURE_GEN_T); + use_env = false; + } + + if (use_texture) { + gl::disable(GL_TEXTURE_2D); + use_texture = false; + } + + color.assign(0.75f, 0.0f, 0.0f); + draw_fragment_normals(fragment, detail); + } } if (group->transform()) { |