APE Animated Texture Control

You can easily control animated textures from APE by using these functions. Remember that animated textures are not limited to world polys, they can be on models, sprites, and 2D controls. RegisterTexture is used to load new textures with specific parameters. FindTexture is used to get handles to textures already loaded for interface, world, or model objects. SetAnimFrame is used to set the next animation frame for an animating texture, using a handle obtained from RegisterTexture or FindTexture.

extern RegisterTexture
  floatvar handle       // returned handle to image
  string filename       // texture file name with path, but no extension
  float bilerp          // (optional) bilinear filter flag
  float mipmap          // (optional) mipmap generation flag
  float repeat          // (optional) repeat mode flag

Parameters

handle
[out] Variable to receive the image handle. Subsequent calls should specify this variable. A return value of zero in the variable is an invalid handle, and means the function failed.
filename
[in] File name of the animated texture without extension relative to anoxdata. For example, if the full texture path is "Anachronox/anoxdata/textures/joey/happy.atd" then you would specify "textures/joey/happy" for this parameter. Note that because of flexible file extension searching, if you have two different graphic files in the same directory that differ only in extension, which file will get loaded is unpredictable. Even if you specify an extension for the graphic, it will be happily ignored. (How this "feature" came about is a long, sordid story that I won't go into here...)
bilerp
[in/optional] This optional flag specifies whether the texture will be bilinear filtered or not on the screen. Specify 1 for on, 0 for off, or -1 for automatic. If it is not specified or you specify automatic, it will assume the texture will be used for 2d interface graphics, and will automatically determine the bilerp value depending on the screen resolution. If the screen resolution is a multiple of 640x480, then bilerp will be 1, otherwise it will be 0. For 3D textures, you should usually use 1.
mipmap
[in/optional] This optional flag specifies whether the texture should have mipmaps generated for it. Specify 1 for on, 0 for off. It should be off for 2D interface graphics, and on for textures on 3D objects.
repeat
[in/optional] This optional flag specifies whether the texture will have the GL_REPEAT or GL_CLAMP texturing mode. Specify 1 for GL_REPEAT and 0 for GL_CLAMP. The default is GL_CLAMP. If you created 2D interface graphics that need to tile, you should specify 1.
extern FindTexture
  floatvar handle       // returned handle to image
  string filename       // texture file name with path, but no extension

Parameters

handle
[out] Variable to receive the image handle. Subsequent calls should specify this variable. A return value of zero in the variable is an invalid handle, and means the function failed.
filename
[in] Filename, same as for RegisterTexture above.
extern SetAnimFrame
  float handle          // image handle
  float framenum        // animation frame number
  float nowait          // (optional) ignore current delay

Parameters

handle
Non-zero handle received from a previous call to RegisterTexture.
framenum
Frame number which you want displayed next in the animation sequence.
nowait
Flag to specify whether or not the currently displayed frame's wait value should be ignored. If you specify 1, then framenum will be processed immediately. The default value is 0.

Example

Please see map joeyproc and the corresponding joeyproc.txt APE script for examples of APE control of animated textures on entities and world brushes.