-
Notifications
You must be signed in to change notification settings - Fork 2
Home
hxDynaLight is a geometry based lighting engine.
I guess that's a fancy way of saying that you have to define a polygon or a circle, and it will cast shadows from that object rather than being based on Sprites or Movieclips.
The main class in this kerfuffle is the LightEngine. You can add Light and ILightOccluder objects to the light engine, and then lightEngine.render( myBitmapData) all the pretty lights.
Super quick example:
`var engine:LightEngine = new LightEngine(); var light:Light = new Light( LightTool.radialLightMap( 400, 400, 0.9)); var circle:ShadowCircle = new ShadowCircle( 20); //Random positions light.x = light.y = 100; circle.x = 50; circle.y = 180;
var canvas:BitmapData = new BitmapData( 500, 500, true, 0x00000000); engine.addLight( light); engine.addOccluder( circle); engine.render( canvas);
// Add the canvas BitmapData to the stage to see the result! And make sure to import all necessary classes. `
com.pdev.lighting.tools.LightTool holds 2 static functions. 1 for creating radial gradients as light maps for lights, and another for creating a paletteMap that will translate lightmap values to actual colour values.
I suggest checking out Main.hx to see an example of how to set things up. The same code should apply to as3 users too.
Polygonal Data structures. If you are using the .swc for as3, then you don't need to worry about this, the required classes should all be included in the .swc
If you are using haxe, just run the following command from commandline:
haxelib install polygonal-ds
You can post a comment on my "blog": http://psvilans.wrongbananas.net/dynalight-dynamic-lighting-engine/ I'll definitely see it, and try to answer asap!