Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertex Normals

Status
Not open for further replies.

abp

Programmer
Sep 14, 2000
134
FR
Hi All

I know this is not a regular question for this forum. But here goes...

Hi

I am writing an arcade game in OpenGL where I have a lot of cubes with textures to render. I am confused as to the code to be used for calculating the vertex normals of the cube for texturing.

If i have a cube of unit dimension at origin
with edges along the +axes,
what will be the vertex normal of the point say
P( 1,1,1 ). Someone told me it would be
V(1/sqrt(3), 1/sqrt(3), 1/sqrt(3)). Is this true ?
If so, how do you calculate it ?

If there are any CAD/game programmers I am sure they can reply to my question...!

Thanks for your help

abp :cool:


 
If you want to see proper lighting for cube you have to set each vertex 3 times with a different normals for each side.
If you will use "average" normal (sum of normals of each side) for each vertex your cube will be lighted as a sphera.
If it is not important for you and your cube has only 8 verties just try:
Nx = 2*x - a; where x can be only 0 or "a"
same for y,z
where "a" is a side of your cube (I think 1).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top