diff --git a/MarchingCubes.cpp b/MarchingCubes.cpp index c46f936..ea91bc1 100644 --- a/MarchingCubes.cpp +++ b/MarchingCubes.cpp @@ -2,6 +2,8 @@ #include +#include "GL/gl.h" + MarchingCubes::MarchingCubes( const ImplicitSurface& surface, const Cuboid& box, @@ -86,8 +88,24 @@ bool MarchingCubes::march_at(double x, double y, double z, Mesh& output) { }; size_t vert_ids[3]; - for(int i=0; i < 3; ++i) + for(int i=0; i < 3; ++i) { +#ifdef DEBUG_DISPLAY_NORMAL + Point locVert = verts[i] + surface.getCenter(); + Point normal = surface.normal_at(verts[i]); + Point outwards = locVert + normal; + Point inwards = locVert + ((-0.2) * normal); + glBegin(GL_LINES); + glColor3f(1., 0., 0.); + glVertex3f(locVert[0], locVert[1], locVert[2]); + glVertex3f(outwards[0], outwards[1], outwards[2]); + glColor3f(0., 0., 1.); + glVertex3f(locVert[0], locVert[1], locVert[2]); + glVertex3f(inwards[0], inwards[1], inwards[2]); + glEnd(); +#endif // DEBUG_DISPLAY_NORMAL + vert_ids[i] = output.add_vertice(verts[i]); + } for(int i=0; i < 3; ++i) { output.add_face(