# Problems calculating true normals

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've made this function to calculate true normals:
Bvertex Bmap::RetNormal(int w, int h) {

Bvertex n1, n2, n3, n, face1;
if (w < 0) w = 0; if (h < 0) h = 0;

n1 = CreateVertex(w, h);
n2 = CreateVertex(w - step, h);
n3 = CreateVertex(w - step, h + step);
n = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w - step, h + step);
n3 = CreateVertex(w, h + step);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w, h + step);
n3 = CreateVertex(w + step, h + step);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w + step, h + step);
n3 = CreateVertex(w + step, h);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w + step, h);
n3 = CreateVertex(w + step, h - step);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w + step, h - step);
n3 = CreateVertex(w, h - step);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w, h - step);
n3 = CreateVertex(w - step, h + step);
face1 = bFunctions::Normal(n1, n2, n3);

n1 = CreateVertex(w, h);
n2 = CreateVertex(w - step, h - step);
n3 = CreateVertex(w - step, h);
face1 = bFunctions::Normal(n1, n2, n3);

n = bFunctions::Normalize(n);

return n;
}


I'm sorry for the less comments.. :) But it doesn't work, i get a kind of weird lighting. I call it in this way:
LoadNormalCoord(w, h, &faces[0], &faces[1]);	// Load the right vertexes into the memory
/*--- Render first triangle ---*/
face = faces[0];						// Put in face the first face

glNormal(RetNormal(w, h));
glVertex(face.v1);						// Render top-left part

glNormal(RetNormal(w+1, h));
glVertex(face.v2);						// Render top-right part

glNormal(RetNormal(w+1, h+1));
glVertex(face.v3);						// Render down-right part

/*--- Render second triangle ---*/

face = faces[1];						// Put in face the second face

glNormal(RetNormal(w, h));
glVertex(face.v1);						// Render top-left part again

glNormal(RetNormal(w+1, h+1));
glVertex(face.v2);						// Render down-right part again

glNormal(RetNormal(w, h+1));
glVertex(face.v3);						// Render down-left part


What am i doing wrong? The calculation of normals doesn't contain any errors (it works with flat normals). Thanks in advance.. [Edited by - programBoy on October 8, 2004 9:22:49 AM]

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 14
• 40
• 63