libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
257 stars 82 forks source link

FREQ - Set a light to be active but not illuminate #83

Open adam-law opened 8 years ago

adam-law commented 8 years ago

Hi,

I think this would be a nice feature to have, to use in conjunction with Box2D and sensors. I was able to get the polygon made from the lit area of a light, and use that to create a Box2D body, fixture and sensor from this. However, this makes it reliant on the light being active before being able to get its shape, and sometimes, I don't want the light to be lighting anything, especially when I use the same system to carve out fog of war. Transparency is not an option a lot of imes, because of the blending involved with FoW etc. The best way would be a toggle to keep the light active, but not giving off light, while still interacting (raycasting) with Box2d objects.

An application for this feature would be toggling the light source to shed light, when an entity steps into its sensor range. In my specialized case, once a light starts illuminating, I can combine it's light field to the character's vision field, to create the actual visual area, and trigger/update all reliant controls, e.g. minimap, game events etc.

On a side note, I saw a FREQ for the ability to shed light to an FBO. I could perhaps use that to calculate light fields, cache them, and switch the lights off, although I think my FREQ is a simpler one to implement, and more accessible to novice users.

Thanks.