Finding bounding cone/pyramid for spot light

Started by
2 comments, last by Zakwayda 18 years, 11 months ago
I have the following problem : given: -a direction vector for the light ( from the origin to the target ) -the lenght of the vector ( the brightness of the light ) -the cone opening ( degrees/radians ) How do I find the bounding cone for the light ? Or bounding pyramid even better, less vertices. I need it for checking stuff against this volume.
Advertisement
You also need the position p of the light.

To test if a vertex is inside the bounding cone, test if the angle between the direction vector of the light and the vector from the lightsource to p is smaller than the cone opening. You get the cosine of the angle between two vectors by normalizing the vectors and then computing the dot product. Compare the cosine with the cosine of the cone opening - if the latter is smaller, the vertex is inside the cone.
That doesn`t work if the surface is not highly tesselated.
So if the surface is huge and the light only lits the middle of the surface then the formula doesn`t work, tryed it already.
That`s why I need the bounding cone, so I can check against each of the planes if a vertex is in front/back of it.
Rather than converting the cone to a bunch of planes, you'd probably be better off intersecting the cone directly with a simple bounding volume. It would be much less expensive and easier to code. For example, you could use bounding spheres. If that is of interest to you, a thread on sphere/cone intersection can be found here.

This topic is closed to new replies.

Advertisement