Ok. Here's the situation. I have a surface and a point. The point represents a light. The light has a radius, color and intensity value. The intensity value of the light is anywhere from 1 to 0, 1 being full intensity, 0 beign totaly dimmed. The color is just an RGB val used to multiply color components of the light map. My question is, how can I determine the light's point of impact on the surface's plane, and generate a radial lightmap based on the distance of the light from the surface, the radius and the intensity values? I beleive the point of impact is (in pseudo-code):
impactx=light.origin.x - plane.normal.x*dist
impacty=light.origin.y - plane.normal.y*dist
impactz=light.origin.z - plane.normal.z*dist
where dist is:
But I think this may be TOTALY wrong, but it seems right. Anyone have any ideas? Any online docs explaining the same, or near the same situation? Any help on this would be great!
Re: Light mapping
I'm not sure exactly what you mean, but this is the way that I'd do it:
Get the values a, b, and c that describe your polygon, for the equation below:
0 = a*pointOnPoly.x + b*pointOnPoly.y
Then get the minimum distance to the plane using these values (I couldn't fit the z dimensions in the text box ):
MinDist = a*light.ori.x + b*light.ori.y ...
a*norm.x + b*norm.y ...
It's then pretty easy to get the coordinates of the closest point on the polygon if you need it (assuming your normals are normalised):
impactPos.x = light.ori.x + norm.x * MinDist
Presumably, you want to reduce the problem to a 2D one (so that you can get the distance from the light, based on the radial distance on the surface from the impactPos, and the surface normal.)
For large distances you can say (approximately):
lightNorm = radialDist/minDist
lightDist = minDist
And for small distances (or full accuracy) you can say:
lightNorm = inverseTan(radialDist/minDist)
lightDist = sqrRt(minDist^2 + radialDist^2)
I hope that I've explained this properly (besides which, you probably had the right idea yourself anyhow...)