Animated Textures

Forget your silly 10 fps looping quake animated textures. Now you can create complex multi-framed animated textures AND control them from APE. Explosion effects, computer terminal displays, animated 2D user-interface controls, even the mouse! ....the possibilities are endless.

ATD1

type      = animation
colortype = integer 
width     = integer
height    = integer
bilinear  = integer (optional, def=1)
clamp     = integer (optional, def=0)
!bitmap
  file    = filename

!bitmap
  ... repeat for all bitmaps
!frame
  bitmap  = integer
  next    = integer (optional)
  wait    = float   (optional)
  x       = integer (optional)
  y       = integer (optional)

!frame
  ... repeat for all frames

Parameters (main)

colortype
Determines how the texture is stored on the card. All source bitmaps must be in the same format. Can be one of the following values:
value meaning
1 8-bit greyscale PNG
2 8-bit greyscale + 8-bit alpha PNG
3 24-bit RGB PNG
4 24-bit RGB + 8-bit alpha PNG
width
Width of output texture, must be power of two.
height
Height of output texture, must be power of two.
bilinear
Must be 0 or 1, controls whether bilinear filtering is used on this image. Default is 1.
clamp
Must be 0 or 1, controls whether the texture is clamped to its edges or is repeated (tiled). It must be 1 if you want to use an animated parabolic environment map. Default is 0.

Parameters (bitmap list)

file
Specifies a source image file. Must be in PNG format and have the same color type as specified earlier by colortype. It can be any size as long as it not larger than the output size in any dimension.

Parameters (frame list)

bitmap
Integer specifying which file specified in the bitmap list to use. The first bitmap you specified is numbered 0; subsequent bitmaps are numbered 1, 2, 3, and so on.
next
Integer specifying the next frame in the animation sequence. The first frame you specified is numbered 0; subsequence frames are numbered 1, 2, 3, and so on. If you specify −1, then the image will stop animating after this frame. The default value is −1.
wait
Floating point value specifying the number of seconds to wait before displaying the next frame in the animation sequence. If you specify 0, then the next frame will be uploaded on the next rendering pass. If you specify −1, then the current frame is uploaded immediately and the next frame in the sequence is processed (see Remarks section). The default value is 0.
x
Integer specifying the x offset into the output texture where the bitmap should appear.
y
Integer specifying the y offset into the output texture where the bitmap should appear.

Remarks

Since this new animated texture code uses frame uploading, having many frames of animation takes up main memory instead of video card texture memory. The amount of video texture memory used is never more than the amount required to store the output frame. However, this doesn't mean animated textures are free and you should frame-output the FF8 opening movie into PNG format and watch it play in Anachronox.

Examples

Although they no longer take up video memory, they still do take up main memory, and taking up too much main memory is a bad thing. One way to reduce your RAM usage is to not change the all of the texture in the animation frame. For example, say you skin a robot, and you want one of his lights to blink. Instead of making two copies of the skin with the light either on or off, you can have one frame be the original skin, and one frame be a very small bitmap containing only the part of the skin that changes with the blinking light. Then you can do something like this:

base.png on.png off.png output
ATD1
type=animation
colortype=3
width=128
height=128

!bitmap
  file=models/robot/base.png
!bitmap
  file=models/robot/on.png
!bitmap
  file=models/robot/off.png

# Frame 0 is what is always uploaded to the texture
# before anything is displayed.  In this case, wait 
# is -1 so the next frame (1) is immediately processed.

!frame
  bitmap=0
  next=1
  wait=-1

# Frame 1 says to upload on.png at the specified
# offsets into the texture.  Then it waits half
# a second before processing the next frame.

!frame
  bitmap=1
  next=2
  wait=.5
  x=46
  y=44

# Frame 2 uploads off.png at the specified offset.
# This replaces the center light with a picture
# of the light turned off.  It then waits .2
# seconds before looping back to frame 1.

!frame
  bitmap=2
  next=1
  wait=.2
  x=46
  y=44

Look in map joeyproc for some examples in animated textures.