Hi,
Could someone correct me if I am wrong :
If I want all the normals to point towards the viewer (ie pointing out of the screen), shouldn’t the z value of normal vector lie between 0 and 1. If the z value (normal vector) is negative then the polygon points should be reversed in other direction and new normal should be calculated ie (Vertices 1,2,3 of triangle should be changed to vertices 1,3,2).

If you have a triangle that is facing the viewer (the default with out any transformations) then the normals z should be 1 (x and y = 0), the “length” of the normal should always be 1, if you reverse the triangle it is facing away from the viewer and z should be -1.

But instead of messing with this yourself, you should do a search on google for “cross product”, I am sure youi will find examples in C or any other language you might be interested in, you use this to calculate the normal for you so you don’t need to mess around with it yourself.

What do you mean so that you dont have to mess with it yourself?? To calculate the normal to a triangle all you have to do is turn 2 of its 3 sides into a normalised vector and take the cross product between th resulting vectors to give you the normal. Then you have to normalise it again though. unfortunatly i forgot what the formula for cross product is though…

That was what I meant with “don’t mess with it yourself”, use the crossproduct instead of sitting and try to figure out the normal by hand, sorry if the post was not clear enough.

Originally posted by MrShoe: What do you mean so that you dont have to mess with it yourself?? To calculate the normal to a triangle all you have to do is turn 2 of its 3 sides into a normalised vector and take the cross product between th resulting vectors to give you the normal. Then you have to normalise it again though. unfortunatly i forgot what the formula for cross product is though…

Don’t normalise the vectors till after you get the cross product. Normalising them before (“turn 2 of its 3 sides into a normalised vector”) is just a waste of time.

Hi,
It seems I was not clear what I wrote. Here is my second attempt and please pardon me.
Consider a triangle with co-ordinates (1,0,0),(0,1,0) and (0,0,1). The normal (not normalized) would be (-1,-1,-1). But If I consider (1,0,0),(0,0,1) and (0,1,0) then normal is (1,1,1). My question is which of the above triangle would be facing out towards the screen ?