###

» Fri Dec 31, 2010 5:54 pm

for lighting I used two edges of the cube as vectors per face found the cross product to get a 3rd vector that gave me the normal of the cubes face, and then found the dot product of that normal vector and an unchanging "light direction vector" (specified with the variables 'Lx' 'Ly' and 'Lz') that belong to the object L (L is just an object i use to store variables, because its faster to write L than global('etc') all the time), anyways, i find the dot product using the components of the two vectors, then i find the norm of those vectors with distance formula sqrt(x^2+y^2+z^2), the norm of the light is precomputed in the variable ('Ln'). with the norms and the dot product i can get the angle between the vectors that they form in their unique plane, by dividing the dot product by the product of the two norms, and then finding the arccosine of that value. the lighting from therein is just setting the filter of the face to a scaled value of that angle difference. R=G=B=('Anglebetween'/180)*255