[[Category:Shenmue II]]
[[Category:Files]]
MT7 is an model container format for Shenmue II.
There are 4 different types of MT7 files (MDCX/7, MDPX/7, MDOX/7, MDLX/7) which are very similar.
The model format is based on an node based hierarchy tree.
For an C# implementation based on this documentation look [https://github.com/philyeahz/ShenmueDKSharp/blob/master/Files/Models/MT7.cs here].
===Header===
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (MDCX, MDPX, ...)
|-
| 0x04 || 0x04 || uint || Size in bytes
|-
| 0x08 || 0x04 || uint || First node offset
|-
| 0x0C || 0x04 || uint || Texture count
|}
===Texture Entry List===
After the header there is an optional texture entry list when the model uses textures.
These texture entries are used to list all textures the model uses which can be in the TXT7 section or even somewhere else.
Example: For the map files there is an PKS which holds the meshes and some other files, each PKS has an PKF which holds the textures for the models inside the PKS.
====Texture Entry====
Each entry has an texture ID/Name after the texture entries.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x02 || ushort || Width
|-
| 0x02 || 0x02 || ushort || Height
|-
| 0x04 || 0x04 || ? || Unknown
|-
| 0x08 || 0x04 || ? || Unknown
|-
| 0x0C || 0x04 || ? || Index?
|}
====Texture ID/Name====
The ID and the name are used to uniquely identify the texture.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || ID?
|-
| 0x04 || 0x04 || string || Name?
|}
===Node Location Dictionary===
After the texture entry list there is an dictionary with all the offsets to the nodes.
The use is not clear of this dictionary. Possible usage could be an fast view of the hierarchy without parsing the nodes or maybe for rigging.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || Offset
|}
===MT7 Node===
Each node holds the hierarchy information and transform values.
Not all nodes have to contain an offset to any mesh data but they still can have an effect on the child nodes meshes with their transform values.
That means every child goes up the hierarchy tree and applies the transform values of the parents (and it's own of course).
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || ID
|-
| 0x04 || 0x0C || float || Position/Translate (X, Y, Z)
|-
| 0x10 || 0x0C || short || Rotation (X, Y, Z)
|-
| 0x1C || 0x0C || float || Scale (X, Y, Z)
|-
| 0x28 || 0x04 || uint || XB01 Offset
|-
| 0x2C || 0x04 || uint || Child Offset
|-
| 0x30 || 0x04 || uint || Sibling Offset
|-
| 0x34 || 0x04 || uint || Parent Offset
|-
| 0x38 || 0x08 || ? || Reserved
|}
====Hierarchy====
├ Parent
├── Child
├── Sibling
===MDCX/7===
The MDCX or MDC7 files are mainly used for character models.
These files do have special sub nodes that extend the base node.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (MDCX)
|-
| 0x04 || 0x40 || float || 4x4 Matrix
|-
| 0x44 || 0x04 || uint || Entry count
|-
| 0x48 || 0x0? || ? || Entries
|}
====MDCX/7 Entry====
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || ? || ?
|-
| 0x04 || 0x04 || ? || ?
|}
===MDPX/7===
The MDCX or MDC7 files are mainly used for prop models.
These files do have special sub nodes that extend the base node.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (MDPX)
|-
| 0x04 || 0x04 || uint || Size in bytes
|-
| 0x08 || 0x04 || string || Name?
|-
| 0x0C || 0x0? || ? || Data
|}
===MDOX/7===
The MDOX or MDO7 files are mainly used for map geometry.
These files do not have any special sub node.
===MDLX/7===
THe MDLX or MDL7 files are mainly used for map geometry.
These files do not have any special sub node.
===XB01===
The XB01 sections hold the mesh data (vertices, strips and material metadata).
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (XB01)
|-
| 0x04 || 0x04 || ? || Unknown
|-
| 0x08 || 0x0C || float || Mesh center (X, Y, Z)
|-
| 0x14 || 0x04 || float || Mesh radius
|-
| 0x18 || 0x04 || uint || First instruction entry offset
|-
| 0x1C || 0x04 || uint || Vertices offset
|}
====Intructions====
These instructions are state machine like. Each instruction changes the state of how to render the strip.
Each instructions consists out of an 1 byte identifier and 1-2 bytes as the size of the instructions in words(2 bytes) including itself.
=====Group=====
An group can hold multiple instructions. The reason for grouping is unknown.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || ID
|-
| 0x04 || 0x04 || uint || Group size in bytes
|-
| 0x08 || 0x08 || ? || Unknown
|}
=====Floats (0x04)=====
Unknown floats.
=====Texture (0x0B)=====
Sets the texture to use for the next instructions.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || Texture count
|}
=====Texture Attributes (0x0D)=====
Sets the texture attributes to use for the next instructions.
Example: Transparency, Texture Wrapping, Unlit, ...
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || Attribute count
|}
=====Strip (0x10)=====
Draws an strip with the given vertex indices.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || Primitiv type? (Triangles or Triangle strip)
|-
| 0x00 || 0x04 || uint || Vertex index count
|}
====Vertices====
=====Header=====
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || ? || Unknown
|-
| 0x04 || 0x04 || ? || Unknown
|-
| 0x08 || 0x02 || ushort || Vertex size in bytes
|-
| 0x0A || 0x02 || ? || Unknown
|-
| 0x0C || 0x04 || uint || Vertex count
|}
=====Vertex=====
Example vertex with an size of 32 bytes.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x0C || float || Position (X, Y, Z)
|-
| 0x0C || 0x0C || float || Normals (X, Y, Z)
|-
| 0x18 || 0x08 || float || Texture Coordinates (U, V)
|}
===TXT7===
The TXT7 sections hold PVRT textures used for the model.
====Header====
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (TXT7)
|-
| 0x04 || 0x04 || uint || Size in bytes
|-
| 0x08 || 0x04 || uint || Texture entry count
|}
====TXT7 Entry====
The entries consist of an offset to the PVRT texture and just like in the texture entry list an ID/Name to identify those offsets.
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || Offset
|}
After the texture offsets come the corresponding texture ID and name to identify them.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || uint || ID?
|-
| 0x04 || 0x04 || string || Name?
|}
===FACE===
Unknown.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (FACE)
|-
| 0x04 || 0x04 || uint || Size in bytes
|}
===CLSG===
Unknown.
{| class="wikitable"
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Identifier (CLSG)
|-
| 0x04 || 0x04 || uint || Size in bytes
|-
| 0x08 || 0x04 || ? || Unknown
|-
| 0x0C || 0x04 || uint || CLTH Offset
|-
| 0x10 || 0x04 || uint || OSAG Offset
|-
| 0x14 || 0x04 || uint || CLCL Offset
|}
====CLTH====
Unknown.
====OSAG====
Unknown.
====CLCL====
Unknown.