Yep, doing it in my biggest project right now.
Basically you have a 2D physics world, and a 3D world. Move things around in
2D, then update the position of your 3D objects based on what is happening
there. Does that make sense?
private function this_onEnterFrame (event:Event):void {
Physics.Step (1 / 30, 10, 10);
Physics.ClearForces ();
for each (var body:b2Body in bodies) {
var object:Object3D = body.GetUserData () as Object3D;
object.x = body.GetPosition ().x / PHYSICS_SCALE;
object.y = - body.GetPosition ().y / PHYSICS_SCALE;
}
View.render ();
}
Something like that. Actually, I have separate classes for my 2D and 3D environments
because made things a lot cleaner and easier to maintain, but this is the basic idea. If
you decide to (I didn't, but again I'm on a big project) you can set the 3D object as the
"user data" for each physics body as a quick way to tie them together. Then
after you update your physics, you can reposition your 3D objects, remembering to convert
the coordinates from the 1/30 (or otherwise) physics scale back to real units. You also
might need to apply a negative to the Y value, depending on how your project is set up.
Once you're finished repositioning you can render your 3D world.
On Thu, 11 Feb 2010 02:47:38 -0800, metSyS <[email protected]> wrote:
Is it possble to use Box2DFlash engine with Away3d? If it's possible
someone can show how. Simple example. Some code. Thanks.