Game Development Community

DTS File Format Info & Help

by Wex · in Torque Game Engine · 07/31/2006 (3:58 am) · 17 replies

Hopefully if you're reading this you want to know what the DTS file format is, or have some knowledge of it.

I've search high, I've search low, I've searched varying levels inbetween. My resounding conclusion is that anyone who knows what the format is all about hasn't the time to document anything, which is all too often the case with stuff like this.

So, as I'm going I've decided to simply splurge out my findings right here in public. They may (will) be wrong, incomplete, and incomprehensible. But it's better than nowt. Hopefully someone will be able to make some sense of what I've written out here.

Personally, I'm only insterested in making static models. So no bones or animation. Which is a pretty good low-spec starting point to work out what's what in the DTS.

Just before we get down and dirty, some thanks going out to Chris Calef for helping me out and pointing me in the right direction, and to Sven 'RaCooN' Knie who wrote out an earlier specification in German. Cheers chaps.


--------------------
From this point foreward, everything's subject to errors and thus change
--------------------


So, where to begin? Well if you've read around the subject already then you aught to know that to be of any use a minimal DTS needs:

1 Bounds-node containing info as to size, position, and orientation
1 Mesh
1 Mesh-node containing mesh info
1 Collision mesh
1 Collision-node containing collision mesh info

(In 3DS models I've looked at there exist a base-node and a start-node, though they don't seem to be in the final exported DTS, I'm assuming they are merely for structure with 3DS and it's exporter)

With this in mind I put together my very own lump of programmer-art in 3DS: a cube with a cube-collision hull and a cube for the bounds-node. Not visually impressive, but easier to read than a full humanoid when we break open the DTS in a hex editor. Which is the next step...

As a sidenote, I'd like to recommend HxD as a hex editor. Free. Simple. Fast. http://mh-nexus.de/HxD.htm

Primarily a DTS is broken up into 32-bit values. That's four bytes, eight hex-digits. The first value in the DTS is the version number:

18 00 7C 00

However, this is in little-endian format, so it should be read as:

00 7C 00 18

Taking a bit of a trek through some code I came across this little snippet (adding the comments myself):

tsShape.cc [1233]
s->read(&smReadVersion); // read first 32-bits (int)
mExporterVersion = smReadVersion >> 16; // eg: 00 7C 00 18 >> 16 = 00 7C . 00 18 = 7C
smReadVersion &= 0xFF; // eg: 00 7C 00 18 & FF = 18

Assuming here that read() gets the first 32 bits of the file. If you do the maths, ExporterVersion becomes 7C and Version is 18

Whether ExporterVersion is actually used to any grand purpose I'm not sure. But the Version value is used for backwards-compatibility within the engine. We are not bothered about earlier versions, so Version for us will always be 18. We won't deal with anything less than version 18 (note: I'm going to be using hexadecimal pretty much throughout this post, it makes life easier, hex version 18 is version 24 in decimal).

We read in 32-bit integers for each value, corresponding in this order:

[head]
Versions
TotalCount - The total number of 32-bit ints to read in
Offset16 - Byte-offset into data where 16-bit values begin
Offset8 - Byte-offset into data where 8-bit values begin

[data header]
Nodes
Objects
Decals
Subshapes
IFLMaterials
Node Rotations
Node Transitions
Node Scales (Uniform)
Node Scales (Aligned)
Node Scales (Arbitrary)
Ground Frames
States?
Triggers
Details Levels
Meshes
Skins
Names
Smallest Size
Smallest Detail
Checkpoint 00
Radius
Tube Radius
CenterX
CenterY
CenterZ
MinBoundsX
MinBoundsY
MinBoundsZ
MaxBoundsX
MaxBoundsY
MaxBoundsZ
Checkpoint 01

[had to split my post, it's way too long, continued in next post...]

#1
07/31/2006 (3:58 am)
From now on the data varies in size depending on what the model is of and what is in it. The term "Object [6]" means that if your model contains 1 object, this Object data chunk will be 6 ints long. 2 objects, and it's 12 ints. Etcetera. You know how many objects you have by the "Objects" entry in the data header shown above.

Checkpoints appear every now and again, probably to let the importer/exporter know that things are progressing nicely. They increment by one each time, and are represented by a single 32-bit int.

Question marks mean I don't know, or simply haven't got the time to work it out right now (I'll continue to update this post throught the day/week).

Object [6]
Checkpoint 03
Decals [?]
Checkpoint 04
Materials [?]
Checkpoint 05
Subshapes [3 int]
Checkpoint 06
Nodes - These three entries are the same as in data header?
Objects - Or are they per-subshape?
Decals
Checkpoint 07
??? Three floats per node
Checkpoint 08
NodeScales [?]
Checkpoint 09
GroundTranslationX
GroundTranslationY
GroundTranslationZ
GroundRotationW ? Not sure about this order
GroundRotationX
GroundRotationY
GroundRotationZ
Checkpoint 0A
ObjectStates [3]
Checkpoint 0B
? Decal States Frame ? No idea.
Checkpoint 0C
Triggers [?]
Checkpoint 0D
Detail [7]
Checkpoint 0E
Meshtypes [1] (per mesh)
Checkpoint 0F
NumFrames int
MaterialFrames int
Parent? int (-1 if none?)
MinBoundsX int
MinBoundsY int
MinBoundsZ int
MaxBoundsX int
MaxBoundsY int
MaxBoundsZ int
CenterX int
CenterY int
CenterZ int
Radius int
TotalVerticies
Verticies [TotalVerticies] X Y Z (x,y,z entry for each vertex)
TotalTextureVerticies
TextureVerticies [TotalTextureVerticies] X Y Z (x,y,z entry for each tex-vertex)
Normals [TotalVerticies] X Y Z (x,y,z entry for each normal)
EncodedNormals? [TotalVerticies] (only 16-bytes each)
Checkpoint 10
???
Checkpoint 11
???
Checkpoint 12

Now the 16-byte section seems to start (as indicated by Offset16 in the head), even though the ENormals seem to be 16-byte entries and are before this point. Don't have much to report any further, as this is as far as I've gotten. A little further on in the file towards the end, in the 8-bit section, are zerobyte-seperated strings for the names of the nodes and meshes.

The 16-byte and 8-byte sections seem to have their own checkpoints all one after the other (no data inbetween) which could be due to my simple models, or just that they are unused.

That's my lot for now, hope someone out there can help me get this spec pinned down once and for all. Afterwards, when it's congealed into something that makes sense, I'll wikify it for all and everyone.

Should be more to come later on in the day, hope I'm not too wrong thus far.

Additional recent findings:
12:45
Between checkpoints 06 and 07 of 16 bit data chunk lie 3 entries per node (from "Nodes" in data header). Probably rotations.
32/16/8 bit sections are read (basically) in parrallel, you can read from any of the three at any time. When Checkpoint increments in one, it increments in all three. Checkpoints must be syncronised.

13:05
Between checkpoints 0F and 10 of 16-bit section lie 18 entries per mesh.
Between checkpoints 0F and 10 of 8-bit section lie 12 entries per mesh.
Assumed to be to do with primitives and indicies.
#2
07/31/2006 (4:57 am)
Very good work!
Thanks,
This should come in very useful for someone wanting to write a DTS importer/veiwer.
#3
07/31/2006 (8:10 am)
Cheers. It's been a week of reading hex print-outs of DTS files to get it this far.

I've just thrown together a javascript reader:

http://www.thewexionweb.com/f/dtsStats.html

Reads in a DTS and spouts out the file in hex with all it's sections split up. This is my own tool I've been using for trying to work out what's what and so it's very buggy and highly tempremental. JavaScript isn't the best thing for doing this, but it's quick to write, see results, and share. If anyone's going to take this, then I warn you, it's not computationally fast and your browser won't be happy if you load in DTS's of anything greater than a few kb. Plus there are 'grey' areas with what JavaScript is actually doing.
#4
07/31/2006 (12:18 pm)
Great work, Wex!

Just to help out anybody else who's struggling through this, I've posted the same info I sent him on my garagegames area here:

http://ccalef.garagegames2.com/dts_summary.txt
(I recommend you download this file and read it in a text editor, as it's plain text with insufficient line breaks to read well in a browser.)

It's not on TDN yet because it's ROUGH notes, my apologies -- as stated above, everybody who knows the details here is pretty much too busy to write docs at the moment, although I still harbor fantasies of cleaning this up and adding to it. I didn't want to continue holding out on whatever value might be provided, but anyone else who wants to improve and edit them would be more than welcome to put them on TDN.

Good luck!
Chris
#5
08/01/2006 (9:19 am)
And for those interested, here's Sven's document I referenced:

http://www.knie-pfaffenhofen.de/DTS-FileFormat.pdf

Though, a warning, I think it's a little off in places.
#6
02/21/2007 (12:18 pm)
Hi Chris,

I am sorry but the link you gave,
doesnt seem to work any longer.

greets,

Kris.
#7
09/06/2007 (12:37 pm)
Always nice to know someone besides me like to read hex code....
#8
01/16/2009 (9:12 pm)
Wow... fixed forum search on the new site has returned this gem of a thread from the dead.
#9
01/17/2009 (4:36 pm)
Tom:
I plan on doing more investigation in the matter.
I am plowing through lines of code now to determine the best way to create an exporter for XSI.

#10
01/17/2009 (5:15 pm)
Can someone translate this into english?
#11
01/17/2009 (5:49 pm)
Mike what do you mean?
Are you refering to the PDF --> http://www.knie-pfaffenhofen.de/DTS-FileFormat.pdf

or something else.....
#12
01/18/2009 (6:30 am)
I was refering to the pdf. After comparing it with what Wex wrote above, I think that's partly what he's doing?
#13
06/08/2009 (11:30 am)
The PDF file link is dead and I'd really love to know how to write/export DTS model files properly.

Anyone still have a copy?
#15
08/28/2009 (1:35 pm)
Certainly the one you posted is a heck of a lot better than none, but any chance of one with english comments?
#16
08/28/2009 (2:08 pm)
Here's a translated version. I hope google did a good job :)
#17
08/28/2009 (3:15 pm)
thanks.