Programming Phase 2

Download Alpha and Omega v2.7.2.0.0
Binaries as Win32 Installer (4 MB)
Download Alpha and Omega v2.7.2.0.0
Source as Visual Studio 2010 Solution (20 MB)

waving-hairWell, refactoring is basically done. The code isn't perfect of course, but it'll do. I'm pretty happy with how this code-cleanup turned out. It feels like a fresh start, like a spring breeze in my face. Ahh it feels nice. Breath in..., breath out...., doesn't that feel good? mmmmm... Let's just take a moment to enjoy.

...

...

NOW BACK TO WORK! - *grabs whip* - WH..TCH!

The project is a bit too empty if you ask me. It's like saying: "Look we don't have anything to show you, but we have this old stuff you might enjoy". Okay, we'll create a logo-animation, something that demonstrates something cool and fun. Instead of being original, artistic, clever, and other adjective words that describe how posh someone is, we'll just look at something existing that is already awesome to see of we can extract some of its former glory.

 The intro when you're not interacting with it: The intro when you are interacting with it:

When looking at the left one, it seems pretty amazing that the Lionhead Studios logo emerges from an interactive fluid simulation. When taking a closer look at 0:09 ~ 0:10, a lot of little blocks are changing color, so they are just masking their logo to the blocks and change these block-colors within a period of 1 second to make the logo appear. We can even see some of the blocks on the ground change color. It is still very cool, but having a deterministic simulation we can do better. There will be no need to do a run-time masking. This is also a perfect demo for testing not just local determinism (on one computer), but global determinism (on all computers).

Unfortunately I don't have access to a good open-source 2D CPU-based fluid simulation (that allows for an interactive environment). I could write one myself, but that is a lot of work for just a toy-project. So I'll just stick with Farseer physics engine and accept the two downsides:

  • Can't have that many particles interacting with each other.
  • Can't get the simulation to be that swirly.

Implementing it

Implementing it will commence in three phases:

  1. Create a simulation of a box and some particles such that a texture can be projected on all the particles.
  2. Create a tool that runs the simulation till the end (without user-interference), project the image we want to show on the particles and create a texture for all those particles.
  3. Make it interactive somehow.

The reason we're creating a separate tool is because it's likely that we often want to change stuff which might break the determinism. Running the tool will quickly generate a new texture for all those particles so it won't be a drag to change some minor details in the simulation. For example: If we are updating the Farseer physics engine with a new version, the physics results will most likely be different. We won't want to do tedious work just because the result is different after some code changes.

Creating the simulation

cupphysicsAfter playing around a little bit with Farseer (the physics engine) we came up with the design of a box on a magical joint. By giving the box a push, it'll swing from left to right and back again, now we just needed to drop some cubes in this box and map each cube to a texture. We started with a simple colorful placeholder image to check if everything is working as it should be. Just for the fun of it we added a minor reflection on the ground :)

SimulationBox

The simulation is complete, now we just need a tool that projects an image on the cubes. 

Building the tool

Our tool will generate a cubes-texture just as the one above in such manner that the simulation will result in an image appearing. We will just run the simulation till the end and than run a simple loop for all cubes. For each cube we will translate the entire scene in such way that the cube is rendered at the top-left position without any rotation. We than pick that part of the screen and put it in our newly generated texture.

SimulationTextureMap

The tool above generated the following texture:

LionheadLoveletter.Cubes.Frame1

Applying this texture give us the following result:

ResultOfTextureMap

Pretty nifty huh? I actually decided to use a different picture, but the process to create it was the same.

Making it interactive

Currently it's just a simulation without any user-interaction. It we keep it like this we could just as well generated a movie so we need to make it interactive.  I've deviated from the original Lionhead Studio Logo method of interaction and created something completely different. I won't spoil the fun by showing print-screens here, but I think the result is pretty interesting 😀 We even included an easter-egg!

Next Time

Wherever the wind takes me... 

Save Files 

line