Add debugging display (on compilation switches)

DEBUG_DISPLAY_WIREFRAME: show a wireframe structure
DEBUG_DISPLAY_NORMAL: show the vertices' normal vectors
This commit is contained in:
Théophile Bastian 2018-02-13 16:16:25 +01:00
parent aaaebdc042
commit b404c2301f
1 changed files with 23 additions and 0 deletions

View File

@ -126,8 +126,31 @@ void GlutRender::display_mesh(Mesh& mesh) const {
glEnd();
#endif // DEBUG_DISPLAY_NORMAL
#ifdef DEBUG_DISPLAY_WIREFRAME
glBegin(GL_LINES);
for(const Face& face: mesh.get_faces()) {
Point n0 = mesh.get_normal(face[0]),
n1 = mesh.get_normal(face[1]),
n2 = mesh.get_normal(face[2]);
Point p0 = face.pt(0, points) + mesh_center + 0.01 * n0,
p1 = face.pt(1, points) + mesh_center + 0.01 * n1,
p2 = face.pt(2, points) + mesh_center + 0.01 * n2;
glColor3f(0., 1., 0.);
glVertex3f(p0[0], p0[1], p0[2]);
glVertex3f(p1[0], p1[1], p1[2]);
glVertex3f(p1[0], p1[1], p1[2]);
glVertex3f(p2[0], p2[1], p2[2]);
glVertex3f(p2[0], p2[1], p2[2]);
glVertex3f(p0[0], p0[1], p0[2]);
}
glEnd();
#endif // DEBUG_DISPLAY_WIREFRAME
glBegin(GL_TRIANGLES);
glColor3f(1., 1., 1.);
for(const Face& face: mesh.get_faces()) {
Point p0 = face.pt(0, points) + mesh_center,
p1 = face.pt(1, points) + mesh_center,