|
More of a maths problem than code: Poly intersection
|
I've made a quite nice shadow calculator that works out what areas should be light and what should be dark. (See attached screenshot)
As it is, my lighting system works really well (and in a lot of levels really looks beautiful) but it just breaks when 2 light sources overlap.
Heres how it works:
-Calculates areas hit by first light source
-Inverts it creating the co-ords for places that are in shadow,
-Does the same for the next light and the calculated poly is added to the existing poly this makes it so that any previously shadow areas inside the 2nd poly are now light...
Which brings us to the problem. Where 2 light areas overlap I get shadow.
I think there are 2 ways of solving this:
1) For any point, if i could work out whether it was inside an existing light source I could work back along the line towards the source until i found shadow and place the point there. Though this could result in small holes the size of the step. I don't know how for any point
2) Calculate the area which the polys overlap (the intersection) and re-add the co-ordinates to the poly. This would work but I have no idea how to work out the intersection of any 2 (never a predictable shape) polys
Is this possible? am I missing an obvious 3rd option?
Thanks. |
__________________

Coming soon (Hopefully:P)
|
Last edited by JkWhoSaysNi; 07-13-2007 at 09:51 PM..
|