Commit 16d9cdcf authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis:

Added-two-new-picking-modes-for-only-in-the-front
Added-support-for-new-picking-modes-to-mesh-node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5268 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5348c653
......@@ -81,7 +81,12 @@ enum PickTarget
/// picks verices (may not be implemented for all nodes)
PICK_VERTEX,
/// pick any of the prior targets (should be implemented for all nodes)
PICK_ANYTHING
PICK_ANYTHING,
/// picks only visible front edges (may not be implemented for all nodes)
PICK_FRONT_EDGE,
/// picks only visible front verices (may not be implemented for all nodes)
PICK_FRONT_VERTEX
};
......
......@@ -1117,6 +1117,11 @@ pick(GLState& _state, PickTarget _target)
pick_vertices(_state);
break;
}
case PICK_FRONT_VERTEX:
{
pick_vertices(_state, true);
break;
}
case PICK_ANYTHING:
case PICK_FACE:
......@@ -1131,6 +1136,12 @@ pick(GLState& _state, PickTarget _target)
break;
}
case PICK_FRONT_EDGE:
{
pick_edges(_state, true);
break;
}
default:
break;
}
......@@ -1143,7 +1154,7 @@ pick(GLState& _state, PickTarget _target)
template<class Mesh>
void
MeshNodeT<Mesh>::
pick_vertices(GLState& _state)
pick_vertices(GLState& _state, bool _front)
{
typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()),
v_end(mesh_.vertices_end());
......@@ -1156,6 +1167,31 @@ pick_vertices(GLState& _state)
return;
}
if (_front)
{
enable_arrays(VERTEX_ARRAY);
Vec4f clear_color = _state.clear_color();
Vec4f base_color = _state.base_color();
clear_color[3] = 1.0;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
_state.set_base_color(clear_color);
glDepthRange(0.01, 1.0);
draw_faces(PER_VERTEX);
glDepthRange(0.0, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDepthFunc(GL_LEQUAL);
_state.set_base_color(base_color);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
enable_arrays(0);
}
if (vertexList_ && !updateVertexList_ && _state.pick_current_index () == vertexBaseIndex_)
{
glCallList (vertexList_);
......@@ -1179,6 +1215,9 @@ pick_vertices(GLState& _state)
if (vertexList_)
glEndList ();
if (_front)
glDepthFunc(depthFunc());
}
......@@ -1255,7 +1294,7 @@ pick_faces(GLState& _state)
template<class Mesh>
void
MeshNodeT<Mesh>::
pick_edges(GLState& _state)
pick_edges(GLState& _state, bool _front)
{
typename Mesh::ConstEdgeIter e_it(mesh_.edges_sbegin()),
e_end(mesh_.edges_end());
......@@ -1267,6 +1306,30 @@ pick_edges(GLState& _state)
return;
}
if (_front)
{
enable_arrays(VERTEX_ARRAY);
Vec4f clear_color = _state.clear_color();
Vec4f base_color = _state.base_color();
clear_color[3] = 1.0;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
_state.set_base_color(clear_color);
glDepthRange(0.01, 1.0);
draw_faces(PER_VERTEX);
glDepthRange(0.0, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDepthFunc(GL_LEQUAL);
_state.set_base_color(base_color);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
enable_arrays(0);
}
if (edgeList_ && !updateEdgeList_ && _state.pick_current_index () == edgeBaseIndex_)
{
glCallList (edgeList_);
......@@ -1289,8 +1352,11 @@ pick_edges(GLState& _state)
glEnd();
}
if (faceList_)
if (edgeList_)
glEndList ();
if (_front)
glDepthFunc(depthFunc());
}
//=============================================================================
......
......@@ -126,11 +126,11 @@ protected:
virtual void draw_faces(FaceMode _mode);
// pick vertices
void pick_vertices(GLState& _state);
void pick_vertices(GLState& _state, bool _front = false);
// pick polygons. to be overridden by TriMeshNodeT
void pick_faces(GLState& _state);
// pick edges
void pick_edges(GLState& _state);
void pick_edges(GLState& _state, bool _front = false);
// opengl vertex array stuff
......
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