home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / MLI.TXT < prev    next >
Text File  |  1996-08-18  |  8KB  |  241 lines

  1.  
  2.                  3D-Studio Material-Library File Format (.mli)
  3.                                Autodesk Ltd.
  4.  
  5.    Document Revision 0.1
  6.  
  7.    May 1996   by Robin Fercoq  ( email robin@mail.fc-net.fr )
  8.  
  9.    Thanks for previous work: the 3d-studio file format (.3ds) doc
  10.    rewritten by Martin van Velsen (email: vvelsen@ronix.ptf.hro.nl )
  11.    based on a work from Jim Pitts (email: jp5.ukc.ac.uk )
  12.   
  13.    A lot of the chunks are still undocumented if you know what they do
  14.    please email me Robin Feroq, Martin van Velsen or Jim Pitts.
  15.    As I get more information of the file format,I will document it for 
  16.    everyone to see. I will post this regurlarly to alt.3d and alt.3d-
  17.    studio and I can be contacted there if my email does not work.
  18.  
  19.    Disclaimer.
  20.    This document describes the file format of the .mli files generated by
  21.    3d-studio by Autodesk. By using the information contained within you 
  22.    free not to hold me liable if, from its use, you f^Hmuck something up. 
  23.    OK?
  24.  
  25.  
  26.    A warning beforehand. This docs describes the format of mli files produced
  27.    by version 3.0 and higher of 3d-studio. You can find this information at
  28.    byte 29 in the binary file.
  29.  
  30.  
  31.    This document describes the matlibs .mli files generated by 3D-Studio 4
  32.   and I think it covers nearly all of its aspects. If not you can 
  33.   contact me or Martin van Velsen or Jim Pitts to add or correct.
  34.  
  35.   First parts of .3DS files include material definitions with the same 
  36.   format than .mli, if you want to understand this part of .3DS files
  37.   you can refer to this document.
  38.  
  39.   Structure
  40.   ---------
  41.  
  42.   3D-Studio binary files are made up of "chunks".
  43.   A chunk is a block : with an ID which identifies what it stands for,
  44.   a pointer to the next chunk (relative to the beginning of the chunk),
  45.   and a block of data or a set of subchunks (which allows a hierarchy),
  46.   or possibly none of these (void chunk).
  47.   Pointers point to the next chunk of the same level.
  48.   The pointer of the last chunk of a subset points to the next chunk 
  49.   level above.
  50.   Chunk ID is 2 bytes, pointer is 4 bytes.
  51.  
  52.   If I am not clear you can read the .3ds file format doc.
  53.    ( posted on alt.3d and alt.3d-studio )
  54.     It can also be found at:
  55.       "http://www.ptf.hro.nl/odi/free-d/docs/io/3ds/3ds_bin.doc"
  56.    Or 
  57.       "http://www.mediatel.lu"
  58.  
  59.  
  60.  
  61.   Remember DOS standard for short and long integers: always
  62.   least significant byte first. I'll write in the natural
  63.   order (most significant first) except for file extracts.
  64.  
  65.  
  66.   Main chunk (level 0)  3DAA
  67.   --------------------------
  68.  
  69.   The Main chunk is the whole .MLI file. Its ID is 3DAA and the pointer
  70.   is in fact the length of the file.
  71.   Begining looks like: AA 3D A0 0F 00 00 ... (for a file of 4k)
  72.  
  73.   Material chunk (level 1) AFFF
  74.   -----------------------------
  75.  
  76.   There is only one type of chunk for level 1: the material chunk which
  77.   is the definition for one material.
  78.   This chunk can be found in .3DS files as a subchunk of the EDIT3DS chunk.
  79.   >From now its all the same with .3DS and .MLI .
  80.  
  81.  
  82.   Typical material chunk content (level 2 subchunks)
  83.   --------------------------------------------------
  84.  
  85.    Id    type     function
  86.  
  87.   A000   asciiz   material name   [the name terminated by a null char]
  88.   A010   S        ambient color   [RGB1 and RGB2]
  89.   A020   S        diffuse color       idem
  90.   A030   S        specular color      idem
  91.   A040   S        shininess       [amount of]
  92.   A041   S        shin. strength     "
  93.   A050   S        transparency       "
  94.   A052   S        trans. falloff     "
  95.   A053   S        reflect blur       "
  96.   A100   intsh    material type   [1=flat 2=gour. 3=phong 4=metal]
  97.   A084   S        self illum      [amount of]
  98.   A240 * V        some trans. falloff amount (not 0)
  99.   A250 * V        some reflect. blur
  100.   A081 * V        two sided
  101.   A083 * V        transparency ADD
  102.   A085 * V        wire on
  103.   A088 * V        face map
  104.   A08A * V        trans. falloff IN
  105.   A08C * V        soften
  106.   A08e * V        3d wire thickness in units (default is in pix)
  107.   A087   float    wire thickness (always present, in case of forced
  108.                                   wire rendering)
  109.  
  110.   S -> subchunks
  111.   V -> void
  112.   intsh -> short int (2 bytes)
  113.   intlo -> long int  (4 bytes)
  114.  
  115.   * -> optional.  Absence of such a chunk leads to "none" or
  116.   to a default value.
  117.   Order respected (as 3DS saves the .MLI)
  118.   Non optional chunks are always present.
  119.  
  120.  
  121.  
  122.   Subchunks of these material characteristics (level 3)
  123.   -----------------------------------------------------
  124.  
  125.   0011   RGB1
  126.   0012   RGB2
  127.  
  128.   Each of the three color chunks have 2 subchunks that defines their
  129.   colors. It seems that RGB1 is the color with a gamma (which one ?)
  130.   and RGB2 is the same color but as displayed on top of the material
  131.   editor window. But I'm not quite sure why there is two aspects
  132.   of the same color and what it does.
  133.   Anyway, in material color chunks there is always these two subchunks.
  134.  
  135.  
  136.   0030   "amount of"
  137.   A252   "displayed amount of bump"
  138.  
  139.   A short integer that corresponds to the value displayed.
  140.  
  141.  
  142.  
  143.   Oh, the nice maps
  144.   -----------------
  145.  
  146.   Map and mask chunks (level 2) come after the material characteristics.
  147.   (just after the A087 chunk)
  148.  
  149.   All these chunks are optional and have subchunks.
  150.  
  151.  
  152.   Map chunks IDs:
  153.  
  154.                  map       mask
  155.  
  156.   texture1       A200      A33E
  157.   texture2       A33A      A340  
  158.   opacity        A210      A342
  159.   bump           A230      A344
  160.   specular       A204      A348
  161.   shininess      A33C      A346
  162.   self illum     A33D      A34A
  163.   reflection     A220      A34C
  164.  
  165.  
  166.   In order to respect the order (well, I know, all this is terribly boring)
  167.   (but I wont joke)  (actually, I have no sens of humour)
  168.   (if I had I wouldn't spend my time with computer binary files, would I ?)
  169.   (and especialy not this one...)
  170.   the chunk of the mask of a map follows the chunk of this map.
  171.   It may be of no importance at all thanks to the chunk structure...
  172.  
  173.  
  174.   Typical map or mask chunk content (more level 3 subchunks)
  175.   ----------------------------------------------------------
  176.  
  177.    0030   intsh    amount of
  178.    A300   asciiz   map's file name
  179.    A351   intsh    map options
  180.    A353   float    map filtering blur ( 7% -> 0.07 )
  181.    A354 * float    1/U scale
  182.    A356 * float    1/V scale
  183.    A358 * float    U offset
  184.    A35A * float    V offset
  185.    A35C * float    map rotation angle
  186.   /A360 * RGB      lum or alpha tint first color (default=00 00 00)
  187.   \A362 * RGB      lum or alpha tint secnd color (default=FF FF FF)
  188.   /A364 * RGB      RGB tint R channel color (default=FF 00 00)
  189.    A366 * RGB      RGB tint G channel color (default=00 FF 00)
  190.   \A368 * RGB      RGB tint B channel color (default=00 00 FF)
  191.  
  192.   Some optional chunks may or may not be present in a given
  193.   map or mask chunk, depending on the options there is
  194.   for the specific map, or for masks.
  195.  
  196. --The map options chunk contains two bytes with options coded by bits.
  197.  
  198.   If read as a short int (ls byte first):
  199.  
  200.   bit4 bit0: 00 tile (default) 11 decal  01 both
  201.   bit 1: mirror
  202.   bit 2: not used ? (0)
  203.   bit 3: negative
  204.   bit 5: summed area map filtering (instead of pyramidal)
  205.   bit 6: use alpha  (toggles RGBluma/alpha. For masks RGB means RGBluma)
  206.   bit 7: there is a one channel tint (either RGBluma or alpha)
  207.   bit 8: ignore alpha (take RGBluma even if an alpha exists (?))
  208.   bit 9: there is a three channel tint (RGB tint)
  209.   ... not used (0)
  210.  
  211.  
  212.   Specific maps
  213.   -------------
  214.  
  215.   -bump
  216.   For a reason of him 3DS divides the amount of bump by 4.
  217.   ( in the 0030 chunk )
  218.   Nevertheless, the amount actually seen in the material editor
  219.   is coded in a specific subchunk of the bump map chunk: A252
  220.   Just after the A300 chunk.
  221.  
  222.  -reflection
  223.   The reflection map has no A351 or A353 chunks since there are no
  224.   options for reflection mapping.
  225.   If the map name is only a null caracter, then we have :
  226.  
  227.  -automatic reflection A310
  228.   A level 2 chunk just after the reflection chunk when there is
  229.   autoreflection. This chunk contains two short ints and two long ints.
  230.   1st short contains 0004. (what does that mean ?)
  231.   2nd short codes for options:
  232.     bit0 seems always set to 1
  233.     bit1 0
  234.     bit2 0
  235.     bit3 First frame only
  236.     bit4 flat mirror
  237.     bitx 0
  238.     next comes a long for the map size
  239.     and the last long is for the "every Nth frame"
  240.  
  241. And there it is