home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / 3DS_08.ZIP / 3ds.doc next >
Text File  |  1995-05-17  |  11KB  |  365 lines

  1.  
  2.  
  3.                   3D Studio File Format  (3ds).
  4.                          Autodesk Ltd.
  5.  
  6.  
  7. Document Revision 0.8 -  December 1994.  First Public Release.
  8.  
  9. If you have any additions or comments to this file please e-mail me.
  10.  
  11. A lot of the chunks are still undocumented if you know what they
  12. do please email me.  As I get more information of the file format
  13. I will document it for everyone to see.  I will post this regularly
  14. to alt.3d and I can be contacted there if my email does not work.
  15.  
  16. Disclaimer.
  17. This document describes the file format of the 3ds files of 3D studio 
  18. by Autodesk.  By using the information contained within you agree not 
  19. to hold me liable if, from its use, you f^Hmuck something up. OK?  
  20.  
  21. Oh and just to make it clear I DO NOT work for Autodesk if you have
  22. any problems with their programs direct it to them not me!
  23.  
  24. Get to it!
  25.  
  26. Now with the joviality's aside all this info I have obtained with
  27. lots of work hacking at 3ds files with a diskeditor and diff.
  28. It has taken many months of hard work and piddling around with them 
  29. so I hope that it is appreciated.
  30.  
  31. Remember information wants to be free!
  32.  
  33. *  Jim Pitts.  -  18 December 1994
  34.  
  35. Contact me at jp5@ukc.ac.uk
  36.  
  37. 1.
  38.  
  39.   The 3ds file format is made up of chunks.  They describe what information 
  40.   is to follow and what it is made up of, its ID and the location of 
  41.   the next main block.  If you don't understand a chuck you can quite simply
  42.   skip it.  The next chunk pointer is relative to the start of the current 
  43.   chunk and in bytes.
  44.  
  45.   * A Chunk.
  46.  
  47.   start end  size  name
  48.   0     1    2     Chunk ID
  49.   2     5    4     Next Chunk
  50.  
  51.   Chunks have a hierarchy imposed on them that is identified by its ID.
  52.   A 3ds file has the Primary chunk ID 4D4Dh.  This is always the first chunk 
  53.   of the file.  With in the primary chunk are the main chunks.
  54.  
  55.   * Main Chunks
  56.  
  57.    id           Description
  58.  
  59.   3D3D          Start of object mesh data.
  60.   B000          Start of keyframer data.
  61.  
  62.   The Next Chunk pointer after the ID block points to the next Main chunk.
  63.  
  64.   Directly after a Main chunk is another chunk.  This could be any other
  65.   type of chunk allowable within its main chunks scope.
  66.  
  67.   For the Mesh description (3D3D) they could be any multiples of.
  68.  
  69.   * Subchunks of 3D3D. - Mesh Block
  70.  
  71.     id          Description
  72.    1100         unknown
  73.    1200         Background Colour.
  74.    1201         unknown
  75.    1300         unknown
  76.    1400         unknown
  77.    1420         unknown
  78.    1450         unknown
  79.    1500         unknown
  80.    2100         Ambient Colour Block
  81.    2200         fog?
  82.    2201         fog?
  83.    2210         fog?
  84.    2300         unknown
  85.    3000         unknown
  86.    4000         Object Block
  87.    7001         unknown
  88.    AFFF         unknown
  89.  
  90.    * Subchunks of 4000  - Object Description Block
  91.  
  92.    - first item of Subchunk 4000 is an ASCIIZ string of the objects name.
  93.  
  94.    Remember an object can be a mesh, a light or a camera.
  95.  
  96.     id          Description
  97.    4010         unknown
  98.    4012         shadow?
  99.    4100         Triangular Polygon Object
  100.    4600         Light
  101.    4700         Camera
  102.  
  103.  
  104.    * Subchunks of 4100 - Triangular Polygon Object
  105.  
  106.     id          Description
  107.    4110         Vertex List
  108.    4111         unknown
  109.    4120         Points List
  110.    4160         Translation Matrix
  111.  
  112.    * 4110 - Vertex List
  113.  
  114.    start end  size  type        name  
  115.     0     1    2    short int   Total vertices in object    
  116.  
  117.     2     5    4    float       X value
  118.     6     9    4    float       Y value
  119.    10    13    4    float       Z value
  120.    ..    ..    .     ..           ..
  121.    ..    ..    .     ..           ..
  122.  
  123.    bytes 2 .. 13 are repeated [Total vertices in object] times for 
  124.    each vertex.
  125.  
  126.    
  127.    * 4111 - unknown
  128.  
  129.    start end  size  type        name  
  130.     0     1    2    short int   Total vertices in object ?
  131.     
  132.     2     3    2    short int   unknown
  133.     .     .    .      ..          ..
  134.     .     .    .      ..          ..
  135.  
  136.     bytes 2..3 are repeated for X times as described by 
  137.     short int at start of record.
  138.  
  139.    
  140.    * 4120 - Points List
  141.  
  142.    start end  size  type        name  
  143.     0     1    2    short int   Total polygons in object - numpoly
  144.  
  145.     2     3    2    short int   Point 1
  146.     4     5    2    short int   Point 2
  147.     6     7    2    short int   Point 3
  148.     .     .    .     ..           ..
  149.     .     .    .     ..           ..
  150.  
  151.     Repeats 'numpoly' times for each polygon.
  152.     
  153.     
  154.     These points refer to the corresponding vertex of 
  155.     the triangular polygon from the vertex list.  
  156.     Points are organized in a clock-wise order.
  157.  
  158.  
  159.    * 4160 - Translation Matrix
  160.  
  161.     This structure describes a matrix for the object.
  162.     It is stored as a 3 X 4 matrix because it is assumed that
  163.     the right most column is 0,0,0,1 
  164.  
  165.    start end  size  type        name  
  166.     0     3    4    float       matrix 1,1
  167.     4     7    4    float       matrix 1,2
  168.     8    11    4    float       matrix 1,3
  169.    12    15    4    float       matrix 2,1
  170.    16    19    4    float       matrix 2,2
  171.    20    23    4    float       matrix 2,3
  172.    24    27    4    float       matrix 3,1
  173.    28    31    4    float       matrix 3,2
  174.    32    35    4    float       matrix 3,3
  175.    36    39    4    float       matrix 4,1
  176.    40    43    4    float       matrix 4,2
  177.    44    47    4    float       matrix 4,3
  178.  
  179.  
  180.    * 4600  - Light
  181.  
  182.  
  183.    start end  size  type        name  
  184.     0     3    4    float       Light pos X
  185.     4     7    4    float       Light pos Y
  186.     8    11    4    float       Light pos Z
  187.  
  188.     after this structure check for more chunks.
  189.  
  190.         id              Description    ( full description later )
  191.        0010             RGB colour
  192.        0011             24 bit Colour
  193.        4610             Spot light
  194.        4620             Light is off   (Boolean)
  195.        
  196.  
  197.    * 4610   -  Spot Light
  198.  
  199.  
  200.    start end  size  type        name  
  201.     0     3    4    float       Target pos X
  202.     4     7    4    float       Target pos Y
  203.     8    11    4    float       Target pos Z
  204.     12   15    4    float       Hotspot
  205.     16   19    4    float       Falloff
  206.  
  207.      
  208.    * 0010  - RGB colour
  209.  
  210.    start end  size  type        name  
  211.     0     3    4    float       Red
  212.     4     7    4    float       Green
  213.     8    11    4    float       Blue
  214.  
  215.  
  216.    * 0011  - RGB colour  -  24 bit
  217.  
  218.    start end  size  type        name  
  219.     0     0    1    byte        Red
  220.     1     1    1    byte        Green
  221.     2     2    1    byte        Blue
  222.       
  223.  
  224.    * 4700  - Camera
  225.  
  226.    Describes the details of a camera in the scene.
  227.  
  228.    start end  size  type        name  
  229.     0     3    4    float       Camera pos X
  230.     4     7    4    float       Camera pos Y
  231.     8    11    4    float       Camera pos Z
  232.     12   15    4    float       Target pos X
  233.     16   19    4    float       Target pos Y
  234.     20   23    4    float       Target pos Z
  235.     24   27    4    float       Camera Bank       
  236.     28   31    4    float       Camera Lens
  237.  
  238.    * 7001  - unknown chunk
  239.  
  240.    nothing known about this chunk except for its Subchunks.
  241.    This chunk also exists as a Subchunk in chunk B000 (keyframer info).
  242.  
  243.     id          Description
  244.    7011         unknown
  245.    7020         unknown
  246.  
  247.  
  248.    * B000   -  Keyframer Main chunk.
  249.  
  250.    Subchunks are
  251.  
  252.     id          Description
  253.    B00A         unknown
  254.    7001         unknown
  255.    B008         Frames  
  256.    B009         unknown
  257.    B002         Start object description
  258.  
  259.  
  260.    * B008   - Frame information
  261.  
  262.      simple structure describing frame info.
  263.  
  264.    start end  size  type        name  
  265.      0    3     4   integer     start frame
  266.      4    7     4   integer     end frame
  267.  
  268.  
  269.    * B002   - Start of Object info
  270.  
  271.      Subchunks
  272.  
  273.      id         Description
  274.     B010        Name & Hierarchy
  275.     B011*       Name Dummy object
  276.     B013        unknown
  277.     B014*       unknown
  278.     B015        unknown
  279.     B020        Objects pivot point?
  280.     B021        unknown
  281.     B022        unknown
  282.  
  283.  
  284.          ( * only on dummy objects )
  285.  
  286.    * B010   -  Name & hierarchy descriptor
  287.  
  288.    start end  size  type        name  
  289.      0    ?     ?   ASCIIZ      Object name
  290.      ?    ?     ?   short int   unknown
  291.      ?    ?     ?   short int   unknown
  292.      ?    ?     ?   short int   Hierarchy of object
  293.  
  294.      The object hierarchy is a bit complex but works like this.
  295.      Each object in the scene is given a number to identify its 
  296.      order in the tree.  Also each object is ordered in the 3ds 
  297.      file as it would appear in the tree.
  298.      The root object is given the number -1 (FFFF).
  299.      As the file is read a counter of the object number
  300.      is kept.
  301.      Is the counter increments the object are children of the previous
  302.      objects.  But when the pattern is broken by a number that will be
  303.      less than the current counter the hierarchy returns to that level.
  304.  
  305.      for example.
  306.  
  307.              object   hierarchy
  308.              name
  309.  
  310.                 A      -1
  311.                 B       0
  312.                 C       1                       This example is taken
  313.                 D       2                       from 50pman.3ds.
  314.                 E       1
  315.                 F       4                       I would really recommend
  316.                 G       5                       having a look at one of
  317.                 H       1                       the example with the
  318.                 I       7                       hierarchy numbers to help
  319.                 J       8                       work it out.
  320.                 K       0
  321.                 L      10
  322.                 M      11                       (if you can describe it
  323.                 N       0                        any better please let
  324.                 O      13                        me know. )
  325.                 P      14
  326.  
  327.  
  328.  
  329.  
  330.                                A
  331.            +-------------------+---------------+
  332.            B                   K               N
  333.        +---+---+               +               +
  334.        C   E   H               L               O
  335.        +   +   +               +               +
  336.        D   F   I               M               P
  337.            +   +
  338.            G   J
  339.  
  340.  
  341.  
  342.        Still not done with this chunk yet!
  343.  
  344.        If the object name is $$$DUMMY then it is a dummy object 
  345.        and therefore you should expect a few extra chunks.
  346.  
  347.  
  348.    *  B011   -  Dummy objects name.
  349.  
  350.         Names a dummy object. ASCIIZ string.
  351.  
  352.    *  B020  - Pivot Point?
  353.  
  354.    The objects pivot point.  Not quite sure what the first 
  355.    five floats do yet (ideas?).
  356.  
  357.    start end  size  type        name  
  358.      0    3     4   float       unknown    
  359.      4    7     4   float       unknown  
  360.      8   11     4   float       unknown    
  361.     12   15     4   float       unknown  
  362.     16   19     4  27     4   float       Pivot Y    
  363.     28   32     4   float       Pivot Z  
  364.  
  365.