Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Overlapping polygons (https://forums.graalonline.com/forums/showthread.php?t=78200)

DustyPorViva 01-03-2008 08:14 AM

Overlapping polygons
 
So I started a lantern script. This works by drawing a circle with polygons around the player. Great! Problem is, I want to introduce multiple lightsources. When polygons overlap each other, it inverses the overlapping polygons. This means I simply can't just add each lightsource. Here's a screencap that shows what's going on:
http://img115.imageshack.us/img115/6...lanternfr4.jpg
How can I fix this? I know it's going to involved a bit of math... and I'm not that great at it, so go easy on me, please!

Angel_Light 01-03-2008 08:23 AM

What are the layers of the Polygons?

DustyPorViva 01-03-2008 08:28 AM

It's all one polygon.

Angel_Light 01-03-2008 08:48 AM

well when ever you cross a polygon they do that intersect punch out as obviously stated before. Maybe just make another polygon?

DustyPorViva 01-03-2008 08:52 AM

Different polygons overlapping does not invert the polygon, so that would mean I'd have to add it to the polygon array... and it would involve calculating the precise coordinates to overlap it with to show it right. I don't think it needs to get that complicated.

coreys 01-05-2008 06:26 AM

Eh, polygons are kinda *****y, really. It's gotta be just right. How exactly are you doing this right now? I imagine it'd have to work drastically different for multiple light sources.

DustyPorViva 01-05-2008 06:38 AM

Actually it works quite great, with different light sources of different sizes. It's just the inverting that's causing problems.

hotrian 01-19-2008 02:20 AM

1 Attachment(s)
I know this isn't the best way to do it, but I thought I'd post my attempt anyway
It works, but if there are too many points it lags like crazy ( Granted, my computer is rather bad, but still) And even so, if you use too few points ( less than 360 / ( 36 / 4)) it will clip the shape too much, and glitch out.

Based on your last post, you have modifiable sizes, I'm sure that wouldn't be too hard for you too add to this system, though I'm using fixed light sizes.

this.lightSize modifies the size,
this.shapeIncrease modifies how many points are on the shape
this.shapeCheck modifies how far it checks in deviation to a point, before deciding it's clipping one too close already

this.lightSources is the array of objects, currently it's adding all players in the level as a light source... so don't try this in a populated level.. lol..

near the bottom you find an f for below it there's
PHP Code:

if ( && !temp.searchNextPoint

that check tells how close a point needs to be, before the script decides the next point it does locate, is actually from another source ( this makes it so diffrent light sources don't clip together unless they're close enough)

the incriments to the f for alter how fast it spreads outwards, in attempt to locate the next point.

The system first locates the closest light to the top left of the level, then it locates each point of that light, by determining which point is closest to the one it's at, without being the last. If a light point is too far from the last, it decides it's another light source and marks that to be a seamless return point, so that the polygon doesn't reclip itself when it returns.

All in all, I'm sure there's a much better way of going about this.


I was going to paste it under CODE or PHP tags, but apparently the server doesn't understand when I try to paste too much or something.. I'll just use attachments

DustyPorViva 01-19-2008 02:25 AM

Wow, someone finally responded! I'm not home right now, but I'll have to try it out when I do get home. Thanks!


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

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