RobGalanakis
01-18-2009, 05:27 PM
A light doesn't have a 'normal', if it is directional type of light (spot, direction, etc.) it will have a direction. Both of these are vectors, and are thus comparable. However, you need to determine whether you want to test against the light's direction, or against the vector from face/vertex to light, I cannot tell from your question (the results will be quite different).
You can use a dot product to compare two normalized vectors. A dot product of 1 means they are facing each other perfectly, 0 means they are perpendicular, -1 means they are parallel (ie, the normal is facing directly away from the light).
So for each vert, you can run:
nDotL = dot (getNormal <mesh> <vert_index_integer>) theLight.dir
--nDotL = dot (getNormal <mesh> <vert_index_integer>) ((normalize (getVert <mesh> <vert_index_integer>)) - normalize (theLight.pos)) --would use the vector from light to vert pos instead
if nDotL > 0 then ()
else if nDotL < 0 then ()
else ()
You'd need to use faces instead of verts though.
CGTalk Moderation
01-20-2009, 02:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.