This document briefly describes the .tmd file format as used by the Sony Playstation to store 3d object information. This document is not intended to be distributed outside of the Net Yaroze community. Please be aware that I have spent very little time working on this and the source. Not all of the polygon primative structures are complete. Once I completely understand them I will document them. If you have any comments or additions to make please contact me. Written By James Pitts. 26/3/97. First Version. sigill@geocities.com http://www.playstaion.co.uk/~Sig1LL -====- HEADER -====- A .tmd file has a header starting at the very first byte of the file. offset type 0 ID 4 Flags 8 Num ID Always 0x00000041 Flags Set to 1 if processed by GsMapModelingData(), else 0 Num Number Objects in tmd This structure only appears once and is directly followed by the first Object Header. -===========- Object Header -===========- This header describes each object in the tmd file. All file offsets within this object are taken from this point. offset type 0 Vertices Table 4 Number Vertices 8 Normal list Offset 12 Number Normals 16 Polygon Primatives Offset 20 Number Primatives 24 scaling (aparently unused) The "Vertices Table" points to a table of vectors (see below for detail) with "Number Vertices" elements. This is the x,y,z coord for each point in the object. Normals are store identically to the Vertices but obviously contain normal vectors. The Polygon Primatives describe each polygon in the scence ( 3 and 4 sided) these records have varying sizes. -==================- Vertices and Normals -==================- To read the Vertice and Normal Data just seek to the offset specified in the Object Header structure. Remember to add the tmd header size to the offsets. NormalTab = ObjHead->NormalOffset + sizeof (tmdheader); The Vertices and Normal are just vectors. offset type 0 x 2 y 4 z 6 filler filler is just for alignment padding and has no use. -========- Primatives -========- This is where the fun starts. :-) This is a table of all the polygons in this object. Each polygon has a header, which is followed by a variable size data block. Header. offset type 0 unknown 1 data block length 2 flag 3 mode 'data block length' is the size of the data to follow this header measured in words. If your reader does not understand the following data or wishes to ignore it. It can just skip 'length * 4' bytes. The data to follow can be determined by the mode and flags fields. The Mode and Flags fields are both split into bitfields. MODE. bits hex type 0 1 Brightness 1 2 Transparency 2 4 Texture 3 8 Quad 4 10 Gouraud 5 20 1 Bit 5 of the mode field is always 1. bit 0 == 1 No flat shading bit 1 == 1 Transparency On bit 2 == 1 Polygon Textured bit 3 == 1 4 sided polygon bit 4 == 1 Polgon is Gouraud shaded bit 5 == 1 Always 1. FLAG. bits hex type 0 1 Light Source 1 2 2 Sided 2 4 Gradation bit 0 == 1 Do not calculate light sourcing bit 1 == 1 Polygon is double sided bit 2 == 1 Gradated The structure that follow below are the data blocks for each polygon mode. * Mode == 0x20 && Flag == 0 (Flat Shaded triangle) offset type 0 red 1 green 2 blue 3 filler 4 index into normal table 6 first point 8 second point 10 third point The rgb fields specify the ambient colour of the poly. Next is the offset in to the normal table for this polygons Normal Vector. Followed by three indexes into the vertex table for each point of the poly. * Mode == 0x28 && Flag == 0 (flat shaded Quad) Same as Mode == 0x20 structure except it has an extra point field followed by a 2 byte filler. offset type 12 fourth point 14 filler * Mode == 0x30 && Flag == 0 (Gouraud shaded Triangle) offset type 0 red 1 green 2 blue 3 filler 4 index into normal table 6 first point 8 index into normal table 10 second point 12 index into normal table 14 third point This is similar to the flat shaded polygon primatives except each vertice has an associated normal. * Mode == 0x38 && Flag == 0 (Gouraud shaded Triangle) Same as Mode == 0x30 structure except it has an extra normal and point field. offset type 16 fourth point normal 18 fourth point *************** END