This week I’ve been working on creating a liquid effect in Flash. After a little research and a relapse to my got old 3D days I remembered a principle called ‘Metaballs‘ or ‘Iso surfaces‘. This is a nice way to replecate fluid dynamics in a 2D or 3D environment. So after some web browsing I found a nice implementation in AS3 by Szataniol. The only problem with this implementation was that it lacked alpha, which I needed to be able to apply some filters for a more realistic effect. This was easily solved by adding an extra render pass to calculate the mask. I’ll post the code for that below.
I hooked up the ‘renderer’ from Szataniol to the Box2D physics engine and starting messing around. I ended up making a couple of different versions:
I’ve set up my Main class in such a way that I can easily switch settings to create the different effects by using a different Model class.
[insert class diagram…]