-
Notifications
You must be signed in to change notification settings - Fork 1
MATERIALANIM
These are used to animate textures. For example, a texture may be horizontally scrolled over its lifetime.
There are 10 tracks that the MaterialAnimation structure keeps track of:
Track | Name | Description |
---|---|---|
1 | Texture | Changes the texture to a different BITMAP |
2 | Scroll | Scrolls/translates the texture |
3 | Stretch | Stretches/scales the texture |
4 | Rotate | Rotates the texture |
5 | Color | Changes the texture's color |
6 | Emission | Change's the texture's emission |
7 | Alpha | Changes the texture's opacity |
8 | ? | Unknown |
9 | ? | Unknown |
10 | ? | Unknown |
The Stretch, Scroll, and Rotate tracks are used to compute a 3x3 matrix transform for the texture coordinates. The computed transform overrides the matrix defined in the MATERIAL file (and often, the first matrix that is computed is equivalent to the matrix defined in the MATERIAL file).
In order to compute the transform matrix, the following matrix multiplication is used (matrix multiplication is performed in reverse order):
offset1 = {{ 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.5, 0.5, 1.0}};
offset2 = {{ 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-0.5, -0.5, 1.0}};
finalmat = offset1 * scroll * scale * rotation * offset2;
where scroll
is the translation matrix, scale
is the scale matrix, and rotation
is the rotation matrix. The offset1
and offset2
matrices are used to set the origin of the texture at (0.5, 0.5)
.
There are three interpolation values that are used:
ID | Usage |
---|---|
1 | Discrete; no interpolation. |
2 | Linear interpolation. |
3 | Although this value is used, the data that it is used with is always empty. |
struct MaterialAnimation {
uint8_t unknown1;
float length; // Length of the animation in seconds (multiply by 60 for frames)
uint16_t texture_interpolation; // Always 1
uint32_t num_texture_frames;
TextureFrame texture_frames[num_texture_frames];
uint16_t scroll_interpolation; // Always 2
uint32_t num_scroll_frames;
ScrollFrame scroll_frames[num_scroll_frames];
uint16_t stretch_interpolation; // Always either 2 or 3
uint32_t num_stretch_frames;
StretchFrame stretch_frames[num_stretch_frames];
uint16_t rotation_interpolation; // Always either 2 or 3
uint32_t num_rotate_frames;
RotateFrame rotate_frames[num_rotate_frames];
uint16_t color_interpolation; // Always 2
uint32_t num_color_frames;
ColorFrame color_frames[num_color_frames];
uint16_t emission_interpolation; // Always 2
uint32_t num_emission_frames;
ColorFrame emission_frames[num_emission_frames];
uint16_t alpha_interpolation; // Always 2
uint32_t num_alpha_frames;
AlphaFrame alpha_frames[num_alpha_frames];
uint16_t unknownpart1_interpolation; // Always 1
uint32_t num_unknownpart1_frames;
UnknownFramePart unknownpart1_frames[num_unknownpart1_frames];
uint16_t unknownpart2_interpolation; // Always 1
uint32_t num_unknownpart2_frames; // always equal to num_unknownpart1_frames
UnknownFramePart unknownpart2_frames[num_unknownpart2_frames];
uint16_t unknownpart3_interpolation; // Always 1
uint32_t num_unknownpart3_frames; // always equal to num_unknownpart1_frames
UnknownFramePart unknownpart3_frames[num_unknownpart3_frames];
int32_t material_id; // ID of a MATERIAL
}
struct TextureFrame {
int32_t bitmap_id;
uint16_t frame;
}
Changes the texture on the specified frame.
struct ScrollFrame {
uint16_t frame;
uint16_t unknown;
float scroll_x; // X scroll value.
float scroll_y; // Y scroll value.
}
Translates the texture on the specified frame.
struct StretchFrame {
uint16_t frame;
uint16_t unknown;
float stretch_x; // X stretch factor (origin is center)
float stretch_y; // Y stretch factor (origin is center)
}
Stretches the texture on the specified frame.
struct RotationFrame {
uint16_t frame;
uint16_t unknown;
float rotation; // Texture rotation (origin is center)
}
Rotates the texture on the specified frame.
struct ColorFrame {
uint16_t frame;
uint16_t unknown;
float red; // between 0 and 1
float green; // between 0 and 1
float blue; // between 0 and 1
}
Changes the color of the texture on the specified frame. Also used for emission.
struct AlphaFrame {
uint16_t frame;
uint16_t unknown;
float alpha;
}
Changes the opacity of the texture on the specified frame.
struct UnknownFramePart {
uint16_t frame;
uint16_t unknown;
char unk[4];
}
There are three tracks near the end of the MaterialAnimation structure which are 8 bytes in length, and all of which have the same number of elements. Whether or not they share the same structure is unknown.