TMD (PlayStation)
(Fix) |
m (Fix) |
||
Line 59: | Line 59: | ||
} tmd_prim_header_t;</pre> | } tmd_prim_header_t;</pre> | ||
− | === Single color triangle (type 0x20,0x22) === | + | ==== Single color triangle (type 0x20,0x22) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 71: | Line 71: | ||
} tmd_flattriangle_t;</pre> | } tmd_flattriangle_t;</pre> | ||
− | === Gouraud triangle (type 0x24) === | + | ==== Gouraud triangle (type 0x24) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 85: | Line 85: | ||
} tmd_gouraudtriangle_t;</pre> | } tmd_gouraudtriangle_t;</pre> | ||
− | === Single color quad (type 0x28) === | + | ==== Single color quad (type 0x28) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 98: | Line 98: | ||
} tmd_flatquad_t; | } tmd_flatquad_t; | ||
− | === Gouraud quad (type 0x2c) === | + | ==== Gouraud quad (type 0x2c) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 116: | Line 116: | ||
} tmd_gouraudquad_t;</pre> | } tmd_gouraudquad_t;</pre> | ||
− | === Flat triangle with vertex normals (type 0x30) === | + | ==== Flat triangle with vertex normals (type 0x30) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 129: | Line 129: | ||
} tmd_flattriangle2_t;</pre> | } tmd_flattriangle2_t;</pre> | ||
− | === Textured triangle (type 0x34) === | + | ==== Textured triangle (type 0x34) ==== |
<pre>typedef struct { | <pre>typedef struct { | ||
Line 150: | Line 150: | ||
} tmd_txtriangle_t;</pre> | } tmd_txtriangle_t;</pre> | ||
− | === Flat quad with vertex normals (type 0x38) === | + | ==== Flat quad with vertex normals (type 0x38) ==== |
<pre>typedef struct { | <pre>typedef struct { |
Latest revision as of 16:13, 25 August 2023
This content was first retrieved from the Internet Archive's Wayback Machine for the date 2016-05-09 from the following URL: https://web.archive.org/web/20160509002322/http://rewiki.regengedanken.de/wiki/.TMD
The .TMD file format is the standard file format for 3D objects on PlayStation. It is also used by many PC ports of Playstation games, like Resident Evil, Resident Evil 2, Resident Evil 3.
Contents |
[edit] Structure
The values are stored in Little-Endian order.
[edit] Header
A TMD file can contain several 3D models. It starts with this header:
typedef struct { unsigned long id; /* Constant = 0x41 */ unsigned long unknown; unsigned long num_objects; /* Number of objects in file */ } tmd_header_t;
Then are following the objects headers, as an array of tmd_object_t objects[num_objects].
[edit] Object
typedef struct { unsigned long vertex_offset; /* Offset to vertex array coordinates */ unsigned long vertex_count; /* Number of vertices */ unsigned long normal_offset; /* Offset to normal array coordinates */ unsigned long normal_count; /* Number of normals */ unsigned long primitive_offset; /* Offsets to primitives */ unsigned long primitive_count; /* Number of primitives */ unsigned long unknown; } tmd_object_t;
[edit] Vertex, normal
Vertices and normals share the same format to holds the 3D coordinate:
typedef struct { short x; short y; short z; short zero; } tmd_vertex_t;
[edit] Primitives
Each primitive starts with same header, and the rest depend on the primitive type:
typedef struct { unsigned char unknown0; unsigned char length; /* Length of following primitive in 32bit words */ unsigned char unknown1; unsigned char type; /* primitive type */ } tmd_prim_header_t;
[edit] Single color triangle (type 0x20,0x22)
typedef struct { unsigned char r,g,b,unknown; /* R,G,B triangle color */ unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short v1; unsigned short v2; } tmd_flattriangle_t;
[edit] Gouraud triangle (type 0x24)
typedef struct { unsigned char r0,g0,b0,unk0; /* R,G,B vertex color */ unsigned char r1,g1,b1,unk1; unsigned char r2,g2,b2,unk2; unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short v1; unsigned short v2; } tmd_gouraudtriangle_t;
[edit] Single color quad (type 0x28)
typedef struct { unsigned char r,g,b,unknown; /* R,G,B quad color */ unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short v1; unsigned short v2; unsigned short v3; } tmd_flatquad_t; ==== Gouraud quad (type 0x2c) ==== <pre>typedef struct { unsigned char r0,g0,b0,unk0; /* R,G,B vertex color */ unsigned char r1,g1,b1,unk1; unsigned char r2,g2,b2,unk2; unsigned char r3,g3,b3,unk3; unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short v1; unsigned short v2; unsigned short v3; unsigned short unk5; } tmd_gouraudquad_t;
[edit] Flat triangle with vertex normals (type 0x30)
typedef struct { unsigned char r,g,b,unk; /* R,G,B triangle color */ unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short n1; unsigned short v1; unsigned short n2; unsigned short v2; } tmd_flattriangle2_t;
[edit] Textured triangle (type 0x34)
typedef struct { unsigned short unknown1; unsigned char v0; /* textures coordinates */ unsigned char u0; unsigned short unknown2; unsigned char v1; unsigned char u1; unsigned short unknown3; unsigned char v2; unsigned char u2; unsigned short v0; /* Vertex index */ unsigned short n0; /* Normal index */ unsigned short v1; unsigned short n1; unsigned short v2; unsigned short n2; } tmd_txtriangle_t;
[edit] Flat quad with vertex normals (type 0x38)
typedef struct { unsigned char r,g,b,unk; /* R,G,B quad color */ unsigned short n0; /* Normal index */ unsigned short v0; /* Vertex index */ unsigned short n1; unsigned short v1; unsigned short n2; unsigned short v2; unsigned short n3; unsigned short v3; } tmd_flatquad2_t;