View Full Version : Normals

aus79er

03-31-2002, 09:43 AM

Hello,

I want to display a 3D block.Now I am displaying it using glBegin(GL_TRIANGLES);

I am getting the x,y,z values from another function.

Now the top surface is not flat.Hence I want to calcuate the normals for the surface.

What is the method to calculate the normals.

I know one method i.e of v1,v2,v3 are the verices of the triangle then the cross product of [v1-v2]x[v2-v3] will give me the normal

IS this the right method...

Thanks

aus

Originally posted by aus79er:

I know one method i.e of v1,v2,v3 are the verices of the triangle then the cross product of [v1-v2]x[v2-v3] will give me the normal

IS this the right method...

Yes, this is the method you must use. However, you must make sure these vertices are in counter-clockwise order.

To calculate normals for each vertex you have to calculate the normals of EACH face the vertex belongs to (using that formula)and sum them together.

Then you only have to normalize the resulting vector. This will average the normals making surfaces look smooth.

You should take care about the way you think about how many faces the vertex belongs to, or you might get sharp edges responding to light the wrong way.

For example: A cube may be defined by 8 vertices, but to make it look right, each vertex needs a normal for each face (3), so it's probably easier to define 24 independent vertices with their own normal.

Hope that helps!

aus79er

03-31-2002, 11:00 AM

Thanks for the help

.............................

As you said

Then you only have to normalize the resulting vector. This will average the normals making surfaces look smooth.

You should take care about the way you think about how many faces the vertex belongs to, or you might get sharp edges responding to light the wrong way.

......................

So in order to normalize is should divde the normal by length i.e sqrt(x*x+y*y+z*z)

ok.

Can anybody explain me how to light using these normal(with details please)...I don't know much details about lighting.

Thanks,

aus

chxfryer

03-31-2002, 08:47 PM

http://www.gametutorials.com

it has a lot of great tutorials

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.