PDA

View Full Version : Box2D Flash AS3 (physics engine)



skatehead
November 15th, 2007, 07:50 PM
Hey guys,
Just wanted to let you know that I've just released Box2DFlashAS3, an open source physics engine ported from Erin Catto's Box2D (http://www.box2d.org/).

Check out the demo here if you're interested. There's also a link to the download on sourceforge.

http://box2dflash.sourceforge.net/

Let me know what you think.

And if you have a digg account, a digg (link) (http://digg.com/programming/Powerful_open_source_physics_engine_Box2D_released _for_Flash_AS3) would be much appreciated (:

mattrock23
November 15th, 2007, 09:14 PM
This is amazing, thanks for posting here(although it probably should have been posted in the scource/experiments forum).

I love how the objects have friction one with another.

skatehead
November 16th, 2007, 04:00 AM
Thanks matrrock23, sorry about posting in the wrong forum, hopefully a mod will see this and move it to where it should be.

rjewson
November 16th, 2007, 10:00 AM
Hey - great work - I just saw your reply to me in the Box2D forum, not checked there in a while.

Charleh
November 16th, 2007, 10:17 AM
Not bad but unfortunately the objects tend to penetrate and 'correct' themselves in real time - and it's also possible to throw objects through other objects if you throw them at a moderate speed - it's a bit inconsistent given the rest of the simulation is actually really good!

Dazzer
November 16th, 2007, 11:43 AM
Another one I just spotted recently is FOAM though quite new

http://blog.generalrelativity.org/?p=17

efnx
November 16th, 2007, 03:19 PM
Hey, that's rad! Looks really great! One thing that I found though is in the compound shapes example it looks like the combined circles are getting mixed up about their center of gravity. Other than that it looks awesome.

skatehead
November 16th, 2007, 04:53 PM
@rje: Thanks, sorry again about the slow response.

@Charleh: The problem is a result of the larger time step (30Hz) in the demos, a performance/accuracy trade off, you can run the simulation at 60Hz by halving the time step and calling Step() twice, such as in this version of the demo. http://box2dflash.sourceforge.net/PhysTest60.html
Still not perfect, but it's a fair bit more stable.

@Dazzer: Thanks for the link, looks pretty impressive so far.

@efnx: Thanks, The center of gravity is off because the second circle has zero density, just to show how the individual shapes that make up a compound object can have different properties. Not a bug, but a feature. :P

mattrock23
November 16th, 2007, 05:16 PM
The only other thing I see is that It doesn't know when you release your mouse outside the screen.

I still really like it though.

Charleh
November 16th, 2007, 06:06 PM
Yeah skatehead its a little more forgiving at that resolution, I'm not expert on physics systems, but is there no way you can predict collision and correct the physics accordingly or is that outside the scope of Flashes processing speed?

efnx
November 16th, 2007, 07:01 PM
Ah, well, nice! I'm impressed. Maybe I'll be using this for something soon!

skatehead
November 16th, 2007, 09:01 PM
@mattrock23: I noticed this too, the mouse release listener isn't being called for some reason, and I have no idea how to fix it or if it's possible, if anyone knows, please let me know. Thanks.

@Charleh: It's absolutely possible (continuous collisions, and more accurate correction), and I can't really comment on the box2D solver because I didn't write it, but it's probably a result of a trade off for performance and more stable stacking. I might ask Erin about the 'glitching' for one frame, I was actually wondering about that myself.

@efnx: Cool, let me know if you do. (:

Sirisian
November 16th, 2007, 10:47 PM
Very nice. I figure it's SAT. Very challenging to make stable physics engines. Also the box tests are awesome! Good performance.

Charleh most physics engines allow penetration. This includes Havok and other high class physics engines. Sacrificing accuracy for speed, which is good most of the time.

minthu
November 17th, 2007, 12:23 AM
This is very interesting and impressive! :pleased:

Charleh
November 17th, 2007, 06:28 AM
Yeah Sirisian, I can understand you might want to sacrifice some accuraccy for speed - just that at the lower resolution its quite easy to make 2 objects completely ignore each other when they are on a collision path - at the higher resolution it works good though! :)

mlk
November 21st, 2007, 10:36 PM
holy cow, i've just lost 20 minutes of my life ! FUNKY. I expect a game from this and soon !

antongranik
November 22nd, 2007, 06:34 AM
Fantastic work!!!

bluerain
July 4th, 2011, 08:45 AM
have downloaded the class file with example, but getting a compilation error. see the error:

1046: Type was not found or was not a compile-time constant: Vector.

What should I do now???

IQAndreas
July 4th, 2011, 06:38 PM
Are you using Flash Builder or Flash Professional?

Make sure you are exporting for FP10, as that's when "Vector" was introduced.

bluerain
July 6th, 2011, 10:40 AM
I have tried with flash professional cs4 and exporting in player version 10, but still getting the error. Can't understand what to do. In this thread I can't post the .zip file for its size, but if you send me a mail on my email id I can reply you back. Sorry for this sir as I don't have your mail id.

IQAndreas
July 8th, 2011, 08:22 AM
I don't have Flash Professional (too expensive, and doesn't work in Linux), so I can't open FLAs. :(

Sorry.

Have you tried just creating a basic "hello world" project from scratch using Box2d instead of starting from this guys starting code?