Commit 0063193d authored by Christopher Tenter's avatar Christopher Tenter
Browse files

add drawmode face colors + halfedge texcoords + smooth lighting

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20262 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ff97bd47
......@@ -100,7 +100,8 @@ DrawMode CELLS = ModeFlagSet(1) << 28;
DrawMode CELLS_COLORED = ModeFlagSet(1) << 29;
DrawMode HALFEDGES = ModeFlagSet(1) << 30;
DrawMode HALFEDGES_COLORED = ModeFlagSet(1) << 31;
DrawMode UNUSED = ModeFlagSet(1) << 32;
DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED = ModeFlagSet(1) << 32;
DrawMode UNUSED = ModeFlagSet(1) << 33;
//== IMPLEMENTATION ==========================================================
......@@ -685,6 +686,7 @@ void initializeDefaultDrawModes( void )
SOLID_FACES_COLORED_FLAT_SHADED. setDrawModeProperties(DrawModeProperties(PRIMITIVE_POLYGON, LIGHTSTAGE_SMOOTH, NORMAL_PER_FACE, COLOR_PER_FACE));
SOLID_FACES_COLORED_SMOOTH_SHADED.setDrawModeProperties(DrawModeProperties(PRIMITIVE_POLYGON, LIGHTSTAGE_SMOOTH, NORMAL_PER_VERTEX, COLOR_PER_FACE));
SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED.setDrawModeProperties(DrawModeProperties(PRIMITIVE_POLYGON, LIGHTSTAGE_SMOOTH, NORMAL_PER_VERTEX, COLOR_PER_FACE, TEXCOORD_PER_HALFEDGE));
SOLID_2DTEXTURED_FACE. setDrawModeProperties(DrawModeProperties(PRIMITIVE_POLYGON, LIGHTSTAGE_UNLIT, NORMAL_NONE, COLOR_NONE, TEXCOORD_PER_HALFEDGE));
SOLID_2DTEXTURED_FACE_SHADED.setDrawModeProperties(DrawModeProperties(PRIMITIVE_POLYGON, LIGHTSTAGE_SMOOTH, NORMAL_PER_FACE, COLOR_NONE, TEXCOORD_PER_HALFEDGE));
......@@ -736,6 +738,9 @@ void initializeDefaultDrawModes( void )
registeredDrawModes_.push_back( DrawModeInternal( "Solid (colored per-face, flat shaded)", SOLID_FACES_COLORED_FLAT_SHADED ) );
registeredDrawModes_.push_back( DrawModeInternal( "Solid (colored per-face, smooth shaded)", SOLID_FACES_COLORED_SMOOTH_SHADED ) );
registeredDrawModes_.push_back(DrawModeInternal("Solid (colored per-face, face textured, smooth shaded)", SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED));
registeredDrawModes_.push_back( DrawModeInternal( "Solid (face textured)", SOLID_2DTEXTURED_FACE ) );
registeredDrawModes_.push_back( DrawModeInternal( "Solid (face textured, shaded)", SOLID_2DTEXTURED_FACE_SHADED ) );
registeredDrawModes_.push_back( DrawModeInternal( "Shader controlled", SOLID_SHADER ) );
......
......@@ -563,6 +563,8 @@ namespace DrawModes {
extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_FLAT_SHADED;
/// draw smooth shaded and colored faces (requires vertex normals and face colors)
extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED;
/// draw per halfedge texture faces modulated with face colors with smooth shading
extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
/// draw per halfedge textured faces
extern ACGDLLEXPORT DrawMode SOLID_2DTEXTURED_FACE;
/// draw per halfedge textured faces
......
......@@ -161,8 +161,12 @@ availableDrawModes() const {
if( mesh_.has_face_normals() )
drawModes |= DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
if( mesh().has_vertex_normals() )
if (mesh().has_vertex_normals()) {
drawModes |= DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED;
if (perFaceTextureCoordsAvailable_)
drawModes |= DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
}
}
if ( mesh_.has_vertex_texcoords2D() ) {
......@@ -512,6 +516,39 @@ draw(GLState& _state, const DrawModes::DrawMode& _drawMode) {
// Rebind the previous texture
ACG::GLState::bindTexture(lastTarget,lastBuffer);
if ((_drawMode & DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED) && mesh_.has_face_colors() && mesh_.has_vertex_normals() && mesh_.has_vertex_texcoords2D() && mesh_.n_faces() > 0)
{
// face colors, texturing via halfedge texcoords, smooth shading of lighting color
Vec4f base_color_backup = _state.base_color();
ACG::GLState::enable(GL_TEXTURE_2D);
ACG::GLState::enable(GL_LIGHTING);
ACG::GLState::shadeModel(GL_SMOOTH);
ACG::GLState::depthRange(0.01, 1.0);
drawMesh_->setSmoothShading();
drawMesh_->usePerVertexNormals();
drawMesh_->usePerFaceColors();
drawMesh_->usePerHalfedgeTexcoords();
GLboolean colorMatEnabled = glIsEnabled(GL_COLOR_MATERIAL);
if (!colorMatEnabled)
ACG::GLState::enable(GL_COLOR_MATERIAL);
drawMesh_->draw(textureMap_, true);
ACG::GLState::depthRange(0.0, 1.0);
if (!colorMatEnabled)
ACG::GLState::disable(GL_COLOR_MATERIAL);
ACG::GLState::disable(GL_TEXTURE_2D);
_state.set_base_color(base_color_backup);
}
if ( ( _drawMode & DrawModes::SOLID_TEXTURED ) && mesh_.has_vertex_texcoords2D())
{
......
......@@ -510,6 +510,7 @@ void TextureNode::enter(GLState& _state , const DrawModes::DrawMode& _drawmode)
DrawModes::SOLID_ENV_MAPPED |
DrawModes::SOLID_2DTEXTURED_FACE |
DrawModes::SOLID_2DTEXTURED_FACE_SHADED |
DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED |
DrawModes::SOLID_SHADER |
open_volume_mesh_texture_draw_modes_ ))
{
......@@ -532,6 +533,9 @@ void TextureNode::enter(GLState& _state , const DrawModes::DrawMode& _drawmode)
ACG::GLState::bindTexture( GL_TEXTURE_2D, textures_[activeTexture_].id );
}
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, tex_mode_ );
// if (_drawmode & DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED)
// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
}
}
......
......@@ -102,6 +102,8 @@ std::vector< QString > drawModeToList(ACG::SceneGraph::DrawModes::DrawMode _draw
draw_modes.push_back("SOLID_FACES_COLORED_FLAT_SHADED");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED)
draw_modes.push_back("SOLID_FACES_COLORED_SMOOTH_SHADED");
if (_drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED)
draw_modes.push_back("SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE)
draw_modes.push_back("SOLID_2DTEXTURED_FACE");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED)
......@@ -162,7 +164,9 @@ ACG::SceneGraph::DrawModes::DrawMode listToDrawMode( std::vector< QString > _dra
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
} else if( _draw_modes[i] == "SOLID_FACES_COLORED_SMOOTH_SHADED" ) {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED;
} else if( _draw_modes[i] == "SOLID_2DTEXTURED_FACE" ) {
} else if (_draw_modes[i] == "SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED") {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
} else if (_draw_modes[i] == "SOLID_2DTEXTURED_FACE") {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE;
} else if( _draw_modes[i] == "SOLID_2DTEXTURED_FACE_SHADED" ) {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED;
......@@ -225,6 +229,8 @@ ACG::SceneGraph::DrawModes::DrawMode descriptionsToDrawMode ( std::vector< QStri
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
} else if( _draw_modes[i] == "Solid (colored per-face, smooth shaded)" ) {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED;
} else if( _draw_modes[i] == "Solid (colored per-face, face textured, smooth shaded)" ) {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
} else if( _draw_modes[i] == "Solid (face textured)" ) {
drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE;
} else if( _draw_modes[i] == "Solid (face textured, shaded)" ) {
......@@ -285,6 +291,8 @@ std::vector< QString > drawModeToDescriptions(ACG::SceneGraph::DrawModes::DrawMo
draw_modes.push_back("Solid (colored per-face, flat shaded)");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED)
draw_modes.push_back("Solid (colored per-face, smooth shaded)");
if (_drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED)
draw_modes.push_back("Solid (colored per-face, face textured, smooth shaded)");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE)
draw_modes.push_back("Solid (face textured)");
if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment