Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-21-2007, 06:22 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
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..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.