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 ) and the cone opening ( degrees/radians ) , how do I find the bounding cone for the light ?

Or bounding pyramid even better, so it doesn`t cause confusion.

Draw it.

Simply draw it from the side (so it’ll be a triangle).

You’ll get something like:

```
L -
/\ |
/ a\ |
/ \ | r
/ \ |
/ \ |
---------- -
|----|
w
```

It’s a simplification of course. Because it’s not really a cone with a flat base. The correct base would be a circular section of a sphere.

L is the position of the spotlight, at the top of the drawing.

a is the angle of the spotlight (i.e. the angle between the vertical and the maximum)

r is the radius of the spotlight

w is the width of the cone at the base.

Of these, r is the difficult one. Because it depends on the lighting falloff. You should look up the lighting section in the red/bluebooks (available in HTML form at the site).

w is simple: it’s equal to r*sin(a)

How you want to store all this stuff and actually use it for something is up to you.

If you want to check anything against the bounding volume, convert it to the bounding volume’s coordinate system, then check.

thanx for the reply, but I said I already know L, a, r and w.

What I can`t do is construct the bounding cone/pyramid for the light ( a pyramid would have 5 vertices for example). I need it to check stuff against this volume, if there`

s any way I can do this with only L,a,r,w then it would be great …

If you are ok with a cone approximation, you can use this…

Given:

L light position

d light direction (unit vector)

r light radius

a opening angle

B = L + d*r is the center of the cone base.

w = r * sin a is the radius of the cone base.

Calculate a vector x that is normal to d. You need a case distinction for that… if cross(d,(1,0,0)) != 0 this is your x, else cross(d,(0,1,0)). You also have to normalize it after that.

Given this x, calculate another vector y = cross(d,x). y should be unit length already, you don’t need to normalize it.

Now the vertices of the cone base are given by:

v(t) = B + w * (x * cos t + y * sin t)

with t varying from 0 to 2pi in as many steps as you want… With these you can draw two triangle fans, one around B, one around L.

Thanx , this is what I needed