Help needed calculating vertex normals...

Blitz3D Forums/Blitz3D Programming/Help needed calculating vertex normals...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You simply need to average the normals of the 3 "old" vertices, like this:
norm_x_of_centre_vert# = (norm_x_of_vert_0 + norm_x_of_vert_1 + norm_x_of_vert_2)/3.0
etc.
The reason the normals need to have a length of 1, is that when DirectX calculates the lighting on a mesh, it uses the normals straight out the bag, without unifying them first. Therefore if your normals have a different length the lighting will be either dimmer (length<1.0) or more intense (length>1.0).

Edit: Ohh, you're doing edge subdivisions...Then it's like this::
norm_x_of_centre_vert# = (norm_x_of_vert_0 + norm_x_of_vert_1)/2.0
etc.
And make sure your values are all floats!

Fredborg