AMS (File Format)

From Wexos's Wiki
Revision as of 00:23, 18 June 2025 by Atlas (talk | contribs)
Jump to navigationJump to search
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.

AMS (Aqualead MeSh) is a file format developed by Aqualead and found in some Wii and 3DS games (and suspected to be used in GameCube titles as well), such as One Piece: Unlimited Adventure, One Piece: Unlimited Cruise Episode 1 - The Treasure Beneath The Waves, One Piece: Unlimited Cruise Episode 2: Awakening of a Hero, One Piece: Unlimited Cruise SP and One Piece: Unlimited Cruise SP 2.

File Format

The file byte order can be either big endian (Wii) or little endian (3DS).

Header

The file starts with the following header:

Offset Type Description
0x00 Char[4] File magic. Always ALMS in ASCII.
0x04 Byte Unknown. Format type? Values seen are 2 and 8.
0x05 Byte Unknown. Posibly bit flags, but files either use 0x80 or 0x81.
0x06 Byte Number of materials (M).
0x07 Byte Number of texture references (T).
0x08 Byte Number of shapes (S).
0x09 Byte Number of bones (B).
0x0A Byte Unknown.
0x0B Byte Unknown.
0x0C Float[2] Unknown. Seems to be some kind of minimum values, perhaps for a 2D bounding box?
0x14 Float[2] Unknown. Seems to be some kind of maximum values, perhaps for a 2D bounding box?
0x1C UInt16 Section 1 offset.
0x1E UInt16 Section 2 offset.
0x20 UInt16 Section 3 offset.
0x22 UInt16 Section 4 offset.

Section 1

This section defines M 0x18 material entries.

Material

TBD

Section 2

This section defines T 0x4-byte texture references.

Texture Reference

Offset Type Description
0x00 Byte Padding.
0x01 UInt24 Asset link identifier of the texture.

Section 3

This section defines B 0x30 bone entries.

Bone

Offset Type Description
0x00 float[3] XYZ position.
0x0C Char[4] Bone name. Hardcoded to be 4 characters long.
0x10 float[4] Rotation, using quaternions.
0x20 float[4] Unknown.

Section 4

This section defines S shape entries.

Offset Type Description
0x00 Int32[S] Shape offsets.

Shape Header

Each shape starts with a 0x20 byte header.

Offset Type Description
0x00 Byte Unknown. Seems to be some kind of debugging flag?
0x01 Byte Unknown. Always 1?
0x02 Byte Unknown. Probably indicates the type of data format.
0x03 Byte Unknown. Always 3?
0x04 UInt16 Number of Unknown Data 1 (S?).
0x06 Byte[2] Unknown.
0x08 UInt16 Number of vertices (SV).
0x0A Byte[2] Unknown. Probably indicates the format of the vertex data.
0x0C UInt16 Number of normals (SN). Normal data is usually always attached to the vertex data, so it's the same as the number of vertices (?)
0x0E Byte[2] Unknown. Probably indicates the format of the normal data.
0x10 UInt16 Number of colors (SC).
0x12 Byte[2] Unknown. Probably indicates the format of the color data.
0x14 UInt16 Number of UVs (SU).
0x16 Byte[2] Unknown. Probably indicates the format of the UV data.
0x18 UInt16 Number of bone entries (SB).
0x1A Byte[2] Unknown.
0x1C Byte[2] Unknown.
0x1E UInt16 Section Data Helpers offset. If the value is 0, the Section Data Helpers comes right after (?)

Usually, the last value of the header (Section Data Helpers offset) is always 0x20, but in some occasions it might be 0x30, with 0x10 bytes of unknown data after it, presumably 4 floats (?)

Section Data Helpers

Currently, it is not clear how the number of helpers is calculated, or how they are ordered. These entries seem to contain the offsets of the first instance for each of the entries defined in the Shape Header. Commonly, the first entry is always related to the vertex data, and the second one to the mesh indices' first Wii Draw Command vertex ID, while the third points to the normal data, the fourth to the mesh indices' first Wii Draw Command normal ID and so on. All offsets are relative to the start of the Shape Header.

Format of a section data helper
Offset Type Description
0x00 Byte Stride of an entire entry unit in bytes.
0x01 UInt24 Data offset for the first instance of the entry. These offsets indicate the first entry for each entry type defined by the Shape Header, including overlapping entries that may share a common data array. For example, the vertex data array may contain normal and weight data attached to each vertex, but the entries for position, normal and weight data are separate. As for the offsets of the first mesh index, it also correlates to the specific part of the first Wii Draw Command that references the entry type.

Unknown Data 1

This section follows directly after the Section Data Helpers and contains S? entries, seen in UInt16 format, unless specified somewhere in the Shape Header (perhaps by 0x06 from the Shape Header?). The purpose of this section is unknown, and it is also currently not possible to know how the offset to this section is calculated, as it does not seem to be referenced by the Section Data Helpers either.

Bone References

This section follows directly after the Unknown Data 1 and contains SB entries, seen in Byte format, unless specified somewhere else in the Shape Header (perhaps by 0x1A from the Shape Header?). This section seems to list the indices of the bones in order. It is currently not possible to know how the offset to this section is calculated, as it does not seem to be referenced by the Section Data Helpers either.

Vertex Data

This section follows after the Bone References and contains SV entries. It seems to correspond to the first entry from the Section Data Helpers. The vertex data for each unit may contain position, normal, bone indices, weight data and perhaps color indices; the format of each defined by the Section Header.

Color Data

SC vertex color entries seem to come after the Vertex Data, if present; the format of each defined by the Section Header.

UV Data

SU UV entries seem to come after the Color Data, if present; the format of each defined by the Section Header.

Draw Data

After the UV entries comes the Draw Data. This section starts with a 4-byte header:

Draw Data Header
Offset Type Description
0x00 Byte Unknown. Always 0x80? Perhaps this value indicates that the data is made of Wii Graphics' commands.
0x01 UInt24 Length of the draw commands in bytes.

Directly after the header there are the Wii Draw Commands.

Unknown Data 2

After the Draw Data comes an Unknown Data section. It starts with a 2-byte header:

Unknown Data 2 Header
Offset Type Description
0x00 UInt16 Length of the data in bytes.

Directly after the header there is the unknown data.

Tools

The following tools can handle AMS files:

  • (none)