Home | Have a look at the insides of the Racer file formats. |
|
The DOF file format is used for storing 3D models. Racer v0.3 used DOF0, but has been superseded by DOF1 since 27-12-2000 and almost hasn't changed during the years, except for an update with v0.9.0 RC8 in June 2013. The format allows easy skipping of chunks that future/previous versions might not know about.
DOF's are stored in binary format and use Intel endianness (just about all processors in PC's these days use the same format). Largely inspired by the IFF format (but not completely taken over), the format contains 3 conceptual levels, all indicated by 4-character identifiers. Each chunk begins with a char[4] identifier followed by a 32-bit integer size that indicates the size (in bytes) of the chunk data that follows. No padding is used (this is different from the original IFF specifications). This allows readers to skip chunks they don't know anything about, just by skipping those bytes and trying to go on, hoping not too miss any important information.
DOF files store 3D data and basic material info. More detailed rendering information is stored in .shd (Racer shader) files. These should not be confused with GPU shaders; those can be referenced in the .shd files.
Level 1; objects
Level 2; object components
Level 3; object component attributes
These you will find inside the MAT0 and
GOB1 chunks. Note that each chunk is directly followed by its length, to make
sure future extensions can be easily put in and out. This is with the exception
of the GEND and MEND chunks (those do not have a length added)!
First a description of MAT0:
qstring name,className;
float ambient[4];
float diffuse[4];
float specular[4];
float emission[4];
float shininess;
int creationFlags;
flags&1 -> environment mappedfloat uvwUoffset;
float uvwVoffset;
float uvwUtiling;
float uvwVtiling;
float uvwAngle;
float uvwBlur;
float uvwBlurOffset;
float transparency; (unused)
int blendMode; (0=no blending, 1=BLEND_SRC_ALPHA=source alpha blending, 2=BLEND_CONST=constant
color blending (unused))
int textures;
qstring mapName[textures];
NOTE: no full paths allowed, just the filename part. Maps will be searched
in the model images/ path (or from an explicitly given path).int submaterials;
MAT0[submaterials]; (recursive)
Submaterials were used mainly for Max's Multi/Sub-object materials.
However, this gives some problems using indexed primitives, so I don't use
it anymore. Try not to use Multi/Sub-materials but use plain materials instead
(which is the most general case).Next, a description of a GOB1 (geometrical definition, or geob):
int flags; (none defined yet; actually the contents of this field are not used from v0.8.3 onwards; you still have to write them though (just use 0))
int paintFlags; (none defined yet)
int materialRef; (the material index)
int indices;
short index[indices];
The index[] array contains indices into the vertex, tvertex etc. arrays.
This allows vertex data (position, normal, color etc) to be re-used, and is
especially useful on T&L enabled hardware, since on that hardware you
have a small cache that remembers the last few transformed & lit vertices.
So locality of triangles may mean that the triangle vertices are still in
the cache and don't need to be transformed & lit again. int vertices;
float vertex[vertices*3];
int tvertices;
float tvertex[tvertices*2];
int tvertices;
float tvertex[tvertices*2];
int normals;
float normal[normals*3];
Note that the normals array will normally be the same length as that
of VERT (since GOB1 uses indexed primitives, so for every vertex, there is
1 texture coordinate pair (tvertex) and 1 normal.int vertexColors;
float vcolor[vertexColors*3];
Note that the vertex color array will normally be the same length as
that of VERT (since GOB1 uses indexed primitives, so for every vertex, there
is 1 vertex color. Each color is an RGB triplet; each color varies from 0..1.int bursts;
int burstStart[bursts]; (start in vertex[] for the first burst vertex)
int burstCount[bursts]; (number of floats in vertex[] to use for this burst)
int burstMtlID[bursts]; (material selection for this burst)
int burstVperP[bursts]; (should always be 3 for all bursts)
Note that burstStart/burstCount has a bit of a weird counting mechanism.
They don't count elements, but rather real floats, so when using glDrawElements(),
you would need to specify a start of burstStart[i]/3 and a count of burstCount[i]/3.
This is needed to perhaps support non-triangle data (it did before, but using
only triangles is much easier on a lot of the algoritmhs involved).General notes about the file format:
Here's a hex dump of a small model; a rectangle generated originally from a SCGT shadow 'model':
00000000: 44 4f 46 31 d1 01 00 00 4d 41 54 53 c1 00 00 00 DOF1....MATS....
00000010: 01 00 00 00 4d 41 54 30 b5 00 00 00 4d 48 44 52 ....MAT0....MHDR
00000020: 04 00 00 00 00 00 00 00 4d 43 4f 4c 44 00 00 00 ........MCOLD...
00000030: cd cc 4c 3e cd cc 4c 3e cd cc 4c 3e cd cc 4c 3e ..L>..L>..L>..L>
00000040: 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 80 3f ...?...?...?...?
00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3f ...............?
00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3f ...............?
00000070: 00 00 00 00 4d 55 56 57 1c 00 00 00 00 00 00 00 ....MUVW........
00000080: 00 00 00 00 00 00 80 3f 00 00 80 3f 00 00 00 00 .......?...?....
00000090: 00 00 00 00 00 00 00 00 4d 54 52 41 08 00 00 00 ........MTRA....
000000a0: 00 00 00 00 00 00 00 00 4d 54 45 58 11 00 00 00 ........MTEX....
000000b0: 01 00 00 00 0b 00 56 45 43 53 48 41 44 2e 42 4d ......VECSHAD.BM
000000c0: 50 4d 53 55 42 04 00 00 00 00 00 00 00 4d 45 4e PMSUB........MEN
000000d0: 44 47 45 4f 42 fc 00 00 00 01 00 00 00 47 4f 42 DGEOB........GOB
000000e0: 31 f4 00 00 00 47 48 44 52 0c 00 00 00 00 00 00 1....GHDR.......
000000f0: 00 00 00 00 00 00 00 00 00 49 4e 44 49 10 00 00 .........INDI...
00000100: 00 06 00 00 00 00 00 01 00 02 00 00 00 02 00 03 ................
00000110: 00 56 45 52 54 34 00 00 00 04 00 00 00 cc cc c9 .VERT4..........
00000120: c2 00 00 8c c1 33 b3 4d 43 99 99 c6 42 00 00 8c .....3.MC...B...
00000130: c1 33 b3 4d 43 99 99 c6 42 00 00 8c c1 66 e6 38 .3.MC...B....f.8
00000140: c3 cc cc c9 c2 00 00 8c c1 66 e6 38 c3 54 56 45 .........f.8.TVE
00000150: 52 24 00 00 00 04 00 00 00 00 00 80 3f 00 00 80 R$..........?...
00000160: bf 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 00 ....?...........
00000170: 00 00 00 00 00 00 00 80 bf 4e 4f 52 4d 34 00 00 .........NORM4..
00000180: 00 04 00 00 00 00 00 00 00 00 00 80 3f 00 00 00 ............?...
00000190: 00 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 00 ........?.......
000001a0: 00 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 80 ....?...........
000001b0: 3f 00 00 00 00 42 52 53 54 14 00 00 00 01 00 00 ?....BRST.......
000001c0: 00 00 00 00 00 12 00 00 00 00 00 00 00 03 00 00 ................
000001d0: 00 47 45 4e 44 45 44 4f 46 .GENDEDOF
Multitexturing
Only since June 2013 does Racer support multi texture coordinate channels. The ASE importer allows reading of the MESH_MAPPINGCHANNEL token to allow multiple channels. Exporting and rendering then allows this 2nd channel, although it requires specific GPU shaders to make use of them. The support has been added to allow better definitions of mix shaders (multiple textures, being mixed based on a control map) and for possible future lightmapping (where the 2nd channel defines the texture coordinates inside the lightmap texture).
Here is an example hexdump of a cube.dof file which has 2 UV channels defined (a TVER chunk and a TVR1 chunk):
00000000: 44 4f 46 31 ba 06 00 00 4d 41 54 53 fe 00 00 00 DOF1....MATS....
00000010: 01 00 00 00 4d 41 54 30 f2 00 00 00 4d 48 44 52 ....MAT0....MHDR
00000020: 10 00 00 00 04 00 63 75 62 65 08 00 53 74 61 6e ......cube..Stan
00000030: 64 61 72 64 4d 43 4f 4c 44 00 00 00 46 94 16 3f dardMCOLD...F..?
00000040: 46 94 16 3f 46 94 16 3f 00 00 80 3f 46 94 16 3f F..?F..?...?F..?
00000050: 46 94 16 3f 46 94 16 3f 00 00 80 3f 66 66 66 3f F..?F..?...?fff?
00000060: 66 66 66 3f 66 66 66 3f 00 00 80 3f 00 00 00 00 fff?fff?...?....
00000070: 00 00 00 00 00 00 00 00 00 00 80 3f cd cc 4c 41 ...........?..LA
00000080: 4d 55 56 57 1c 00 00 00 00 00 00 00 00 00 00 00 MUVW............
00000090: 00 00 80 3f 00 00 80 3f 00 00 00 00 00 00 00 00 ...?...?........
000000a0: 00 00 00 00 4d 54 52 41 08 00 00 00 00 00 00 00 ....MTRA........
000000b0: 00 00 00 00 4d 43 46 4c 04 00 00 00 00 00 00 00 ....MCFL........
000000c0: 4d 54 45 58 36 00 00 00 02 00 00 00 0c 00 6d 61 MTEX6.........ma
000000d0: 72 73 68 61 6c 6c 2e 64 64 73 22 00 32 6e 64 75 rshall.dds".2ndu
000000e0: 76 73 65 74 61 6d 62 69 65 6e 74 20 6f 63 63 6c vsetambient occl
000000f0: 75 73 69 6f 6e 20 5f 6d 72 5f 2e 74 67 61 4d 53 usion _mr_.tgaMS
00000100: 55 42 04 00 00 00 00 00 00 00 4d 45 4e 44 47 45 UB........MENDGE
00000110: 4f 42 a8 05 00 00 01 00 00 00 47 4f 42 31 9c 05 OB........GOB1..
00000120: 00 00 47 48 44 52 0c 00 00 00 00 00 00 00 00 00 ..GHDR..........
00000130: 00 00 00 00 00 00 49 4e 44 49 40 00 00 00 1e 00 ......INDI@.....
00000140: 00 00 00 00 01 00 02 00 03 00 04 00 05 00 06 00 ................
00000150: 07 00 08 00 09 00 0a 00 0b 00 0c 00 0d 00 0e 00 ................
00000160: 0f 00 10 00 11 00 12 00 13 00 14 00 15 00 16 00 ................
00000170: 17 00 18 00 19 00 1a 00 1b 00 1c 00 1d 00 56 45 ..............VE
00000180: 52 54 6c 01 00 00 1e 00 00 00 e5 f2 f3 c0 e5 f2 RTl.............
00000190: 73 41 e5 f2 f3 40 e5 f2 f3 40 e5 f2 73 41 e5 f2 sA...@...@..sA..
000001a0: f3 40 e5 f2 f3 40 e5 f2 73 41 e5 f2 f3 c0 e5 f2 .@...@..sA......
000001b0: f3 40 e5 f2 73 41 e5 f2 f3 c0 e5 f2 f3 c0 e5 f2 .@..sA..........
000001c0: 73 41 e5 f2 f3 c0 e5 f2 f3 c0 e5 f2 73 41 e5 f2 sA..........sA..
000001d0: f3 40 e5 f2 f3 c0 00 00 00 00 e5 f2 f3 40 e5 f2 .@...........@..
000001e0: f3 40 00 00 00 00 e5 f2 f3 40 e5 f2 f3 40 e5 f2 .@.......@...@..
000001f0: 73 41 e5 f2 f3 40 e5 f2 f3 40 e5 f2 73 41 e5 f2 sA...@...@..sA..
00000200: f3 40 e5 f2 f3 c0 e5 f2 73 41 e5 f2 f3 40 e5 f2 .@......sA...@..
00000210: f3 c0 00 00 00 00 e5 f2 f3 40 e5 f2 f3 40 00 00 .........@...@..
00000220: 00 00 e5 f2 f3 40 e5 f2 f3 40 00 00 00 00 e5 f2 .....@...@......
00000230: f3 c0 e5 f2 f3 40 e5 f2 73 41 e5 f2 f3 c0 e5 f2 .....@..sA......
00000240: f3 40 e5 f2 73 41 e5 f2 f3 c0 e5 f2 f3 40 e5 f2 .@..sA.......@..
00000250: 73 41 e5 f2 f3 40 e5 f2 f3 40 00 00 00 00 e5 f2 sA...@...@......
00000260: f3 40 e5 f2 f3 40 00 00 00 00 e5 f2 f3 c0 e5 f2 .@...@..........
00000270: f3 c0 00 00 00 00 e5 f2 f3 c0 e5 f2 f3 c0 e5 f2 ................
00000280: 73 41 e5 f2 f3 c0 e5 f2 f3 c0 e5 f2 73 41 e5 f2 sA..........sA..
00000290: f3 c0 e5 f2 f3 40 e5 f2 73 41 e5 f2 f3 c0 e5 f2 .....@..sA......
000002a0: f3 40 00 00 00 00 e5 f2 f3 c0 e5 f2 f3 c0 00 00 .@..............
000002b0: 00 00 e5 f2 f3 c0 e5 f2 f3 c0 00 00 00 00 e5 f2 ................
000002c0: f3 40 e5 f2 f3 c0 e5 f2 73 41 e5 f2 f3 40 e5 f2 .@......sA...@..
000002d0: f3 c0 e5 f2 73 41 e5 f2 f3 40 e5 f2 f3 c0 e5 f2 ....sA...@......
000002e0: 73 41 e5 f2 f3 c0 e5 f2 f3 c0 00 00 00 00 e5 f2 sA..............
000002f0: f3 c0 54 56 45 52 f4 00 00 00 1e 00 00 00 00 6f ..TVER.........o
00000300: a1 be 00 6f a1 be 9a 08 bb 3e 00 6f a1 be 9a 08 ...o.....>.o....
00000310: bb 3e 9a 08 bb 3e 9a 08 bb 3e 9a 08 bb 3e 00 6f .>...>...>...>.o
00000320: a1 be 9a 08 bb 3e 00 6f a1 be 00 6f a1 be 00 6f .....>.o...o...o
00000330: a1 be 00 6f a1 be 9a 08 bb 3e 00 6f a1 be 9a 08 ...o.....>.o....
00000340: bb 3e 9a 08 bb 3e 9a 08 bb 3e 9a 08 bb 3e 00 6f .>...>...>...>.o
00000350: a1 be 9a 08 bb 3e 00 6f a1 be 00 6f a1 be 00 6f .....>.o...o...o
00000360: a1 be 00 6f a1 be 9a 08 bb 3e 00 6f a1 be 9a 08 ...o.....>.o....
00000370: bb 3e 9a 08 bb 3e 9a 08 bb 3e 9a 08 bb 3e 00 6f .>...>...>...>.o
00000380: a1 be 9a 08 bb 3e 00 6f a1 be 00 6f a1 be 00 6f .....>.o...o...o
00000390: a1 be 00 6f a1 be 9a 08 bb 3e 00 6f a1 be 9a 08 ...o.....>.o....
000003a0: bb 3e 9a 08 bb 3e 9a 08 bb 3e 9a 08 bb 3e 00 6f .>...>...>...>.o
000003b0: a1 be 9a 08 bb 3e 00 6f a1 be 00 6f a1 be 00 6f .....>.o...o...o
000003c0: a1 be 00 6f a1 be 9a 08 bb 3e 00 6f a1 be 9a 08 ...o.....>.o....
000003d0: bb 3e 9a 08 bb 3e 9a 08 bb 3e 9a 08 bb 3e 00 6f .>...>...>...>.o
000003e0: a1 be 9a 08 bb 3e 00 6f a1 be 00 6f a1 be 54 56 .....>.o...o..TV
000003f0: 52 31 f4 00 00 00 1e 00 00 00 cb 10 07 3f 26 53 R1...........?&S
00000400: 35 3f 5e ba 79 3f 26 53 35 3f 5e ba 79 3f 00 00 5?^.y?&S5?^.y?..
00000410: 80 3f 5e ba 79 3f 00 00 80 3f cb 10 07 3f 00 00 .?^.y?...?...?..
00000420: 80 3f cb 10 07 3f 26 53 35 3f 89 d2 de 3b 00 00 .?...?&S5?...;..
00000430: 00 00 70 ce e8 3e 00 00 00 00 70 ce e8 3e b4 59 ..p..>....p..>.Y
00000440: 95 3e de 71 ea 3e e9 48 7e 3f 0a d7 23 3c e9 48 .>.q.>.H~?..#<.H
00000450: 7e 3f 0a d7 23 3c 9c a2 33 3f 6d 56 0d 3f 17 b7 ~?..#<..3?mV.?..
00000460: 51 39 00 00 80 3f 17 b7 51 39 00 00 80 3f eb 73 Q9...?..Q9...?.s
00000470: 95 3e 00 00 80 3f eb 73 95 3e 6d 56 0d 3f eb 73 .>...?.s.>mV.?.s
00000480: 95 3e 6d 56 0d 3f 17 b7 51 39 9f 3c 0c 3f 2a a9 .>mV.?..Q9.<.?*.
00000490: b3 3e 32 e6 7e 3f 2a a9 b3 3e 32 e6 7e 3f 6f 81 .>2.~?*..>2.~?o.
000004a0: 24 3f 32 e6 7e 3f 6f 81 24 3f 9f 3c 0c 3f 6f 81 $?2.~?o.$?.<.?o.
000004b0: 24 3f 9f 3c 0c 3f 2a a9 b3 3e 00 00 00 00 95 d4 $?.<.?*..>......
000004c0: a9 3e 26 53 e5 3e 95 d4 a9 3e 26 53 e5 3e 24 97 .>&S.>...>&S.>$.
000004d0: 1f 3f 26 53 e5 3e 24 97 1f 3f 00 00 00 00 24 97 .?&S.>$..?....$.
000004e0: 1f 3f 00 00 00 00 95 d4 a9 3e 4e 4f 52 4d 6c 01 .?.......>NORMl.
000004f0: 00 00 1e 00 00 00 00 00 00 00 00 00 80 3f 00 00 .............?..
00000500: 00 80 00 00 00 00 00 00 80 3f 00 00 00 80 00 00 .........?......
00000510: 00 00 00 00 80 3f 00 00 00 80 00 00 00 00 00 00 .....?..........
00000520: 80 3f 00 00 00 80 00 00 00 00 00 00 80 3f 00 00 .?...........?..
00000530: 00 80 00 00 00 00 00 00 80 3f 00 00 00 80 00 00 .........?......
00000540: 00 00 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 .........?......
00000550: 00 00 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 .....?..........
00000560: 80 3f 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 .?...........?..
00000570: 00 00 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 .........?......
00000580: 00 00 00 00 80 3f 00 00 80 3f 00 00 00 00 00 00 .....?...?......
00000590: 00 80 00 00 80 3f 00 00 00 00 00 00 00 80 00 00 .....?..........
000005a0: 80 3f 00 00 00 00 00 00 00 80 00 00 80 3f 00 00 .?...........?..
000005b0: 00 00 00 00 00 80 00 00 80 3f 00 00 00 00 00 00 .........?......
000005c0: 00 80 00 00 80 3f 00 00 00 00 00 00 00 80 00 00 .....?..........
000005d0: 00 00 00 00 00 00 00 00 80 bf 00 00 00 00 00 00 ................
000005e0: 00 00 00 00 80 bf 00 00 00 00 00 00 00 00 00 00 ................
000005f0: 80 bf 00 00 00 00 00 00 00 00 00 00 80 bf 00 00 ................
00000600: 00 00 00 00 00 00 00 00 80 bf 00 00 00 00 00 00 ................
00000610: 00 00 00 00 80 bf 00 00 80 bf 00 00 00 00 00 00 ................
00000620: 00 80 00 00 80 bf 00 00 00 00 00 00 00 80 00 00 ................
00000630: 80 bf 00 00 00 00 00 00 00 80 00 00 80 bf 00 00 ................
00000640: 00 00 00 00 00 80 00 00 80 bf 00 00 00 80 00 00 ................
00000650: 00 00 00 00 80 bf 00 00 00 00 00 00 00 80 42 52 ..............BR
00000660: 53 54 54 00 00 00 05 00 00 00 00 00 00 00 12 00 STT.............
00000670: 00 00 24 00 00 00 36 00 00 00 48 00 00 00 12 00 ..$...6...H.....
00000680: 00 00 12 00 00 00 12 00 00 00 12 00 00 00 12 00 ................
00000690: 00 00 00 00 00 00 04 00 00 00 03 00 00 00 05 00 ................
000006a0: 00 00 02 00 00 00 03 00 00 00 03 00 00 00 03 00 ................
000006b0: 00 00 03 00 00 00 03 00 00 00 47 45 4e 44 45 44 ..........GENDED
000006c0: 4f 46 OF
(last updated June 3, 2013 )