By Travis Hopkins on Tuesday, November 22nd, 2011 10:21 AM PST

For many 2D games, a common method of providing character animation is by using a series of static images or sprite-sheets.

Dream Zoo, Zynga’s newest mobile game (available soon for iOS and Android) required a different approach. In Dream Zoo, players collect, breed and care for animals in their very own zoo with thousands of animal varieties possible – from rainbow giraffes to polka dot lions.

(Wireframe Giraffe in Dream Zoo)

Don’t let their size fool you. Thousands of tiny penguins, lemurs, lizards and turtles add up when it comes to game storage.

Rather than use traditional animation techniques in Dream Zoo, we utilized morph target animation, which allows for smoother blends and a larger set of animations, all while taking up less storage.

The challenge with using morph target animation is that storage requires each key-frame have the same number of vertices as the base frame. For example, a vertex comprises 2 short values each for both the UV and Position coordinates, and with 400 vertices per key-frame amounts to over 3KB of data. While this is much less than storage in sprite animation, it’s still costly. Our goal was to allow for the most unique animations possible while staying under the App Store 3G download limit (20MB) for our title, so we looked into vertex compression techniques.

We opted to implement the Edgebreaker, an open source compression technique developed by Prof. Jarek Rossignac at Georgia Tech. We reached out to Prof. Rossignac through our University Relations team, and he was kind enough to lend his expertise.

With this algorithm, we are only storing triangle connectivity information and a sequence of correction values that comprise the deltas between a predicted corner position and the actual corner position in local triangle space.

These deltas end up being very small values, most often zero in case of perfect predictions. The first key-frame of animation uses parallelogram prediction as described in his works for corner locations, but subsequent frames use the previous frames’ positions as predictors.  Since the predictions are made in local (triangle space), this allows for perfect predictions in cases of affine transformations to the mesh. The final delta storage uses a variable bit size encoding routine optimized for small values. Check out the source code for Edgebreaker here.

In the end, we reduced the total size of 300 animations in Dream Zoo from 5.6MB to about 1.7MB, a savings of 70%.

This application of compressed mesh animation is a first for Zynga, and an emerging technique in mobile game development.

Sound off with any questions or comments below. Be sure to check out the source code for Edgebreaker, too.


2 Responses to “Mesh Compression In Dream Zoo”

  1. Karthik Kumar Viswanathan Says:

    Neat! :)

  2. uoxrtintuu Says:

    I reach for Jest when I do purple neutral looks and Naked Lunch for browner looks
    Wholesale Mac Makeup

Leave a Reply

Connect with Facebook