FOAM

And another, physics engine. this one looks pretty good.

http://blog.generalrelativity.org/actionscript-30/foam-rigid-body-physics-engine-alpha-release-01/

After playing with FOAM for an evening, I found this engine to be a fairly easy to work with. I did run into a problem where the FOAM Vector class conflicted with the built in Flash Vector class. The Flash Vector class was added in CS4, FOAM obviously was written before this.

The problem could have been circumvented by carefully qualifying package names. This would have been an elegant and intelligent solution. In stead I decided for the more ham fisted approach of changing all instances of the name Vector to VectorPoint.

I just opened all of the files in the org.generalrelativity.foam and subpackages and did a find and replace on each file, replacing Vector for VectorPoint. Don’t forget to change the file name of Vector.as to VectorPoint.as. Compiler errors will often point out any spots where you missed an instance of the name.

The generalrelativity blog posts some FOAM renderers. This are useful files. I packaged them in the org.generalrealtivity.foam.view package. It seemed like a logical place to store them. Don’t forget to change the package declaration at the top of each of these files.

FOAM seems pretty easy to use. Unlike Box2d it uses pixels and stage coordinates to position elements on the stage which made it more intuitive to use. The property names seem very intuitive also. Moving objects look to all be built off the SimpleParticle class. Which has obvious properties like x and y to work with. So, creating any Object that inherits from SimpleParticle, you can position it by setting it’s x and y to stage coordinates. Pretty simple. Almost like working with regular MovieClips.

I did notice that fast moving objects could pass through another object. I assume this is caused when the velocity is great enough that the object moves past the interposing object without intersecting.

Leave a Reply

Your email address will not be published. Required fields are marked *