Using Normals for backface-culling...

Blitz3D Forums/Blitz3D Programming/Using Normals for backface-culling...

Here´s a list of all simplifications that can be applyied to the algorythm:

1. There is only ONE polygon object, the normal´s sphere.
2. Its radius is 1.00.
3. Its center point is always located at the world origin, (0.00, 0.00, 0.00).
4. The sphere has a total of 144 polygons.
Of those, 32 are triangles and 112 are quadrangles.
6. If it allows for more optimization, all faces can be handled as triangles, so the sphere is actualy a collection of 144 triangles.
7. The sphere is only drawn in order to check the correctness of the backface culling and lighting. But, in the voxel engine, it is never actualy drawn.
8. The viewing vector is always (0.00, 0.00, 1.00).
There is no camera vector at all. Al changes in the camera position and/or rotation are achieved by moving/scalling/rotating the voxel objects, not the cammera.
9. A voxel original normal is stored as an 8 bit value, holding only two angles, Alpha and betha.
This 8 bits value indexes a table, which has 144 entries, and returns the 3 components of the normal (nx#, ny#, nz#).

a% = int(floor#(Alpha# / 22.50)
b% = int(floor#(Betha# / 22.50)
If (a% > 4) And (a% < 12) Then
a% = (8 - al%) And $0f
b% = be% Xor $08
EndIf

The gamma# is not needed, because these are just the ORIGINAL normals, meaning that no rotation has been applied to them.
I chose to use alpha# and betha# as the indice, just because it is easier to remember, but the normal indices are not required to be related to any angle at all.
(i just did it this way because it makes it easy to find the angle I want in that big orange I have, with the needles stuck in it).

I hope this inromation helps.
Hey, Col... I don´t mean to bother you, but you know 3d maths and I appreciate your help.

I, on the other hand, am not comfortable with normals, dot products, etc...
So, if you can help me get any further...
Thanks a lot,

Rui Barbosa Jr.