Commit 1df747d5 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'newDrawMode' into 'master'

added drawmode faces_colored_flat_shaded

See merge request !4
parents 54c01d0b 8271a682
......@@ -338,7 +338,7 @@ void VolumeMeshBufferManager<VolumeMesh>::setOptionsFromDrawMode(ACG::SceneGraph
// colors
if (_drawMode & (mDrawModes.cellsColoredPerCell))
enablePerCellColors();
else if (_drawMode & (mDrawModes.cellsColoredPerFace | mDrawModes.facesColoredPerFace))
else if (_drawMode & (mDrawModes.cellsColoredPerFace | mDrawModes.facesColoredPerFace | mDrawModes.facesColoredPerFaceFlatShaded))
enablePerFaceColors();
else if (_drawMode & (mDrawModes.cellsColoredPerHalfface | mDrawModes.halffacesColoredPerHalfface))
enablePerHalffaceColors();
......@@ -356,7 +356,7 @@ void VolumeMeshBufferManager<VolumeMesh>::setOptionsFromDrawMode(ACG::SceneGraph
//normals
if (_drawMode & (mDrawModes.cellsFlatShaded | mDrawModes.halffacesFlatShaded))
enablePerHalffaceNormals();
else if (_drawMode & (mDrawModes.facesFlatShaded | mDrawModes.facesTexturedShaded))
else if (_drawMode & (mDrawModes.facesFlatShaded | mDrawModes.facesTexturedShaded | mDrawModes.facesColoredPerFaceFlatShaded))
enablePerFaceNormals();
else if (_drawMode & (mDrawModes.cellsSmoothShaded | mDrawModes.facesSmoothShaded | mDrawModes.halffacesSmoothShaded |
mDrawModes.cellsPhongShaded | mDrawModes.facesPhongShaded | mDrawModes.halffacesPhongShaded))
......
......@@ -74,6 +74,7 @@ public:
facesSmoothShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (smooth shaded)")),
facesPhongShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (phong shaded)")),
facesColoredPerFace(ACG::SceneGraph::DrawModes::addDrawMode("Faces (colored per face)")),
facesColoredPerFaceFlatShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (colored per face, flat shaded)")),
facesColoredPerVertex(ACG::SceneGraph::DrawModes::addDrawMode("Faces (colored per vertex)")),
facesTextured(ACG::SceneGraph::DrawModes::addDrawMode("Faces (textured)")),
facesTexturedShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (textured and shaded)")),
......@@ -104,7 +105,7 @@ public:
cellBasedDrawModes(cellsFlatShaded | cellsSmoothShaded | cellsPhongShaded | cellsColoredPerCell | cellsColoredPerFace
| cellsColoredPerHalfface | cellsColoredPerVertex | cellsTransparent),
faceBasedDrawModes(facesFlatShaded | facesSmoothShaded | facesPhongShaded | facesColoredPerFace |
faceBasedDrawModes(facesFlatShaded | facesSmoothShaded | facesPhongShaded | facesColoredPerFace | facesColoredPerFaceFlatShaded |
facesColoredPerVertex | facesTextured | facesTexturedShaded | hiddenLineBackgroundFaces),
halffaceBasedDrawModes(halffacesFlatShaded | halffacesSmoothShaded | halffacesPhongShaded | halffacesColoredPerHalfface
| halffacesColoredPerVertex),
......@@ -128,6 +129,7 @@ public:
ACG::SceneGraph::DrawModes::DrawMode facesSmoothShaded;
ACG::SceneGraph::DrawModes::DrawMode facesPhongShaded;
ACG::SceneGraph::DrawModes::DrawMode facesColoredPerFace;
ACG::SceneGraph::DrawModes::DrawMode facesColoredPerFaceFlatShaded;
ACG::SceneGraph::DrawModes::DrawMode facesColoredPerVertex;
ACG::SceneGraph::DrawModes::DrawMode facesTextured;
ACG::SceneGraph::DrawModes::DrawMode facesTexturedShaded;
......@@ -189,14 +191,15 @@ public:
*/
ACG::SceneGraph::DrawModes::DrawMode getFirstFaceDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
{
if (facesFlatShaded & _drawMode) return facesFlatShaded;
if (facesSmoothShaded & _drawMode) return facesSmoothShaded;
if (facesPhongShaded & _drawMode) return facesPhongShaded;
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerVertex & _drawMode) return facesColoredPerVertex;
if (facesTextured & _drawMode) return facesTextured;
if (facesTexturedShaded & _drawMode) return facesTexturedShaded;
if (facesFlatShaded & _drawMode) return facesFlatShaded;
if (facesSmoothShaded & _drawMode) return facesSmoothShaded;
if (facesPhongShaded & _drawMode) return facesPhongShaded;
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerFaceFlatShaded & _drawMode) return facesColoredPerFaceFlatShaded;
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerVertex & _drawMode) return facesColoredPerVertex;
if (facesTextured & _drawMode) return facesTextured;
if (facesTexturedShaded & _drawMode) return facesTexturedShaded;
if (halffacesFlatShaded & _drawMode) return halffacesFlatShaded;
if (halffacesSmoothShaded & _drawMode) return halffacesSmoothShaded;
......
......@@ -178,6 +178,8 @@ DrawModes::DrawMode VolumeMeshNodeT<VolumeMeshT>::availableDrawModes() const {
result |= drawModes_.facesColoredPerVertex;
if (colorAttrib_.face_colors_available())
result |= drawModes_.facesColoredPerFace;
if (colorAttrib_.face_colors_available())
result |= drawModes_.facesColoredPerFaceFlatShaded;
if (texcoordAttrib_.vertex_texcoords_available())
result |= drawModes_.facesTextured;
if (texcoordAttrib_.vertex_texcoords_available())
......@@ -345,6 +347,19 @@ void VolumeMeshNodeT<VolumeMeshT>::drawFaces(GLState& _state, const DrawModes::D
GLState::disable(GL_LIGHTING);
GLState::shadeModel(GL_SMOOTH);
}
else if (_drawMode & (drawModes_.facesColoredPerFaceFlatShaded))
{
GLState::enable(GL_COLOR_MATERIAL);
GLState::enableClientState(GL_COLOR_ARRAY);
GLState::colorPointer(4, GL_UNSIGNED_BYTE, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getColorOffset()));
GLState::enable(GL_LIGHTING);
GLState::shadeModel(GL_FLAT);
GLState::enableClientState(GL_NORMAL_ARRAY);
GLState::normalPointer(GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getNormalOffset()));
}
else if (_drawMode & (drawModes_.facesTexturedShaded) )
{
glClientActiveTexture(GL_TEXTURE0);
......@@ -641,6 +656,9 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo
// edge based draw mode (except edges on cells) and irregular edges
edgeDrawMode |= _drawMode & (drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges);
// enable twosided lighting for per_face_flat_shaded
if(faceDrawMode & (drawModes_.facesColoredPerFaceFlatShaded))
_state.set_twosided_lighting(true);
if (cellDrawMode)
drawCells(_state, cellDrawMode);
......
Markdown is supported
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