Animations with over 1024 frames

From FSDeveloper Wiki
Revision as of 05:54, 15 March 2009 by Arno (talk | contribs) (Keyframes table)
Jump to: navigation, search

The FS2004 MakeMDL has a limitation build in that it can only export animations with a length of 1024 frames. Because the animation timer is a 18 Hz timer that means that the maximum animation length is only about 55 seconds. That might be fine for a hangar door that is opening or a radar that is rotating, but if you want to make some animated traffic on your airport for example 55 seconds is a bit short.

Unfortunately there is no workaround for this limitation from within GMax, but when you start editing the ASM code of your object it is possible to get beyond 1024 frames for an animation. So the limitation is purely in MakeMDL, not in FS2004 itself. This tutorial will explain which pieces of the ASM code you have to edit to make a longer animation.

Although I will try to explain everything as clearly as possible, I would say this is a task that a novice scenery designer might find a bit hard. But if you are a little bit familiar with ASM tweaking then I hope this tutorial will give you enough knowledge of how the animations are defined to be able to tweak them. Let's get started.

There are two sections of the ASM code where you will have to make changes. The first is the section with the animation tables (ANIP) and the second is the section where the actual interpolation for the animation is performed (ANIC). Which changes to make in these two seconds is discussed next.

Animation tables

In this section I will describe with changes you need to make the animation tables. There are two sorts of tables you will have to change. The first is the table that stores your animation keyframes and the second is the table that is used to determine the frame for the animation timer variable.

Keyframes table

The animation keyframe table stores all the keyframes of your animation. They contain of an frame number and then the actual data. This can be 3 values for a position or 4 for a rotation (given as a quaternion). Below you see a sample of how the keyframe table can look for a simple translation of 1024 frames.

 anim_long_trans_1       label word
     dw           1       ; 1: Point (translation) 
     real4     -1.0       ; Previous panim value
     real4 16 dup (0.0)   ; Cached matrix 
     dw           2       ; number of entries
     real4       0.0,   0.000000,  0.000000,  0.000000 ; frame/x/y/z values
     real4    1023.0, 100.000000,  0.000000,  0.000000 ; frame/x/y/z values

As we want to get a longer animation, it is obvious that we need to add more keyframes to this table. So you will have to add additional lines until you reach the length in frames you want for your animation. Below you see an example where I extended the table to 4096 frames in total.

 anim_long_trans_1       label word
     dw           1       ; 1: Point (translation) 
     real4     -1.0       ; Previous panim value
     real4 16 dup (0.0)   ; Cached matrix 
     dw           5       ; number of entries
     real4       0.0,   0.000000,   0.000000,  0.000000 ; frame/x/y/z values
     real4    1024.0, 100.000000,   0.000000,  0.000000 ; frame/x/y/z values
     real4    2048.0, 100.000000, 100.000000,  0.000000 ; frame/x/y/z values
     real4    3072.0, 200.000000, 100.000000,  0.000000 ; frame/x/y/z values
     real4    4095.0, 200.000000,   0.000000,  0.000000 ; frame/x/y/z values

How you get the data to extend the keyframe table is up to you. Obviously GMax can not export the longer table for you. So you either have to type in the new data manually, or you could export multiple sections of 1024 frames from GMax and stitch them all together manually. In the last case you need to be sure that the frame value continues nicely.

Timer interpolation table

The second type of table that you will have to change is the interpolation table that is used to determine the correct frame number for the animation timer. The animation timer is nothing more than a variable that is increased by 1 every 1/18th of a second. It runs between a value of -32768 and 32767. That is not something we can use to interpolate our keyframes with, so therefore there is an interpolation table that is used to interpolate from the timer variable to a variable that is running between 0 and the amount of frames we want in our animation.

For the situation with 1024 frames that we exported from GMax you see the interpolation table below.

 ** Insert sample of interpolation table **
 

As you can see this table actually consists of three sections. Let's take a look at what these actually do before we start tweaking them. The first part (named mod_1) is used to cut the timer running between -32768 and 32767 into sections running from 0 to 16383. This two step approach is only done because else the second interpolation table would become very long. The picture illustrates how this sawtooth pattern works for interpolating from the timer variable to a temporarily variable running between 0 and 16383.

 ** Insert picture of first sawtooth **

The second table (named mod_2) does the same, but it takes a variable running between 0 and 16383, which is the output of the first table, and then interpolates it so that we get a variable as output that is running between 0 and 1023. Below you see an image of this interpolation pattern as well.

 ** Insert picture of second sawtooth **

The third part of the table (named convert_hi) is used to convert from the integer frame number we have determined in the previous step, to a floating point representation of that frame number. This is because the keyframe data is stored as floating point numbers.

 ** Add more explanation of how this works **

So now we know how the tables that GMax has written for us work, we can start to adjust them for the situation with longer animations. The first part (named mod_1) does not have to be changed, unless you want an animation with over 16384 frames of course. Let's assume that is not the case now.

The second part (named mod_2) will have to be changed, as our animation now has 4096 instead of 1024 frames. So we need to interpolate between 0 and 4095 now. The picture below shows how our sawtooth of the interpolation needs to look now.

 ** Insert picture of tweaked second sawtooth **

The third part we will also have to change as our interpolation runs till a higher frame number now.

 ** Add more explanation of how this works **

Below you see how the total interpolation table looks after these changes.

 ** Insert sample of  tweaked interpolation table **

After these changes we are done with tweaking the animation tables, so we can continue to alter the code where the actual interpolation is performed.

Animation interpolation