From b404c2301fde744ed8577724659a095f561d558b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Tue, 13 Feb 2018 16:16:25 +0100 Subject: [PATCH] Add debugging display (on compilation switches) DEBUG_DISPLAY_WIREFRAME: show a wireframe structure DEBUG_DISPLAY_NORMAL: show the vertices' normal vectors --- render/GlutRender.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/render/GlutRender.cpp b/render/GlutRender.cpp index a01eb67..331bc84 100644 --- a/render/GlutRender.cpp +++ b/render/GlutRender.cpp @@ -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,