PDA

View Full Version : Drawing Normals as Lines



FrigginFrog
09-28-2011, 04:44 PM
Hi, I've been having real trouble figuring out how to draw normals as lines. Right now for my project I'm working on smoothing out a cylinder. I've created normals for the faces and so far it looks fine. I just can't grasp how to draw lines to indicate where the normals are.
Here's a snipped of code.
// draw bottom boundary:
glBegin ( GL_TRIANGLE_STRIP);
p1[0] = ctx; p1[1] = cty; p1[2] = ctz;
p2[0] = ntx; p2[1] = nty; p2[2] = ntz;
p3[0] = 0; p3[1] = -len; p3[2] = 0;
getNormals( p1, p2, p3, topTriangle);
glNormal3f(topTriangle[0],topTriangle[1],topTriangle[2]);
glVertex3d ( cbx, cby, cbz ); glVertex3d ( nbx, nby, nbz ); glVertex3d ( 0, -len, 0 );
glEnd();

This is for the bottom circle of my cylinder.

Any help would be greatly appreciated.

V-man
09-29-2011, 03:58 AM
The starting point of the line will be the vertex.
The end point will be thevertex+normal * some_length_factor


This is not a end point. This is just a vector.
p2[0] = ntx; p2[1] = nty; p2[2] = ntz;