Monday, September 21, 2009

What is Puppeteer

As I mentioned before, the Puppeteer is an animation engine for video games. But not only the engine. It also has a visual pluginable tool for combining and blending animations, customizing transitions, editing scenes, and many more.

Puppeteer consists of 3 main parts: Puppeteer Asset Manager (PAM), Puppeteer Runtime (PR) and Puppeteer Modules (PM). The animation engine is implemented as a Puppeteer Module.

Puppeteer Asset Manager

What is asset management? Let's start by defining what the asset is. An asset is a program data resource that:
1. Is unavoidably required for a normal application run.
2. Never changes during the application lifetime.

The examples of assets are:
1. Config files.
2. Icons and dialog layouts.
3. Meshes and animations in video games.

the best known and the simplest Asset Management software is the Visual Studio resource editor. However, when it comes to video games the assets can be quite big to be linked to the game executable or dll. They are normally shipped as separate files, and the game loads and unloads them as required.

Ideally, an asset manager software should:
1. Allow grouping assets for an easy visual navigation.
2. Provide a simple way to edit assets of different types.
3. Provide a 3-d preview for assets that can be previewed in a 3-d space. For example, meshes, skeletons and 3-d animations.
4. Maintain assets relationships including referencial integrity and constrains.
5. Be extendable. It should provide a clear plugin API for creating new asset types on top of the existing ones. For example creating an asset that references two or more animations and blends them together using different weights. Or an asset that references a number of animations and plays them in a sequence.
6. Provide assets grouping and packaging into the runtime files, which are the asset packages loaded by an actual game.

There is a number of asset management engines for video games on the market. However I am not aware of any good open source asset managers. Collada Asset Manager has announced plans to go open source. But it's not there yet. There are some additional reasons why I think Puppeteer is better than than Collada's product, but I would rather not go into the details just yet.

Puppeteer Runtime

The PR is a static C++ library. As I have mentioned already PAM packs assets into the runtime files, and the PR provides API for loading/unloading these files. It also provides an interface for Puppeteer Plugins for instantiating assets.

Once a game loads a puppeteer runtime file, it can create assets using asset IDs provided by PAM. Puppeteer runtime doesn't make any assumptions of how these assets are used. It's up to the modules to provide the code that uses the data. All PR is doing is loading/unloading and making sure the assets are correctly delivered from the PAM.

Puppeteer Modules

Every Puppeteer Module consists of two parts:
1. A dot net DLL to be used with the PAM.
2. A static C++ lib file to be linked into the game.

Both libraries implement the same assets. The standard Puppeteer package comes with two modules:
1. Animation Core Module.
2. Animation Standard Module.

I also have plans for adding Rendering Core Module. But not in the first release.

Animation Core Module implements the following assets:
1. ChannelsAsset. Defines a set of animatable channels. Every channel has a type, which is either: float, weight, translation, scale, rotation, rotation-translation, or scale-rotation-translation.
2. SkeletonAsset. Defines a skeleton hierarchy and attaches every joint to one of the channels of the ChannelsAsset. It references ChannelsAsset for it.
3. AnimationAsset. A set of key-frames that animate a subset of channels from the ChannelsAsset. Note that Animation doesn't reference Skeleton. They both reference Channels instead. So Animation can animate different Skeletons as long as they belong to the same Channels.
4. ControllerAsset. A base class for all animation controllers. AnimationAsset is the only controller in this package. Standard Puppeteer Plugins will be focusing on implementing controllers.
5. CharacterAsset. Represents a game character. It bounds Skeleton and a set of Meshes with a static scaling array. (The Meshes will not be implemented in the first release, so currently it only bounds skeleton with scaling).
6. TransformationAsset. I don't know mush about this asset yet ;) I didn't implement is yet. May be I will change the name later on, the "transformation" is too long. Anyway, this is a base class for transformation assets.
The runtime calls them after controllers do their job. Transformation assets correct the pose before sending it to the rendering part of a game. Possible implementations are: HumanIkTransformation, FootPlantingTransformation, PhysicsTransformation. And more specific transformations like head tracking, setting emotions/attitude, etc. None of these will be implemented in the first release. But they all are on the to-do list.
7. SceneAsset. A set of character assets with initial positions. It also attaches an initial animation controller to every character. And sets Transformations.

Animation Standard Module currently implements only one asset - the BlendController. It blends a number of animations together. Animators can set a synchronization points for every animation, and the BlendController makes sure all animations reach this point at the same time.

For example animator may want to blend fast running character with a slower running character. The problem is that the steps in two animations are usually not synchronized. So animators may set a sync point when the foots touch the ground. And the controller will slow down or speed up certain animations to make sure they reach these frames at the same time.

Additional controllers I'm planning to add to the Standard Plugins in the nearest future are: BlendArray, BlendSpace and Locomotion. They all will be wrapping BlendController.

Current Status

1. Asset Manager - completed. I am working on optimizations and stress testing.
2. Runtime - almost completed. Everything is implemented but not tested yet.
3. Modules - under development. Channels, Skeleton and Animation are done. I'm working on a Controller, Character and Scene.

No comments:

Post a Comment