Monday, November 30, 2009

More progress on soft-body physics

I made a lot of progress with my soft-body physics engine.
Now the motion looks a lot more natural (if you get the settings right) and you can also do some seriously weird effects.

Now, I've made it so that points which are further away from the center of mass will be affected by more force (this is similar to real-world situations where there is usually more normal force to counterbalance external forces near the center of mass than other areas). This gives the Soft-body a 'wavy' feel.

Press any key to tone-down motion:

The 3 parameters that you can edit here are only a very small fraction of the properties that can now be modified through this engine. In this case the plant was generated such that there is a significant, linear distribution of weight from top to bottom; most of the weight is at the bottom (thus the center of mass is brought closer to the base). This makes things really wavy and it looks as if it is underwater. Each point on the shape is affected by tiny amounts of gravity, but the gravity on the shape itself was set to 0 (so that it would not fly-off the screen).

Here's a more realistic version:

The plant was drawn with a very basic engine which converts hand-drawn lines to a set of soft-body points in code. I plan to make this soft-body generator more robust after I finish the game that I'm currently working on.

Saturday, November 28, 2009

Back to Flash

I've been doing some work in Flash using ActionScript 3.
I've started planning for a whole series of online games that will revolve around a common theme.

So far, I've created some engines including a flexible application page-manager and a pretty cool soft-body physics library that allows soft-body objects to react to physical 'force fields'.

Here's a link (Press any key to reset)

The math used there is fairly heavy. It uses many physical concepts surrounding motion, mass, elasticity (Hooke's law) and linear algebra. It's somewhat physically accurate except for air resistance (I cheated a bit there)... Physicists hate air resistance anyway so who cares.

As you might notice, the body is in a zero-gravity environment with so-called 'air resistance'.
The body is made up of special points of a given mass which react to force vectors, the body itself reacts to 'force beams' which vary in magnitude, area of effect and dissipation effects (distance from source and distance from center of beam).

Obviously there are missing physical elements such as dissipation of force via contact but on the whole it's a nice addition to my portfolio.