Thoughts on animation

In the past, the way Doomsday has approached 3D model animation has been exceedingly simple. Since MD2 models are vertex-animated, with a full set of vertices per each frame, Doomsday has simply associated a model frame with each object state. When rendering, the model frame would be selected by looking up which one has been linked with the current state of the object. In other words, each 3D model frame was being treated like a 3D version of the original 2D sprite.

This is quite restricting when it comes to creating nice 3D animations. The first tweak that I applied back in the day was to linearly interpolate vertex positions between frames to make the model animate more smoothly. The second tweak was to allow inserting additional model frames into the interpolation. In practice, writing the DED definitions for such an animation was rather cumbersome, because in DED files model frames were always strictly associated with specific mobj states. One needed to calculate the adjusted interpolation ranges for each segment of the animation manually.

The current objective is to implement skeletal animation. It took me quite some time to rid myself of the old state-based animation mindset and start thinking more in terms of objects and animation sequences. Also, implementing this in practice is only now feasible thanks to the private data that all thinkers can have.

When one looks at how mobj states are actually being used by Doom, it is clear that they implement animation sequences. Therefore, the goal is not to map individual states to model frames, but to map mobj state sequences (of a particular type of object) to animation sequences in a 3D model.

The end result is that the actual current mobj state only indirectly affects how the 3D model is animated, and one is free to animate the model as needed. For instance, skeletal animation makes it possible to animate the feet of a humanoid based on its movement (standing, walking, running), while the torso can animate according to the current action (fire, use, punch, etc.).

In other words, the 3D model is animated as an entity independent of the game mobj. The state and motion of the mobj dictates which animation sequences get started, but the animations then proceed more or less independently of the current mobj state.