TMD

WIP

See http://psx.arthus.net/sdk/Psy-Q/DOCS/FileFormat47.pdf , p.71

typedef struct TMD_HEADER {
    u_long ID;       // TMD file version - current is 0x00000041
    u_long flags;    // LSB (FIXP) is either 0 or 1, all other bits are 0
    u_long nobj;     // Number of objects in TMD
} TMD_HEADER;

struct TMD_OBJECT {
    u_long *vert_top;       // Start address of a vertex - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_vert;          // Number of vertices
    u_long *normal top;     // Start address of a normal  - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_normal;        // Number of normals
    u_long *primitive top;  // Start address of a primitive  - if FIXP is 1, absolute address, else, relative to object's block address
    u_long n_primitive;     // Number of primitives
    long scale;             // Scaling factor - scale value is scale factor^2 . -1 is 1/2.
} TMD_OBJECT;

struct TMD_PACKET {
    u_short mode, flag;
    u_short ilen;           // data section length in words
    u_short olen;           // word length
    u_long data;
    } TMD_PACKET;
struct TMD_VERTEX {
    short vx, vy, vz;
    short pad;
} TMD_VERTEX;

struct TMD_NORMAL {
    short vx, vy, vz;       // fixed point value with scale 1.0 == 4096
    short pad;
} TMD_NORMAL;

typedef struct TMD_FILE {
    TMD_HEADER header;
    TMD_OBJECT objTable[];  // objTable has length TMD_HEADER.nobj
    TMD_PACKET primitive[]; // primtive has length TM_PACKET.ilen
    TMD_VERTEX vertex;
    TMD_NORMAL normal;
} TMD_FILE;

Ressources

https://github.com/taedixon/tmd2obj