Originally posted by 147-2:
[b]
// normalize
// n = (nx / sqrt(|n|), ny / sqrt(|n|), nz / sqrt(|n|))

nabs = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);

n[0] /= nl; n[1] /= nl; n[2] /= nl;

// where is nl coming from?
// shouldnt it be n[0] /= nabs; … ??

[/b]

Ah, sorry… mixed versions of the code, nabs was named nl before, but it is named nabs in all places of the real code, so this isn’t the problem, I’ve tried with glEnable(GL_NORMALIZE); on, and the normals are still off.

Hmmm, maybe it helps if you specify the problem more precisely. Is the tria/poly not lit? is the reflection not correct?

My first guess would be, the vectors are not correctly defined. I think it should be anti clockwise. Use the right hand rule to check. But you said that you checked that already…

Originally posted by xDigital:
[b]Hmmm, maybe it helps if you specify the problem more precisely. Is the tria/poly not lit? is the reflection not correct?

My first guess would be, the vectors are not correctly defined. I think it should be anti clockwise. Use the right hand rule to check. But you said that you checked that already…

No clue so far
Regards
xDigital[/b]

The reflection is not correct, drawing the normals yields that they are 90 degrees of, in some axis. The vertices are defined in CCW order, as said, I’ve verified this by drawing the back sides in wire frame.

The normal is in the same plane as the polygon, if the polygon is defined in a plane parallel to the x-y, y-z or x-y planes.

I can probably get a screenshot and post a link to it here if the description was fuzzy.

[This message has been edited by kinslayer (edited 02-24-2004).]