It's a complex format.
Code:
local int i;
struct {
char magic[4];
int size; // size of file incl. header
int version; // = 17
} KMSH;
struct {
char Signatur[4];
int size;
int Format; // 1 = Mesh, 2 = Anim (?)
int uk; // = 1
} HEAD;
struct Texture {
string name;
};
struct MAT2 {
char Signatur[4];
int size;
string uk; // internal name?
int NumTextures;
Texture Texturenames[NumTextures]<optimize=false>;
int uk1;
int uk2;
int uk3;
string uk4;
};
struct {
char Signatur[4];
int size;
int NumMat;
MAT2 Materials[NumMat]<optimize=false>;
} MATL;
struct Mesh {
char MeshSig[4];
int size; // inkl. Signatur
struct {
char head[4];
int size;
string meshname;
int NumGroups; // number of groups in SPRS
int NumVerts; // total number of vertices defined in GEOM
float uk1; // bounding area?
float uk2;
float uk3;
float uk4;
int NumLOD; // number of total LOD entries
} Header;
struct Ctrl { // NumCTRL only non-zero in ANIM files
char Signatur[4];
int size;
int NumCTRL;
int uk[NumCTRL*2];
} ctrl;
typedef struct { // only used in ANIM files
char Signatur[4];
int size;
float x,y,z;
} POLY;
typedef struct {
short index; // index of the vertex in GEOM
int uk; // flag?
float nX; // the vertex normal
float nY;
float nZ;
} VertEx; // Extra vertex data with normals
struct Model {
char Signatur[4];
int size;
for (i=0; i<Header.NumGroups; i++)
{
struct {
char Signatur[4];
int size;
int LODEntries[Header.NumLOD]; // one entry for each LOD
int NumVertsEx; // number of entries in the extended vertex list
int uk;
} SPHD;
}
for (i=0; i<Header.NumGroups; i++)
{
struct
{
char Signatur[4];
int size;
int uk;
local int j;
for (j=0; j<Header.NumLOD; j++)
{
struct {
struct {
ubyte x,y,z; // indices for the extended vertex list
} LODVertIndices[SPHD[i].LODEntries[j]];
} LODEntries;
}
VertEx VertsEx[SPHD[i].NumVertsEx]; // extended vertex list
} Groups;
}
} model;
typedef struct { // a vertex definition
float x;
float y;
float z;
} Vec3f;
struct GEOM {
char Signatur[4];
int size;
Vec3f vertices[Header.NumVerts];
} geom;
} mesh;