Burlington Ducky iPhone App
The people at itemis provide a vast range of skills beyond model-driven engineering. For me, this versatility yielded an iPhone project in cooperation with Weischer Mobile and phi mobile media where a funny marketing app had to be delivered. The design concept presented to Burlington drafted a line (water), a circle (duck) inside a rectangle (iPhone) and an arrow (movement). Some bullet points completed the requirements of the part I was asked to implement. Even though the final app offers some more features such as a movie, funny photo tricks and wallpapers, I was responsible for the ducky only. This is what I came up with:
Under the hood, the animated ducky as well as the illusion of water is based on a hand-crafted physics engine. The water is implemented as a particle-based fluid simulation. Matthias Müller published a paper with the same title and great slides for SIGGRAPH 2007 as a starting point if you are interested in this topic. The ducky itself interacts as rigid body with these particles where buoyancy had been implemented explicitly. Play with Erik Neumann’s demo to have fun with rigid body physics. These concepts had been adjusted and combined with the accelerometer and touch sensors built into the iPhone to let the user interact with the simulation.

Different techniques had been applied to realize the illusion of a splashing ducky
Having just dots and circles as one could look at the physics engine was obviously not the ultimate goal. From the raw data of the simulation the water surface area had to be derived, the ducky had to be put in shape and some smooth animations and sounds were needed to round out the illusion of an interactive bathtub.
Without going into every detail I want to emphasize that the iPhone is not a MacBook Pro. Where you traditionally use marching cubes/squares to convert distinct particles into a cohesive area the processing power of mobile devices requires you to squeeze out every cycle by thinking outside the box and taking advantage of hardware acceleration. In this case, OpenGL ES offers a variety of techniques including framebuffers, blending functions and alpha tests to perform the needed steps by the GPU.

metaball technique from particles using blending and alpha functions
Some other findings during the project include the unreliability of sensor data as well as users’ unpredictable behavior. Be aware that humans and machines act differently under certain circumstances. For applications where the interaction between those both is crucial you should do usability tests early, often and extensively before delivery, again.
The iPhone is different from other mobile devices or the emulator. Generally, floating point arithmetic will be evaluated more efficient than fixed-point. Some GPU operations are executed faster on the device than on the emulator, others are of poor performance though. Therefore, you should profile on the device to test different approaches of your design regularly. And: You must not forget to do so with sound enabled since sound processing might take more than 30% of your overall processing power.
So, go ahead and grab your version of the Burlington Duck on the app store:
If you are interested in details (e.g. “unpredictable human factor”, production of the screencast, etc.), please let me know and use the comment function of this post.

October 2nd, 2009 at 9:16 am
Hey Heiko
Thanks for this article. Good work (the duck as well as the blog). Keep it up!
I’ll try the Burlington Duck on my iPod touch tonight.
–
oliver
October 2nd, 2009 at 4:52 pm
I’m wondering if you’d be willing to share the source code for this app?
Out of personal interest I’ve been wondering how to create a liquid which reacts to the phones orientation.
I understand if not though.
Tom.
October 2nd, 2009 at 11:08 pm
Thank you, Oliver.
Tom,
I am not sure what you are asking for. The water effect uses the idea of metaballs and a derivation of marching squares to convert particles that comply to some rules to a fluid area. One of these rules is gravity where the actual vector is given by the data of the accelerometer. In the mentioned paper Matthias Müller subsums gravity under “external forces”. Does this make sense?
October 3rd, 2009 at 12:13 am
I meant making the app open source.
Thanks for the info as well though! Really great post.
Tom.
October 3rd, 2009 at 6:16 pm
Nice writeup - any chance of open sourcing the application?
October 7th, 2009 at 9:45 pm
Tom, Mr-sk,
I’m afraid I cannot make this work open source. Feel free to ask questions on a conceptual level, though. I’ll be glad to give answers.