Hello,

I realize this has probably been asked a hundred times before (I found the exact question at least once, but unfortunately the solution didn’t help me.) I have I function to generate facet normals, which works fabulously. I want to now create per-vertex normals, but that doesn’t work. All of the triangles get shaded wierd. The model looks like it is in camoflouge. It’s splotchy looking. I have pasted the relevant code below. It really didn’t show up well in this forum I don’t think, but hopefully that won’t matter. GL_SMOOTH is enabled, and the facenormals are calculated and working correctly. I’ve checked that the faces really do contain the vertex they are supposed to. I really don’t konw what else it could be, mathematically this is correct I am fairly certain. The drawing code is just a simple set of calls to glColor, glNormal, glVertex in that order. GL drawing mode is GL_TRIANGLES. Any help would be appreciated.

for (i = 0; i < Object->vertexcount; i++){

numfaces = 0;

tempnorm.x = 0.0;

tempnorm.y = 0.0;

tempnorm.z = 0.0;

for (i2 = 0; i2 < Object->facecount; i2++){

if (Object->vertexlist[i2].a == i | | Object->vertexlist[i2].b == i | | Object->vertexlist[i2].c == i){

numfaces++;

tempnorm.x += facenormals[i2].x;

tempnorm.y += facenormals[i2].y;

tempnorm.z += facenormals[i2].z;

}

}

tempnorm = i3dNormalize(tempnorm.x, tempnorm.y, tempnorm.z);

Object->vertices[i].normal = tempnorm;

}