|
The continuing adventures in Flash Dynamic Shadows Posted by VengantMjolnir on Sun 29 of Nov., 2009 22:33 PST |
In the last couple of weeks I haven't had as much time to work on my own projects as I would like. However, that isn't to say I have been completely without progress. So without further disemination...
I began by refactoring my lighting system a bit. I'm preparing for integration into a game editor so I needed a clear way to seperate out data from behaviour. I decided to go with a factory system, and have a Create() and Destroy() method for my lights and shadow casters. I'm currently instantiating the lights and casters directly. Physics and lighting are something I haven't quite decided how exactly I'm going to set up, but I have it right now that my helper functions for my physics world return a unique ID, and I assign that to the light or caster.
I'm not currently using an actor system for the physics, I'm just assigning the unique ID to the b2Body:m_userData and then returning it. In my custom contact listener I have a simple method:
override public function BeginContact(contact:b2Contact):void
{
super.BeginContact(contact);
var light:LightComponent;
var casterID:int = -1;
if ( contact.GetFixtureA().IsSensor() && !contact.GetFixtureB().IsSensor() )
{
light = LightSystem.Instance.GetLight( contact.GetFixtureA().GetBody().GetUserData() );
casterID = contact.GetFixtureB().GetBody().GetUserData();
}
else if ( contact.GetFixtureB().IsSensor() && !contact.GetFixtureA().IsSensor() )
{
light = LightSystem.Instance.GetLight( contact.GetFixtureB().GetBody().GetUserData() );
casterID = contact.GetFixtureA().GetBody().GetUserData();
}
if ( light != null )
{
light.AddShadowCaster( casterID );
//trace( "Adding contact with light:", light.Id, casterID);
}
}
The last thing I've done so far is start work on a very basic camera and rendering system. So far all I have is a prototype camera movement( hooked to arrow keys ) that shows off just how bare my test setup is. At least everything is moving correctly.
Demo on next page...
| Permalink: tiki-view_blog_post.php?blogId=1&postId=9 |