Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing Normals to Surfaces
    primarykey
    data
    text
    <p>I am trying to draw the normal vectors to a mesh file so I can see how the normal vectors bounce from their respected face. In the draw function, it takes in each face and draws a line from the center point of the face to the (center + normal vector). When I run it, however, I do not see any red lines bouncing off each face. What am I doing wrong here?</p> <pre><code>void drawTria(myFace face) { glNormal3f((face.getNormal().x), (face.getNormal().y), (face.getNormal().z)); wired ? glBegin(GL_LINE_LOOP) : glBegin(GL_POLYGON); glColor3f(0.0, 0.0, 0.5); glVertex3f(vertexList.at(face.v1-1).x, vertexList.at(face.v1-1).y, vertexList.at(face.v1-1).z); glVertex3f(vertexList.at(face.v2-1).x, vertexList.at(face.v2-1).y, vertexList.at(face.v2-1).z); glVertex3f(vertexList.at(face.v3-1).x, vertexList.at(face.v3-1).y, vertexList.at(face.v3-1).z); glEnd(); // Drawing normals glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); glVertex3f(face.getCenter().x, face.getCenter().y, face.getCenter().z); glVertex3f((face.getCenter().x+face.getNormal().x), (face.getCenter().y+face.getNormal().y), (face.getCenter().z+face.getNormal().z)); glEnd(); } myVertex myFace::getCenter() { myVertex center; center.x = (vertexList.at(v1-1).x + vertexList.at(v2-1).x + vertexList.at(v3-1).x)/3; center.y = (vertexList.at(v1-1).y + vertexList.at(v2-1).y + vertexList.at(v3-1).y)/3; center.z = (vertexList.at(v1-1).z + vertexList.at(v2-1).z + vertexList.at(v3-1).z)/3; return center; } myVertex myFace::getNormal() { myVertex normal; normal.x = ((vertexList.at(v2-1).y - vertexList.at(v1-1).y) * (vertexList.at(v3-1).z - vertexList.at(v1-1).z)) - ((vertexList.at(v2-1).z - vertexList.at(v1-1).z) * (vertexList.at(v3-1).y - vertexList.at(v1-1).y)); normal.y = ((vertexList.at(v2-1).z - vertexList.at(v1-1).z) * (vertexList.at(v3-1).x - vertexList.at(v1-1).x)) - ((vertexList.at(v2-1).x - vertexList.at(v1-1).x) * (vertexList.at(v3-1).z - vertexList.at(v1-1).z)); normal.z = ((vertexList.at(v2-1).x - vertexList.at(v1-1).x) * (vertexList.at(v3-1).y - vertexList.at(v1-1).y)) - ((vertexList.at(v2-1).y - vertexList.at(v1-1).y) * (vertexList.at(v3-1).x - vertexList.at(v1-1).x)); return normal; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload