OK, so I've been working on my engine some more and I'm having an issue when calculating the face normals. I've seen a lot of different methods online about calculating the subtraction between vertices in a triangle. The most common appears to be B - A = Vector 1; C - A = Vector 2; Then cross-product the two vectors and you have your face normal.
So, say I have two triangles that compose a tile that is used. The triangles form a triangle mesh in the form of:
AD
BC
Wherein ABC is the first triangle and CDA is the second triangle.
When I run through the calculations to do the face normal of ABC, the vector appears to be in the wrong direction. My directional light is at 0,0,1; the normal is at 0,0,-1 for a flat face (or in the negative Z axis, in general). I was using B - A and C - A; Then I figured it should be B - A and B - C to calculate the correct direction -- and indeed, my face normal goes to +Z.
Is this the correct order to do it? I've googled and haven't found a very good explanation on what the correct order is -- very few sites actually draw it out cleanly to explain which order one should do it in -- they just throw in Spaghetti code (which I'm guilty of copying) to do the basic B - A and C - A -- which was totally wrong.
EDIT: And now I see another topic a little further down that suggest A - B and C - B, wherein B is the common shared point between the two in the triangle... Which again, works to some degree.
At this point, I think I may have my light being setup incorrectly -- which sucks, but it's good to know that my Light is just wrong (so I can fix it). Once I know the correct order, I can proceed, I think, to building this correctly.
Thoughts?
Edited by Terin, 04 August 2012 - 09:07 AM.