PDA

View Full Version : Normals vectors



Erakis
10-29-2001, 09:23 AM
Hello.
Your web site in very interresting (Congratulation !)

I have some problem with (Normals computing).

I already have a vectorial algebra course (School - Mathematic) and I well understand the way of calculating the normal vectors of one facet.
But my problem is knowing which facets do I choose among all those available when I built an object ?

EXEMPLE :
Suppose I want to draw a sphere like this one: http://astronomy.swin.edu.au/pbourke/opengl/sphere/
AND calculating normals facets MANUALLY...

The Problem
Is it better to compute each coords of sphere inside an array and use it after to compute the normal or I could compute it in same time.
I don't understand, cause to compute a normals facets, I need 3 vectors but in this exemple there are only 2 vectors at each glBegin(...) / glEnd.
How can I create the third vector ?

After picking the 3 vector, If understand well I have to do this :
Subtract 2 vector from the 3 vector by a matrix soustraction operation.
Do the Cross product of the result
Normalize the lenght of the result vector.
Could you help me just a little bit cause I don't find any docs on internet.
The docs I found, just related the way to compute normal but not USE it.

Martin
eraquila@bigfoot.com


PS : Thank to help me and excuse me to disturb you.

chowe6685
10-29-2001, 10:07 AM
I'm not sure how you are storing your vertices and faces, so see if this makes sense
you have an array of vertices and an array of faces, each face has is made up of three vertices, represented by the index of the vertex's location in the array of vertices.
Now for each face you want to find two vectors that define it. If you have the triangle ABC, there are many possible vectors, just use AB and BC. Compute the cross product of these two vectors. Doing this for all faces will give you the normals of all faces. You will tend to get better lighting effects if you calculate the normals for each vertex. To do this figure out what faces each vertex is part of, then average the normals of those faces.
I hope that this addresses your question, I realize it is a bit long winded, but it should work