home *** CD-ROM | disk | FTP | other *** search
/ Avalon - 3D Objects & Resources / Avalon.iso / frmtspcs / t3d_doc1.txt < prev    next >
Text File  |  1995-01-01  |  35KB  |  776 lines

  1.  
  2.                                  FORM TDDD
  3.                                  ---------
  4.                        Imagine 3.0 Object File Format
  5.  
  6.                          Rev 3.0  05-19-94 S.Kirvan
  7.                 Copyright 1994 Impulse Inc., Mpls, MN 55444
  8.  
  9.     Disclaimer:
  10.         All information contained herein is subject to change without
  11.         notice.  Knowledge is dangerous - use at your own risk.  No
  12.         warranties are made or implied, and no liability or responsibility
  13.         is assumed.     Good luck.
  14.  
  15. SCOPE:
  16. =====
  17.  
  18. This text will describe Imagine 3.0's basic object file format.  It is
  19. beyond the scope of this text to describe any of the file formats used for
  20. spline objects, deform tool, or any other object types not mentioned below.
  21. However, some of the data described below may apply to some of these
  22. undocumented object formats.  It is also not the intent of this document to
  23. explain the implementation of the information contained in the TDDD files
  24. (ie. what equations we use to represent Imagine's paths - lighting models -
  25. forms geometry - tweening algorithms, etc.).
  26.  
  27. GENERAL INFO:
  28. ============
  29.  
  30. FORM TDDD is used by Impulse's Imagine 3.0 for 3D rendering data.  TDDD
  31. stands for "3D data description".  The files contain 3D object
  32. definitions, and can be extended to describe different types of object
  33. information.
  34.  
  35. The TDDD file is stored in Amiga (680x0) format, and conforms to the "IFF"
  36. file format on that computer.  On IBM (80x86) based machines, much of the
  37. data refered to below will have to be byte reversed before it makes sense.
  38.  
  39. The IFF (interchange file format) format stores data in packets called
  40. "chunks."  Each chunk begins with a long word identifier <ID> in ascii
  41. format.  This identifier is immediately followed by a long word data-size.
  42. The data-size is measured in bytes and descrbes how much data, following
  43. the data-size long word, is part of the chunk identified by the <ID>.  
  44. Imagine's IFF structure supports nesting of these chunks.  For more info on
  45. the IFF standard, see the "Amiga ROM Kernal Reference Manual: Devices (3rd
  46. Edition)."
  47.  
  48. Currently, in "standard IFF" terms, a FORM TDDD has only one supported chunk
  49. type:  an OBJ chunk describing the object heirarchy.
  50.  
  51. The OBJ chunk, in turn, is made up of smaller chunks with the standard IFF
  52. structure:  <ID> <data-size> <data>.
  53.  
  54. The OBJ "sub-chunks" support object heirarchies.  Currently, there are 2
  55. types of supported OBJ sub-chunks:  A DESC chunk, describing one node of a
  56. heirarchy; and a TOBJ chunk marking the end of a heirarchy chain.  For each
  57. DESC chunk, there must be a corresponding TOBJ chunk.
  58.  
  59. In Imagine, the structure of the object heirarchy is as follows:  Each
  60. heirarchy has a head (parent) object. The parent may have child objects.
  61. The children may have grandchildren, and so on. An object with children is
  62. a "grouped" object within Imagine.
  63.  
  64. Each object heirarchy is written in an OBJ chunk, along with all its
  65. descendants.  The descendant heirarchy is supported as follows:
  66.  
  67.    starting with the head (parent) object,
  68.  
  69.    1)  A DESC chunk is written, describing the object.
  70.    2)  If the object in 1) has children, steps 1) thru 3) are performed
  71.                 for each child.
  72.    3)  A TOBJ chunk is written, marking the end of the object description.
  73.  
  74. The TOBJ sub-chunks have zero size -- and no data.  The DESC sub-chunks are
  75. made up of "sub-sub-chunks", again, with the standard IFF structure:
  76. <ID> <data-size> <data>.
  77.  
  78. Reader software WILL FOLLOW the standard IFF procedure of skipping over any
  79. un-recognized chunks -- and "sub-chunks" or "sub-sub-chunks".  The
  80. <data-size> field indicates how many bytes to skip.  In addition it WILL
  81. OBSERVE the IFF rule that an odd <data-size> may appear, in which case the
  82. corredponding <data> field will be padded at the end with one extra byte to
  83. give it an even size.
  84.  
  85. DATA TYPES:
  86. ==========
  87.  
  88. First, there are several numerical fields appearing in the data, describing
  89. object positions, rotation angles, scaling factors, etc.  They are stored as
  90. "32-bit fractional" numbers, such that the true number is the 32-bit number
  91. divided by 65536.  So as an example, the number 3.14159 is stored as
  92. (hexadecimal) 0x0003243F (ie. 0x0003243F / 65536 = 3.14159).  This allows
  93. the data to be independant of any particular floating point format.  Numbers
  94. stored in this format are typedef'ed as "FRACT"s below.
  95.  
  96. Second, there are several color (or RGB) fields in the data.  They are
  97. always stored as three UBYTEs representing the red, green and blue
  98. components of the color.  Red is always first, followed by green, and then
  99. blue.  For some of the data chunks, Imagine reads the color field into the
  100. 24 LSB's of a LONGword.  In such cases, the 3 RGB bytes are preceded by a
  101. zero byte in the file.
  102.  
  103.     The three basic data types that will be refered to herein are:
  104.  
  105.     BYTE        :  a single byte of data (char)
  106.     WORD        :  a two byte data field (short)
  107.     LONG        :  a four byte data field (long)
  108.  
  109.     A "U" (ie. UBYTE) means unsigned.
  110.  
  111.     The following "typedef"s are used below:
  112.  
  113.     typedef LONG    FRACT;                /* 4 bytes */
  114.     typedef UBYTE   COLOR[3];             /* 3 bytes */
  115.  
  116.     typedef struct vectors {
  117.         FRACT X;          /* 4 bytes */
  118.         FRACT Y;          /* 4 bytes */
  119.         FRACT Z;          /* 4 bytes */
  120.     } VECTOR;             /* 12 bytes total */
  121.  
  122.     typedef struct matrices {
  123.         VECTOR I;         /* 12 bytes */
  124.         VECTOR J;         /* 12 bytes */
  125.         VECTOR K;         /* 12 bytes */
  126.     } MATRIX;             /* 36 bytes total */
  127.  
  128.     typedef struct _tform {
  129.         VECTOR r;         /* 12 bytes - position */
  130.         VECTOR a;         /* 12 bytes - x axis */
  131.         VECTOR b;         /* 12 bytes - y axis */
  132.         VECTOR c;         /* 12 bytes - z axis */
  133.         VECTOR s;         /* 12 bytes - size */
  134.     } TFORM;              /*  60 bytes total */
  135.  
  136.     typedef struct _pthd {
  137.         TFORM   PData;    /* axis data */
  138.         UWORD   inFrom;   /* previous axis number */
  139.         UWORD   outTo;    /* next axis number */
  140.         UWORD   flags;    /* flags for this axis */
  141.                           /*   Bit 0 - reserved - zero for "Detail Editor" paths
  142.                           /*   Bit 1 - an axis connects in to this axis
  143.                           /*   Bit 2 - an axis connects out of this axis
  144.                           /*   Bits 3 thru 15 - reserved
  145.         UWORD   pad;      /* reserved */
  146.     } PTHD;
  147.  
  148. DESC SUB-SUB-CHUNKS:
  149. ===================
  150.  
  151. NAME - size 18
  152.  
  153.     BYTE    Name[18];       ; a name for the object.
  154.  
  155.     Object's name as it appears in the attributes requester.  Used for
  156.     tracking, etc.
  157.  
  158. SHP2 - size 4
  159.  
  160.     WORD    Shape;          ; number indicating object type
  161.     WORD    Lamp;           ; bit field indicating lamp type
  162.  
  163.     Valid shape numbers are:
  164.  
  165.         0 - Sphere
  166.         2 - Axis            ; custom objects with points/faces
  167.         5 - Ground
  168.         1, 3, and 4 are reserved, and should never appear in TDDD files.
  169.  
  170.     Perfect spheres have thier radius set by the X size parameter (see SIZE
  171.     chunk).  A ground object is an infinte plane perpendicular to the world
  172.     Z axis.  Its Z coordinate sets its height, and the X and Y coordinates
  173.     are only relevant to the position of the "hot point" used in selecting
  174.     the object in the editor (see POSI chunk).  Custom objects have points,
  175.     edges and triangles associated with them.  Imagine's primative objects
  176.     are cumstom (type 2) objects.  The size fields are relevant only for
  177.     drawing the object axes in the editor.
  178.  
  179.     Lamp numbers are composed of several bit fields:
  180.  
  181.     Bit 0  - Point light source.
  182.     Bit 1  - Parallel light source.
  183.     Bit 2  - Round shape.
  184.     Bit 3  - Rectangular shape.
  185.  
  186.     Bit 4  - No Lens Flare FX flag.
  187.     Bit 5  - 1/R Diminishing intensity.
  188.     Bit 6  - Controlled falloff.
  189.     Bit 7  - Cast Shadows.
  190.  
  191.     Bits 8 to 14 - reserved.
  192.     Bit 15 - Bright object.
  193.  
  194.     For a light casting object, bit 0 or 1 must be set - all other bits are
  195.     optional.  All lights emminate from the object's axes (see POSI, SIZE,
  196.     and AXIS chunk) and shadow casting lights will be blocked by faces that
  197.     have neither fog nor transparent attributes.
  198.  
  199. POSI - size 12
  200.  
  201.     VECTOR  Position;       ; the object's position.
  202.  
  203.     This is the position (in world coordinates) of the object's axes.  Legal
  204.     coordinates are in the range -32768 to 32767 and 65535/65536.
  205.  
  206. AXIS - size 36
  207.  
  208.     VECTOR  XAxis;
  209.     VECTOR  YAxis;
  210.     VECTOR  ZAxis;
  211.  
  212.     These are direction vectors for the object coordinate system.  They must
  213.     be "orthogonal unit vectors" (ortho-normal) - i.e. the sum of the
  214.     squares of the vector components must equal one (or close to it), and
  215.     the vectors must be perpendicular.
  216.  
  217. SIZE - size 12
  218.  
  219.     VECTOR  Size;       ; object size info
  220.  
  221.     See SHAP chunk above.  The sizes are used in a variety of ways depending
  222.     on the object shape.  For custom objects and lights, they are the
  223.     lengths of the coordinate axes drawn in the editor.
  224.  
  225. BBOX - size 24
  226.  
  227.     FRACT bounds[6];           ;bounding box data
  228.  
  229.     The descriptions of the bounds array is as follows:
  230.  
  231.     bounds[0] - negative X boundary (relative to object axis position)
  232.     bounds[1] - negative Y boundary
  233.     bounds[2] - negative Z boundary
  234.     bounds[3] - posative X boundary
  235.     bounds[4] - posative Y boundary
  236.     bounds[5] - posative Z boundary
  237.  
  238.     This chunk contains the objects bounding box info for use in improving
  239.     redraw and loading speed when using Imagine's quick stage mode.
  240.  
  241. STND - variable size
  242.  
  243.     The data in an STND chunk consists only of smaller sub-chunks.
  244.     STID and STDT are the only types defined so far.
  245.  
  246.     This is Imagine's state data chunk.  There is a STND chunk for each
  247.     (named) state in an object.  Each STND chunk will contain a STID
  248.     (state ID) chunk followed by one or several STDT (state data) chunks.
  249.     (see STID and STDT chunks)
  250.  
  251. STID - size 20
  252.  
  253.     BYTE stid[18];      ; state name
  254.     UWORD stFlags;      ; state flags
  255.                         ;   Bit 0 - contains axis data (group)
  256.                         ;   Bit 1 - contains shape data (points)
  257.                         ;   Bit 2 - contains color/properties data
  258.                         ;   Bits 3 thru 15 - reserved
  259.  
  260.     This chunk contains the state name and a description of the type of data
  261.     assiciated with this state.  This chunk will only appear within a STND
  262.     chunk and is usually followed by one or more STDT chunks.
  263.  
  264. STDT - variable size
  265.  
  266.     WORD tag;               ; state data type tags
  267.                             ;   tag values are as follows:
  268.                             ;   101 - contains object axis info
  269.                             ;   102 - contains point (vertex) data
  270.                             ;   103 - contains path data
  271.                             ;   104 - contains axis size data
  272.                             ;   105 - contains face color data (CLST)
  273.                             ;   106 - contains face filter data (TLST)
  274.                             ;   107 - contains face reflect data (RLST)
  275.                             ;   108 - contains object attribute data
  276.                             ;   all other values are reserved
  277.     WORD flags;             ; state data flags
  278.     BYTE stateData[size];   ; state data - variable size
  279.  
  280.     This is the state data chunk.  The tag value describes what kind of
  281.     information is actually stored within the stateData[] array.  This chunk
  282.     will only appear within a STND chunk and will be preceded by either a
  283.     STID chunk or another STDT chunk.  The stateData[] array is interpreted
  284.     as follows depending upon the tag type:
  285.  
  286.         tag = 101 - contains object axis info - saved with grouping
  287.             VECTOR axis_r;           ; axis position vector
  288.             MATRIX axis_m;           ; axis alignment vectors
  289.             (48 bytes total)
  290.  
  291.             See AXIS and POSI chunks.
  292.  
  293.         tag = 102 - contains point (vertex) data - saved with shape
  294.             VECTOR obj_points[point_count];     ; object's points in 3 space
  295.             (12 * point_count bytes total)
  296.  
  297.             point_count = point count for object - e.g. from PNTS chunk
  298.  
  299.         tag = 103 - contains path data - saved with shape
  300.             PTHD pdata[ACount];        ; path data for object
  301.             (68 * ACount bytes total)
  302.  
  303.             ACount = axis count for object - e.g. from PTH2 chunk
  304.  
  305.         tag = 104 - contains axis size data - saved with shape
  306.             VECTOR size;            ; object size info
  307.             (12 bytes total)
  308.  
  309.             See SIZE chunk.
  310.  
  311.         tag = 105 - contains face color data (CLST) - saved with properties
  312.             COLOR   colors[face_count];          ; color values
  313.             (face_count * 3 bytes total)
  314.  
  315.             face_count = face count for object - e.g. from FACE/CLST,...
  316.  
  317.         tag = 106 - contains face filter data (TLST) - saved with properties
  318.             COLOR   filter[face_count];          ; filter values
  319.             (face_count * 3 bytes total)
  320.  
  321.             face_count = face count for object
  322.  
  323.         tag = 107 - contains face reflect data (RLST) - saved with properties
  324.             COLOR   reflect[face_count];          ; reflect values
  325.             (face_count * 3 bytes total)
  326.  
  327.             face_count = face count for object
  328.  
  329.         tag = 108 - contains object attribute data - saved with properties
  330.             UBYTE   props[8];           ; object properties (PRP1 chunk)
  331.             UWORD   lamp;               ; bit field - lamp type (SHP2 chunk)
  332.             UWORD   flags;              ; reserved
  333.             VECTOR  intensity;          ; light intensity (INT1 chunk)
  334.             FRACT   foglen;             ; value of foglength (FOGL chunk)
  335.             UBYTE   color[4];           ; object color  (COLR chunk)
  336.             UBYTE   reflect[4];         ; object reflectance (REFL chunk)
  337.             UBYTE   filter[4];          ; object transparency (TRAN chunk)
  338.             UBYTE   specular[4];        ; object specularity (SPC1 chunk)
  339.             (44 bytes total)
  340.  
  341.             Note that the properties state does not save texture/brush info,
  342.             only object base attributes.  See PRP1, SHP2, INT1, FOGL, COLR,
  343.             REFL, TRAN, SPC1 chunks.
  344.  
  345. PNTS - size 2 + 12 * point count
  346.  
  347.     UWORD   PCount;                    ; point count
  348.     VECTOR  Points[point_count];       ; points
  349.  
  350.     This chunk has all the points for custom (type 2 - axis) objects.
  351.     point_count is the total number of points on the object.  Edges will
  352.     refer to these points by thier position in the Points[] array (i.e.
  353.     the point numbers appearing below run from 0 through point_count - 1).
  354.  
  355. EDGE - size 2 + 4 * edge_count
  356.  
  357.     UWORD   ECount;                   ; edge count
  358.     UWORD   Edges[edge_count][2];     ; edges
  359.  
  360.     This chunk contins the edge list for custom objects.  The Edges[][2]
  361.     array is pairs of point numbers that are connected by the edges.  The
  362.     values of Edges[n][0] and Edges[n][1] will thus be between 0 and
  363.     point_count - 1, and the Points[] array will have to be refered to to
  364.     find the endpoint positions of this edge.  Faces will refer to these
  365.     edges by thier position in the Edges[][] array (i.e. the edge numbers
  366.     appearing below run from from 0 to edge_count - 1). (See PTNS chunk)
  367.  
  368. FACE - size 2 + 6 * face count
  369.  
  370.     UWORD   FCount;         ; face count
  371.     UWORD   Faces[][3];     ; faces
  372.  
  373.     This chunk contains the triangle (face) list for custom objects.  The
  374.     Faces[][3] array is triples of edge numbers that are connected to form
  375.     triangles.  This back references through the Edge list and then through
  376.     the Point list to find the 3 space coordinates of the face's vertexes.
  377.     (See EDGE and PNTS chunks)  Note: it is possible that the edge numbers
  378.     given for a face would use more than 3 point numbers all together ...
  379.     this should be considered as an error ... however, Imagine doesn't
  380.     enforce the desired constsistency when objects are loaded.  This can
  381.     lead to some confusion when testing "first time" code, since Imagine
  382.     sometimes uses only the first two edge numbers, assumeing that the
  383.     3rd edge is constsient with the 1st two.
  384.  
  385. PTH2 - size 2 + 68 * axis count
  386.  
  387.     UWORD   ACount;         ; axis count
  388.     PTHD    PData[ACount];  ; path (axis) data
  389.  
  390.     This chunk contains the axis data for Imagine "path" objects.  ACount is
  391.     the number of axes in the path object.  The PData array contains a bit
  392.     of data for each point (axis) along the path.  A closed path is made
  393.     by setting the value of the inFrom[] variable of the first axis to the
  394.     number of the last axis, and setting the outTo[] variable of the last
  395.     axis to the number of the first axis (1).  An open path will have to
  396.     have the flags[] bits 1 (or 2) clear, showing that the first (or last)
  397.     axis is only connected on one side ... the 1st axis should show a
  398.     "connected out" flag, and the last axis should show a "connected in"
  399.     flag only.
  400.  
  401. COLR - size 4
  402. REFL - size 4
  403. TRAN - size 4
  404. SPC1 - size 4
  405.  
  406.     BYTE    pad;            ; pad byte - must be zero
  407.     COLOR   col;            ; RGB color
  408.  
  409.     These are the main object RGB color, and reflection, transmission and
  410.     specularity coefficients.
  411.  
  412. CLST - size 2 + 3 * face_count
  413. RLST - size 2 + 3 * face_count
  414. TLST - size 2 + 3 * face_count
  415.  
  416.     UWORD   face_count;                  ; number of faces
  417.     COLOR   colors[face_count];          ; colors
  418.  
  419.     These are the color, reflection and transmission coefficients for each
  420.     face in custom (type 2 - axis) objects. The face_count has to match the
  421.     face count in the FACE chunk. The ordering corresponds to the face
  422.     order.  When the objects main attributes are altered, the new color
  423.     values are copied into the whole colors[] array.  Modifying color
  424.     values in face mode or choosing "randomize colors" from the attributes
  425.     requester will independantly alter the values in the colors[][] array.
  426.     This chunk appears in all custom (type 2 - axis) objects.
  427.  
  428. TXT3 - variable size
  429.  
  430.     UWORD   Flags;          ; texture flags:
  431.                             ;     Bit  0         - apply to child objs
  432.                 ;     Bits 1 thru 15 - reserved
  433.     TFORM   TForm;          ; local coordinates of texture axes.
  434.     FRACT   Params[16];     ; texture parameters
  435.     UBYTE   PFlags[16];     ; parameter flags for texture requester
  436.                             ;   Bit 0 - alter red color in color chip
  437.                             ;   Bit 1 - alter green color in color chip
  438.                             ;   Bit 2 - alter blue color in color chip
  439.                             ;   Bit 3 - alter parameter when resizing object
  440.                             ;   Bits 4 thru 7 - reserved
  441.     BYTE    SubGr[18];      ; Subrgoup to restrict texture to
  442.     BYTE    LockState[18];  ; State name for "texture tacking"
  443.     UBYTE   Length;         ; length of texture file name
  444.     UBYTE   Name[Length];   ; texture file name (not NULL terminated)
  445.     UBYTE   optionalpad;    ; appears only if the name string has an even
  446.                             ; length -- so the total length of the name
  447.                 ; "block" (length + name + pad?) comes out even
  448.  
  449.     This chunk contains the texture data necessary for the renderer to
  450.     communicate with Imagine's procedural texture modules and for
  451.     positioning textures on objects.  Subgr[], if used, restricts the
  452.     texture application to the named subgroup.  LockState[], if used, will
  453.     lock (tack) the texture to the object's faces for object morphing
  454.     without texture sliding.  The values in Params[] are tweened
  455.     (interpolated) internally by Imagine when morphing/animating textures.
  456.     A TXT3 chunk appears for each texture applied to an object.
  457.  
  458. BRS4 - variable size
  459.  
  460.     UWORD   Flags;          ; brush type:
  461.                             ;    0 - Color
  462.                             ;    1 - Reflectivity
  463.                             ;    2 - Filter
  464.                             ;    3 - Altitude
  465.                             ;    4 - Reflection
  466.     UWORD   WFlags;         ; brush wrapping flags:
  467.                             ;    Bit 0 - wrap x
  468.                             ;    Bit 1 - wrap z
  469.                             ;    Bit 2 - apply to children
  470.                             ;    Bit 3 - repeat brush
  471.                             ;    Bit 4 - mirror with repeats
  472.                             ;    Bit 5 - inverse video
  473.                             ;    Bit 6 - Use genlock
  474.     TFORM   TForm;          ; local coordinates of brush axes.
  475.     UWORD   FullScale;      ; full scale value
  476.     UWORD   MaxSeq;         ; highest number for sequenced brushes
  477.     BYTE    SubGr[18];      ; Subrgoup to restrict brush to
  478.     BYTE    LockState[18];  ; Brush lockstate
  479.     UBYTE   Length;         ; length of brush file name
  480.     UBYTE   Name[Length];   ; brush file name (not NULL terminated)
  481.     UBYTE   optionalpad     ; if name has even length (see TXT3 description)
  482.  
  483.     This chunk contains the brush data necessary for the renderer to load
  484.     and position brush maps (texture maps) on objects.  FullScale is used
  485.     to map the highest color value within a brush map to full-scale 255 for
  486.     Imagine's internal interpritation of the brush.  Subgr[], if used,
  487.     restricts the brush application to the named subgroup.  LockState[], if
  488.     used, will lock (tack) the brush to the object's faces for object
  489.     morphing without texture sliding.  The value in MaxSeq is tweened
  490.     (interpolated) internally, from 1 to MaxSeq, by Imagine when animating
  491.     brushes - this way, brush morphing can be accomplished.  A BRS4 chunk
  492.     appears for each brush map applied to an object.
  493.  
  494.  
  495. FOGL - size 4
  496.  
  497.     FRACT foglen;           ; value of foglength attribute
  498.  
  499.     This is the object foglength set in Imagine's attributes requester.
  500.  
  501. PRP1 - size 8
  502.  
  503.     UBYTE   IProps[8];       ; more object properties
  504.  
  505.     The discriptions of the IProps array is as follows:
  506.  
  507.     IProps[0] - dithering factor (0-255)
  508.     IProps[1] - hardness factor (0-255)
  509.     IProps[2] - roughness factor (0-255)
  510.     IProps[3] - shinyness factor (0-255)
  511.     IProps[4] - index of refraction - ir = (float)IProps[4] / 100.0 + 1.0;
  512.     IProps[5] - quickdraw type: 0=none, 1=bounding box, 2=quick edges
  513.     IProps[6] - flag - Phong shading on/off
  514.     IProps[7] - flag - Genlock on/off
  515.  
  516.     The dithering factor controls the amount of color dithering used on the
  517.     object - 255 is fully dithered.  The hardness factor controls how tight
  518.     the specular spot should be - 0 is a big soft spot, 255 is a tight hot
  519.     spot  The roughness factor controls how rough the object should appear
  520.     - 0 is smooth, 255 is max roughness.  The shiny factor in interaction
  521.     with the object's filter values controls how shiny the object appears.
  522.     Setting it to anything but zero forces the object to be non-transparent
  523.     since then the filter values are used in the shiny (reflection)
  524.     calculations.  A value of 255 means maximum shinyness.
  525.  
  526. INT1 - size 12
  527.  
  528.     VECTOR  Intensity;      ; light intensity
  529.  
  530.     This has seperate R, G & B intensities for the light objects.  Note
  531.     that these color values are stored as FRACT's and are not limited to
  532.     the 0 to 255 range of the usual UBYTE color values so lights can be
  533.     brighter than 255 255 255.
  534.  
  535. ANID - size 64
  536.  
  537.     LONG    Cellno;         ; cell number ("key" cell)
  538.     TFORM   TForm;          ; object position/axes/size in that cell.
  539.  
  540.     For Imagine's "Cycle" objects, within EACH DESC chunk in the file -
  541.     that is, for each object of the group, there will be a series of ANID
  542.     chunks.  The cell number sequences of each part of the group must agree
  543.     with the sequence for the head object, and the first cell number must
  544.     be zero.
  545.  
  546. FOR2 - size 56 + 12 * PC + 2 * keys
  547.  
  548.     WORD    NumC;               ; number of cross section points
  549.     WORD    NumF;               ; number of slices
  550.     WORD    Flags;              ; forms object type flag
  551.                                 ;   Bit 0 - X-Y Cross Section
  552.                                 ;   Bit 1 - One Former View
  553.                                 ;   Bit 2 - One Spacer View
  554.                                 ;   Bits 3 thru 15 - reserved
  555.                                 ;   (bit 0 off means Y-Z Cross Section)
  556.                                 ;   (bits 1 and 2 off means Two Former Views)
  557.     WORD    keys;               ; number of defined key sections
  558.     MATRIX  TForm;              ; object rotation/scaling transformation
  559.     VECTOR  Shift;              ; object translation
  560.     VECTOR  Points[PC];         ; "Forms" editor points
  561.     WORD    sexions[keys];      ; list of key sections by number
  562.  
  563.     For Imagine's "Forms" objects, the "PNTS" chunk above is not written
  564.     out, but this structure is written instead.  The object's real points
  565.     are then calculated from these using a proprietary algorithm.  The
  566.     tranformation parameters above allow the axes of the real object be
  567.     moved around relative to the "Forms" points.  The value, PC, is
  568.     calculated as follows:
  569.  
  570.         for Two Former Views:
  571.             PC = keys * NumC + 4 * NumF;
  572.  
  573.         for One Former View:
  574.             PC = keys * NumC + 2 * NumF;
  575.  
  576.         for One Spacer View:
  577.             PC = keys * NumC + 1 * NumF;
  578.  
  579. PART - size 6
  580.  
  581.     WORD type;          ; tells what type of particles to use
  582.                         ;   bits 0-3:  shape
  583.                         ;       0x0000 - faces (no particles)
  584.                         ;       0x0001 - tetrahedrons
  585.                         ;       0x0002 - pyramids
  586.                         ;       0x0003 - octahedrons
  587.                         ;       0x0004 - cubes
  588.                         ;       0x0005 - blocks
  589.                         ;       0x0006 - dodecahedrons
  590.                         ;       0x0007 - spheres
  591.                         ;       0x0008 - random
  592.                         ;       0x0009 - use object file
  593.                         ;   bits 4-7:  centering
  594.                         ;       0x0000 - inscribed
  595.                         ;       0x0010 - circumscribed
  596.                         ;       0x0020 - interpolated
  597.                         ;       0x0030 - barycentric
  598.                         ;   bits 8-11:  size
  599.                         ;       0x0000 - small
  600.                         ;       0x0100 - large
  601.                         ;       0x0200 - random
  602.                         ;       0x0300 - specify
  603.                         ;   bits 12-15:  alignment
  604.                         ;       0x0000 - to object
  605.                         ;       0x1000 - to face
  606.                         ;       0x2000 - random
  607.     FRACT size;         ; used with specify size
  608.  
  609.     This is the main object particalization parameters.  This chunk
  610.     describes the geometry of the particles to be used in place of the
  611.     objects faces.  The PTFN chunk contains the file name of the "use
  612.     object file" type of particles, and the FGR2 chunk contains the
  613.     particle geometry info for specific sub groups.  Particles only work
  614.     on custom (type 2 - axis) objects with faces.  (see PTFN and FGR2
  615.     chunks)
  616.  
  617. PTFN - variable size
  618.  
  619.     BYTE length;                 ; number of characters in the file name
  620.     BYTE PartFileName[length];   ; particle file name (not null terminated)
  621.     BYTE optionalpad;            ; appears only if name has an even length
  622.                                  ; (see TXT3 description)
  623.  
  624.     For Imagine's particalized objects.  This is the filename for the "use
  625.     object file" type of particlization. (see PART chunk)
  626.  
  627. FGR2 - variable size
  628.  
  629.     UWORD faceCount;            ; the number of faces in this subgroup
  630.     BYTE  subGrName[18];        ; the name of the subgroup
  631.     UWORD faceNums[faceCount];  ; the list of faces in this subgroup
  632.     UWORD pType;                ; subgroup particle type - see PART chunk
  633.     FRACT pSize;                ; subgroup particle size - see PART chunk
  634.     UBYTE pFNSize;              ; character count in the particle file name
  635.     BYTE  pFName[pFNSize];      ; particle filename - see PTFN chunk
  636.     BYTE  optionalpad;          ; appears only if name has an even length
  637.  
  638.     This is the Subgroup info for Imagine's custom (type 2 - axis) objects
  639.     which have subgroups - the mnemonic, FGR2, stands for face group.
  640.     pType, pSize, pFNSize, and pFName all deal with particalized subgroups.
  641.     The faceNums[] array is a list of faces by numerical position in the
  642.     face list as described in the FACE chunk.  Valid face numbers run from
  643.     zero through object_face_count - 1.
  644.  
  645. BBSG - size 18
  646.  
  647.     BYTE bbsg[18];      ; big bone subgroup name
  648.  
  649.     This is the Big Bone SubGroup name used with the bones function in
  650.     Imagine.  By design, BBSG will appear in the DESC chunk of a particular
  651.     bone (usually an axis), and will refer to a subgroup name in a FGR2
  652.     chunk of the parent object of this entire group.  (note: the "Bones"
  653.     functions also assume that a state named DEFAULT appears in the state
  654.     list of the group's parent object, containing at least "shape" and
  655.     "grouping" data) (also, see SBSG chunk below)
  656.  
  657. SBSG - size 18
  658.  
  659.     BYTE sbsg[18];      ; small bone subgroup name
  660.  
  661.     This is the Small Bone SubGroup name used with the bones function in
  662.     Imagine.  By design, SBSG will appear in the DESC chunk of a particular
  663.     bone (usually an axis), and will refer to a subgroup name in a FGR2
  664.     chunk of the parent of this entire group.  (see BBSG chunk above)
  665.  
  666. EFLG - 2 + edge_count
  667.  
  668.     WORD    edge_count;                 ; the number of edges on the object
  669.     UBYTE   edgeFlag[edge_count];       ; array of edge flags for each edge
  670.                                         ;   Bits 0 thru 5 - reserved
  671.                                         ;   Bit 6 - quick edge
  672.                                         ;   Bit 7 - sharp edge
  673.  
  674.     This chunk contains the flag values for all the edges of custom (type
  675.     2 - axis) objects with edges.  These flags currently support the quick
  676.     edge and sharp edge flags.  (Note: Imagine writes this chunk only if
  677.     one or more edges in the object actually has bit 6 or 7 set)
  678.  
  679. DESC notes
  680. ----------
  681.  
  682. Again, most of these fields are optional, and some defaults are supplied.
  683. However, if there is a FACE chunk, there must also be a CLST chunk, an RLST
  684. chunk and a TLST chunk -- all with matching "count" fields.  The SHAP chunk
  685. is not optional.
  686.  
  687. Your best bet in understanding the relationship between chunks (what's
  688. required, and what's not) will probably be through creating objects within
  689. Imagine, saving them out, and then interrogating and comparing the TDDD
  690. files.
  691.  
  692. The order in which the chunks appear is somewhat irrelevant.  Some of
  693. the chunks contain a point count, or something similar, and some of them
  694. (STDT chunks) don't actually contain a count, but are based on a count.
  695. Imagine assigns the appropriate count based on the first occurence of
  696. a chunk whose size would depend on the count, and then enforces consitency
  697. as succeding chunks are processed.
  698.  
  699. For TXT3 and BRS4 (texture and brush) chunks, the order in which the chunks
  700. appear in the file determines the order they are listed in Imagine, and
  701. also the order in which they are applied during rendering.
  702.  
  703. For Imagine's "Quick Stage" mode, the DESC chunks are processed only until
  704. a certain minimum amount of data has been read in, and then it skips to the
  705. end of the DESC chunk.  The "required" fields (in order to skip to the end)
  706. are NAME,POSN,ALGN,SIZE,SHP2 and BBOX.  If state data (i.e. Bones data) is
  707. required from the object for stage animation, then it must appear before
  708. at least one of the "required" fields listed above, or it will be ignored
  709. -- similarly for cycle editor data (ANID chunks), and path (PTH2) data.
  710. For example, Imagine does the following:  1) writes all of the "required"
  711. chunks listed above except for the BBOX chunk, 2) writes ANID chunks (if any),
  712. 3) writes STND chunks (if any), 4) writes a PTH2 chunk (if reqd),
  713. 5) writes a BBOX chunk, and finally, 6) writes the rest of the data.
  714.  
  715. Unfortunately, Impulse does not have the support staff available to answer
  716. technical questions about the information included in this document.
  717. Hopefully, this will be a good starting point.  How far you get with it will,
  718. most likely, be dependent upon hard work and perseverance.
  719.  
  720. Good Luck and Enjoy.
  721.  
  722. PC (80x86 CPU) notes
  723. ====================
  724.  
  725. The IFF file format originated on machines in which the byte order for
  726. LONG (4 byte) and WORD (2 byte) data is "most significant byte first".
  727. This concept has been preserved in the "PC" versions of Imagine.
  728.  
  729. What it means, is that if you are writing code for the "other" type of CPU
  730. (80386 code, for example), you will need to reverse the byte ordering in
  731. (U)LONG, FRACT, and (U)WORD data wherever it appears (e.g. the FRACTs in
  732. a VECTOR structure must be (separatly) byte reversed ... the size field
  733. following a chunk identifier is another good example)
  734.  
  735. IFF file format notes
  736. ---------------------
  737.  
  738. In case you are unfamiliar with the IFF file structure, the TDDD files
  739. have the following (simple, "single FORM") IFF structure:
  740.  
  741. form_ID           4 characters:  'F','O','R','M'
  742. form_size         LONG size   : -- MSB(yte) first
  743. form_type         4 characters:  'T','D','D','D'
  744. chunks:
  745.     chunk_ID      4 characters: e.g. 'O','B','J',' '
  746.     chunk_size    LONG size   : -- byte reversed if appropriate
  747.     chunk_data    'size' bytes:
  748.     chunk_pad     0 or 1 bytes: -- pad to even length if 'size' is odd
  749.  
  750. Note: The "form_size" field appearing after the "form_ID" is the total
  751.       length of the data that FOLLOWS it, INCLUDING the 4-byte (TDDD) id.
  752.       Also the "chunk_size" fields list the size of the data in the
  753.       "chunk_data" blocks that follow.  In other words, the size fields
  754.       when rounded up to an even number, always list the number of bytes
  755.       (after the size field) to skip forward in the file if, based on the
  756.       ID field preceding the size, the reader can not or does not wish to
  757.       interpret the data ... so, in particular, the sizes that appear DO NOT
  758.       include the length of the ID and size fields themselves, and the
  759.       'form_size' DOES include 4 bytes for the 'form_type' field that
  760.       follows it.
  761.       
  762. Imagine uses "extended sub-chunks" -- where for some chunk types, the
  763. data actually consists of a series of smaller chunks, in the same IFF
  764. form: ID/Size/Data/pad_byte_if_neccesary.  In fact, the only "true" IFF
  765. chunk that imagine recognizes is the 'OBJ ' chunk -- which contains the
  766. complete data for a single heirarchy (group) of objects.  Things are as
  767. they are, mainly for historical reasons ... once upon a time, TDDD files
  768. were also used to hold all the data for a single frame in an animation,
  769. and several 'OBJ ' chunks could appear, as well as more chunks giving
  770. data about the camera position, etc.  Now, when Imagine writes a TDDD
  771. file, it contains only a single 'OBJ ' chunk.  Imagine will still process
  772. a file containing multiple 'OBJ ' chunks, but in all cases, except when
  773. it loads a file into its "Detail Editor", it ignores all but the first
  774. object heirarchy.
  775.  
  776.