home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / tddd / spec / tdddb.txt next >
Encoding:
Text File  |  1994-06-17  |  22.6 KB  |  543 lines

  1. ED. NOTE:  This is not a formal specification, but an informal
  2. description of the format.
  3.  
  4.  
  5.  
  6.                           FORM TDDD
  7.                           ---------
  8.  
  9.     FORM TDDD is used by Impulse's Turbo Silver 3.0 for 3D rendering
  10.     data.  TDDD stands for "3D data description".  The files contain
  11.     object and (optionally) observer data.
  12.  
  13.     Currently, in "standard IFF" terms, a FORM TDDD has only two chunk
  14.     types:  an INFO chunk describing observer data;  and an OBJ chunk
  15.     describing an object heirarchy.  The INFO chunk appears in "cell"
  16.     files, and the OBJ chunk appears in "cell" files and "object" files.
  17.     The FORM has an (optional) INFO chunk followed by some number of
  18.     OBJ chunks.  (Note:  OBJ is followed by a space -- ckID = "OBJ ")
  19.  
  20.     The INFO and OBJ chunks, in turn, are made up of smaller chunks with
  21.     the standard IFF structure:  <ID> <data-size> <data>.
  22.  
  23.     The INFO "sub-chunks" are relatively straightforward to interpret.
  24.  
  25.     The OBJ "sub-chunks" support object heirarchies, and are slightly
  26.     more difficult to interpret.  Currently, there are 3 types of OBJ
  27.     sub-chunks:  an EXTR chunk, describing an "external" object in a
  28.     seperate file; a DESC chunk, describing one node of a heirarchy;
  29.     and a TOBJ chunk marking the end of a heirarchy chain.  For each
  30.     DESC chunk, there must be a corresponding TOBJ chunk.  And an
  31.     EXTR chunk is equivalent to a DESC/TOBJ pair.
  32.  
  33.     In Turbo Silver, the structure of the object heirarchy is as
  34.     follows.  There is a head object, and its (sexist) brothers.
  35.     Each brother may have child objects.  The children may have
  36.     grandchildren, and so on. The brother nodes are kept in a
  37.     doubly linked list, and each node has a (possibly NULL)
  38.     pointer to a doubly linked "child" list. The children point
  39.     to the "grandchildren" lists, and so on.  (In addition, each
  40.     node has a "back" pointer to its parent).
  41.  
  42.     Each of the "head" brothers is written in a seperate OBJ chunk,
  43.     along with all its descendants.  The descendant heirarchy is
  44.     supported as follows:
  45.  
  46.         for each node of a doubly linked list,
  47.  
  48.         1)  A DESC chunk is written, describing its object.
  49.         2)  If it has children, steps 1) to 3) are performed
  50.             for each child.
  51.         3)  A TOBJ chunk is written, marking the end of the children.
  52.  
  53.     For "external" objects, steps 1) to 3) are not performed, but
  54.     an EXTR chunk is written instead.  (This means that an external
  55.     object cannot have children unless they are stored in the same
  56.     "external" file).
  57.  
  58.     The TOBJ sub-chunks have zero size -- and no data.  The DESC
  59.     and EXTR sub-chunks are made up of "sub-sub-chunks", again,
  60.     with the standard IFF structure:  <ID> <data-size> <data>.
  61.  
  62.     Reader software WILL FOLLOW the standard IFF procedure of
  63.     skipping over any un-recognized chunks -- and "sub-chunks"
  64.     or "sub-sub-chunks". The <data-size> field indicates how many
  65.     bytes to skip.  In addition it WILL OBSERVE the IFF rule that
  66.     an odd <data-size> may appear, in which case the corredponding
  67.     <data> field will be padded at the end with one extra byte to
  68.     give it an even size.
  69.  
  70.  
  71.     Now, on with the details.
  72.  
  73.     First, there are several numerical fields appearing in the data,
  74.     describing object positions, rotation angles, scaling factors, etc.
  75.     They are stored as "32-bit fractional" numbers, such that the true
  76.     number is the 32-bit number divided by 65536.  So as an example,
  77.     the number 3.14159 is stored as (hexadecimal) $0003243F.  This
  78.     allows the data to be independant of any particular floating point
  79.     format. And it (actually) is the internal format used in the
  80.     "integer" version of Turbo Silver.  Numbers stored in this format
  81.     are called as "FRACT"s below.
  82.  
  83.     Second, there are several color (or RGB) fields in the data.
  84.     They are always stored as three UBYTEs representing the red,
  85.     green and blue components of the color.  Red is always first,
  86.     followed by green, and then blue.  For some of the data chunks,
  87.     Turbo Silver reads the color field into the 24 LSB's of a
  88.     LONGword.  In such cases, the 3 RGB bytes are preceded by a
  89.     zero byte in the file.
  90.  
  91.  
  92.     The following "typedef"s are used below:
  93.  
  94.     typedef LONG    FRACT;          /* 4 bytes */
  95.     typedef UBYTE   COLOR[3];       /* 3 bytes */
  96.  
  97.     typedef struct  vectors {
  98.         FRACT   X;                  /* 4 bytes */
  99.         FRACT   Y;                  /* 4 bytes */
  100.         FRACT   Z;                  /* 4 bytes */
  101.     } VECTOR;                   /* 12 bytes total */
  102.  
  103.     typedef struct  matrices {
  104.         VECTOR  I;                  /* 12 bytes */
  105.         VECTOR  J;                  /* 12 bytes */
  106.         VECTOR  K;                  /* 12 bytes */
  107.     } MATRIX;                   /* 36 bytes total */
  108.  
  109.  
  110.     The following structure is used in generating animated cells
  111.     from a single cell.  It can be attached to an object or to the
  112.     camera.  It is also used for Turbo Silver's "extrude along a
  113.     path" feature.
  114.  
  115.     typedef struct  story   {
  116.         UBYTE   Path[18];           /*  18 bytes        */
  117.         VECTOR  Translate;          /*  12 bytes        */
  118.         VECTOR  Rotate;             /*  12 bytes        */
  119.         VECTOR  Scale;              /*  12 bytes        */
  120.         UWORD   info;               /*   2 bytes        */
  121.     } STORY;                    /*  56 bytes total  */
  122.  
  123.     The Path[] name refers to a named object in the cell data.
  124.     The path object should be a sequence of points connected
  125.     with edges.  The object moves from the first point of the
  126.     first edge, to the last point of the last edge.  The edge
  127.     ordering is important.  The path is interpolated so that
  128.     the object always moves an equal distance in each frame of
  129.     the animation.  If there is no path the Path[] field should
  130.     be set to zeros.
  131.     The Translate vector is not currently used.
  132.     The Rotate "vector" specifies rotation angles about the
  133.     X, Y, and Z axes.
  134.     The Scale vector specfies X,Y, and Z scale factors.
  135.     The "info" word is a bunch of bit flags:
  136.  
  137.         ABS_TRA     0x0001      - translate in world coorinates (not used)
  138.         ABS_ROT     0x0002      - rotation in world coorinates
  139.         ABS_SCL     0x0004      - scaling in world coorinates
  140.         LOC_TRA     0x0010      - translate in local coorinates (not used)
  141.         LOC_ROT     0x0020      - rotation in local coorinates
  142.         LOC_SCL     0x0040      - scaling in local coorinates
  143.         X_ALIGN     0x0100      - (not used)
  144.         Y_ALIGN     0x0200      - align Y axis to path's direction
  145.         Z_ALIGN     0x0400      - (not used)
  146.         FOLLOW_ME   0x1000      - children follow parent on path
  147.  
  148.  
  149.     INFO sub-chunks
  150.     ---------------
  151.  
  152.     BRSH - size 82
  153.  
  154.         WORD    Number;                 ; Brush number (between 0 and 7)
  155.         CHAR    Filename[80];           ; IFF ILBM filename
  156.  
  157.         There may be more than one of these.
  158.  
  159.     STNC - size 82
  160.  
  161.         Same format as BRSH chunk.
  162.  
  163.     TXTR - size 82
  164.  
  165.         Same format as BRSH chunk.  The Filename field is the name of
  166.         a code module that can be loaded with LoadSeg().
  167.  
  168.     OBSV - size 28
  169.  
  170.         VECTOR  Camera;                 ; Camera position
  171.         VECTOR  Rotate;                 ; Camera rotation angles
  172.         FRACT   Focal;                  ; Camera focal length
  173.  
  174.         This tells where the camera is, how it is aimed, and its
  175.         focal length.  The rotation angles are in degrees, and specify
  176.         rotations around the X, Y, and Z axes.  The camera looks down
  177.         its own Y axis, with the top of the picture in the direction of
  178.         the Z axis.  If the rotation angles are all zero, its axes
  179.         are aligned with the world coordinate axes.  The rotations are
  180.         performed in the order ZXY about the camera axes.  A positive
  181.         angle rotates Y toward Z, Z toward X, and X toward Y for
  182.         rotations about the X, Y, and Z axes respectively.  To
  183.         understand the focal length, imagine a 320 x 200 pixel
  184.         rectangle perpendicular to, and centered on the camera's
  185.         Y axis.  Any objects in the infinite rectangular cone defined
  186.         by the camera position and the 4 corners of the rectangle will
  187.         appear in the picture.
  188.  
  189.     OTRK - size 18
  190.  
  191.         BYTE    Trackname[18];
  192.  
  193.         This chunk specifies the name of an object that the camera
  194.         is "tracked" to.  If the name is NULL, the camera doesn't
  195.         track.  Otherwise, if the object is moved inside Turbo Silver,
  196.         the camera will follow it.
  197.  
  198.     OSTR - size 56
  199.  
  200.         STORY   CStory;         ; a STORY structure for the camera
  201.  
  202.         The story structure is defined above.
  203.  
  204.     FADE - size 12
  205.  
  206.         FRACT   FadeAt;         ; distance to start fade
  207.         FRACT   FadeBy;         ; distance of total fade
  208.         BYTE    pad;            ; pad byte - must be zero
  209.         COLOR   FadeTo;         ; RGB color to fade to
  210.  
  211.     SKYC - size 8
  212.  
  213.         BYTE    pad;            ; pad byte - must be zero
  214.         COLOR   Horizon;        ; horizon color
  215.         BYTE    pad;            ; pad byte - must be zero
  216.         COLOR   Zenith;         ; zenith color
  217.  
  218.     AMBI - size 4
  219.  
  220.         BYTE    pad;            ; pad byte - must be zero
  221.         COLOR   Ambient;        ; abmient light color
  222.  
  223.     GLB0 - size 8
  224.  
  225.         BYTE    Props[8];       ; an array of 8 "global properties" used
  226.                                 ; by Turbo Silver.
  227.  
  228.         Props[0] - GLB_EDGING       ; edge level (globals requester)
  229.         Props[1] - GLB_PERTURB      ; perturbance (globals requester)
  230.         Props[2] - GLB_SKY_BLEND    ; sky blending factor (0-255)
  231.         Props[3] - GLB_LENS         ; lens type (see below)
  232.         Props[4] - GLB_FADE         ; flag - Sharp/Fuzzy focus (globals)
  233.         Props[5] - GLB_SIZE         ; "apparant size" (see below)
  234.         Props[6] - GLB_RESOLVE      ; resolve depth (globals requester)
  235.         Props[7] - GLB_EXTRA        ; flag - genlock sky on/off
  236.  
  237.         The edging and perturbance values control the heuristics in
  238.         ray tracing.  The sky blending factor is zero for no blending,
  239.         and 255 for full blending.  The lens type is a number from 0
  240.         4, corresponding to the boxes in the "camera" requester, and
  241.         correspond to 0) Manual, 1) Wide angle, 2) Normal, 3) Telephoto,
  242.         and 4) Custom.  It is used in setting the camera's focal length
  243.         if the camera is tracked to an object.  The Sharp/Fuzzy flag
  244.         turns the "fade" feature on and off - non-zero means on.
  245.         The "apparant size" parameter is 100 times the "custom size"
  246.         parameter in the camera requester.  And is used to set the
  247.         focal length for a custom lens.  The "resolve depth" controls
  248.         the number of rays the ray tracer will shoot for a single pixel.
  249.         Each reflective/refractive ray increments the depth counter, and
  250.         the count is never allowed to reach the "resolve depth".  If both
  251.         a reflective and a refractive ray are traced, each ray gets its
  252.         own version of the count - so theoretically, a resolve depth of
  253.         4 could allow much more than 4 rays to be traced.  The "genlock
  254.         sky" flag controls whether the sky will be colored, or set to
  255.         the genlock color (color 0 - black) in the final picture.
  256.  
  257.  
  258.     All of the INFO sub-chunks are optional, as is the INFO chunk.
  259.     Default values are supplied if the chunks are not present.  The
  260.     defaults are:  no brushes, stencils, or textures defined; no story
  261.     for the camera; horizon and zenith and ambient light colors set
  262.     to black; fade color set to (80,80,80);  un-rotated, un-tracked
  263.     camera at (-100, -100, 100); and global properties array set to
  264.     [30, 0, 0, 0, 0, 100, 8, 0].
  265.  
  266.  
  267.     DESC sub-sub-chunks
  268.     -------------------
  269.  
  270.     NAME - size 18
  271.  
  272.         BYTE    Name[18];       ; a name for the object.
  273.  
  274.         Used for camera tracking, specifying story paths, etc.
  275.  
  276.     SHAP - size 4
  277.  
  278.         WORD    Shape;          ; number indicating object type
  279.         WORD    Lamp;           ; number indicating lamp type
  280.  
  281.         Lamp numbers are:
  282.  
  283.             0 - not a lamp
  284.             1 - like sunlight
  285.             2 - like a lamp - intensity falls off with distance.
  286.  
  287.         Shape numbers are:
  288.  
  289.             0 - Sphere
  290.             1 - Stencil
  291.             2 - Axis            ; custom objects with points/triangles
  292.             3 - Facets          ; illegal - for internal use only
  293.             4 - Surface
  294.             5 - Ground
  295.  
  296.         Spheres have thier radius set by the X size parameter.
  297.         Stencils and surfaces are plane-parallelograms, with one
  298.         point at the object's position vector; one side lying along
  299.         the object's X axis with a length set by the X size; and
  300.         another side starting from the position vector and going
  301.         "Y size" units in the Y direction and "Z size" units in
  302.         the X direction.  A ground object is an infinte plane
  303.         perpendicular to the world Z axis.  Its Z coordinate sets
  304.         its height, and the X and Y coordinates are only relevant
  305.         to the position of the "hot point" used in selecting the
  306.         object in the editor.  Custom objects have points, edges
  307.         and triangles associated with them.  The size fields are
  308.         relevant only for drawing the object axes in the editor.
  309.         Shape number 3 is used internally for triangles of custom
  310.         objects, and should never appear in a data file.
  311.  
  312.     POSI - size 12
  313.  
  314.         VECTOR  Position;       ; the object's position.
  315.  
  316.         Legal coordinates are in the range -32768 to 32767 and 65535/65536.
  317.         Currently, the ray-tracer only sees objects in the -1024 to 1024
  318.         range.  Light sources, and the camera may be placed outside that
  319.         range, however.
  320.  
  321.     AXIS - size 36
  322.  
  323.         VECTOR  XAxis;
  324.         VECTOR  YAxis;
  325.         VECTOR  ZAxis;
  326.  
  327.         These are direction vectors for the object coordinate system.
  328.         They must be "orthogonal unit vectors" - i.e. the sum of the
  329.         squares of the vevtor components must equal one (or close to it),
  330.         and the vectors must be perpendicular.
  331.  
  332.     SIZE - size 12
  333.  
  334.         VECTOR  Size;
  335.  
  336.         See SHAP chunk above.  The sizes are used in a variety of ways
  337.         depending on the object shape.  For custom objects, they are
  338.         the lengths of the coordinate axes drawn in the editor.  If the
  339.         object has its "Quickdraw" flag set, the axes lengths are also
  340.         used to set the size of a rectangular solid that is drawn rather
  341.         than drawing all the points and edges.
  342.  
  343.     PNTS - size 2 + 12 * point count
  344.  
  345.         UWORD   PCount;         ; point count
  346.         VECTOR  Points[];       ; points
  347.  
  348.         This chunk has all the points for custom objects.  The are
  349.         refered to by thier position in the array.
  350.  
  351.     EDGE - size 4 + 4 * edge cout
  352.  
  353.         UWORD   ECount;         ; edge count
  354.         UWORD   Edges[][2];     ; edges
  355.  
  356.         This chunk contins the edge list for custom objects.
  357.         The Edges[][2] array is pairs of point numbers that
  358.         are connected by the edges.  Edges are refered to by thier
  359.         position in the Edges[] array.
  360.  
  361.     FACE - size 2 + 6 * face count
  362.  
  363.         UWORD   TCount;         ; face count
  364.         UWORD   Connects[][3];  ; faces
  365.  
  366.         This chunk contains the triangle (face) list for custom objects.
  367.         The Connects[][3] array is triples of edge numbers that are
  368.         connected by triangles.
  369.  
  370.     COLR - size 4
  371.     REFL - size 4
  372.     TRAN - size 4
  373.  
  374.         BYTE    pad;        ; pad byte - must be zero
  375.         COLOR   col;        ; RGB color
  376.  
  377.         These are the main object RGB color, and reflection and
  378.         transmission coefficients.
  379.  
  380.     CLST - size 2 + 3 * count
  381.     RLST - size 2 + 3 * count
  382.     TLST - size 2 + 3 * count
  383.  
  384.         UWORD   count;      ; count of colors
  385.         COLOR   colors[];   ; colors
  386.  
  387.         These are the main object color, and reflection and
  388.         transmission coefficients for each face in custom objects.
  389.         The count should match the face count in the FACE chunk.
  390.         The ordering corresponds to the face order.
  391.  
  392.     TPAR - size 64
  393.  
  394.         FRACT   Params[16];     ; texture parameters
  395.  
  396.         This is the list of parameters for texture modules when
  397.         texture mapping is used.
  398.  
  399.     SURF - size 5
  400.  
  401.         BYTE    SProps[5];      ; object properties
  402.  
  403.         This chunk contains object (surface) properties used
  404.         by Turbo Silver.
  405.  
  406.         SProps[0] - PRP_SURFACE     ; surface type
  407.                                     ;   0 - normal
  408.                                     ;   4 - genlock
  409.                                     ;   5 - IFF brush
  410.         SProps[1] - PRP_BRUSH       ; brush number (if IFF mapped)
  411.         SProps[2] - PRP_WRAP            ; IFF brush wrapping type
  412.                                     ;   0 - no wrapping
  413.                                     ;   1 - wrap X
  414.                                     ;   2 - wrap Z
  415.                                     ;   3 - wrap X and Z
  416.         SProps[3] - PRP_STENCIL     ; stencil number for stencil objects
  417.         SProps[4] - PRP_TEXTURE     ; texture number if texture mapped
  418.  
  419.     MTTR - size 2
  420.  
  421.         UBYTE   Type;               ; refraction type (0-4)
  422.         UBYTE   Index;              ; custom index of refraction
  423.  
  424.         This chunk contains refraction data for transparent or
  425.         glossy objects.  If the refraction type is 4, the object
  426.         has a "custom" refractive index stored in the Index field.
  427.         The Index field is 100 * (true index of refraction - 1.00)
  428.         -- so it must be in the range of 1.00 to 3.55.  The
  429.         refraction types is 0-3 specify 0) Air - 1.00, 1) Water - 1.33,
  430.         2) Glass - 1.67 or 3) Crystal 2.00.
  431.  
  432.     SPEC - size 2
  433.  
  434.         UBYTE   Specularity;            ; range of 0-255
  435.         UBYTE   Hardness;               ; specular exponent (0-31)
  436.  
  437.         This chunk contains specular information.  The Specularity
  438.         field is the amount of specular reflection -- 0 is none,
  439.         255 is fully specular.  The "specular exponent" controls
  440.         the "tightness" of the specular spots.  A value of zero
  441.         gives broad specular spots and a value of 31 gives smaller
  442.         spots.
  443.  
  444.     PRP0 - size 6
  445.  
  446.         UBYTE   Props[6];           ; more object properties
  447.  
  448.         This chunk contains object properties that programs other
  449.         than Turbo Silver might support.
  450.  
  451.         Props[0] - PRP_BLEND        ; blending factor (0-255)
  452.         Props[1] - PRP_SMOOTH       ; roughness factor
  453.         Props[2] - PRP_SHADE        ; shading on/off flag
  454.         Props[3] - PRP_PHONG        ; phong shading on/off flag
  455.         Props[4] - PRP_GLOSSY       ; glossy on/off flag
  456.         Props[5] - PRP_QUICK        ; Quickdraw on/off flag
  457.  
  458.         The blending factor controls the amount of dithering used
  459.         on the object - 255 is fully dithered.  
  460.         The roughness factor controls how rough the object should
  461.         appear - 0 is smooth, 255 is max roughness.
  462.         The shading flag is interpreted differently depending on
  463.         whether the object is a light source or not.  For light
  464.         sources, it sets the light to cast shadows or not.  For
  465.         normal objects, if the flag is set, the object is always
  466.         considered as fully lit - i.e. it's color is read directly
  467.         from the object (or IFF brush), and is not affected by light
  468.         sources.
  469.         The phong shading is on by default - a non-zero value turns
  470.         it off.
  471.         The glossy flag sets the object to be glossy or not.  If
  472.         the object is glossy, the "transmit" colors and the index
  473.         of refraction control the amount of "sheen".  The glossy
  474.         feature is meant to simulate something like a wax coating
  475.         on the object with the specified index of refraction. The
  476.         trasmission coefficients control how much light from the
  477.         object makes it through the wax coating.
  478.         The Quickdraw flag, if set, tells the editor not to draw
  479.         all the points and edges for the object, but to draw a
  480.         rectanglular solid centered at the object position, and
  481.         with sizes detemined by the axis lengths.
  482.  
  483.     INTS - size 4
  484.  
  485.         FRACT   Intensity;          ; light intensity
  486.  
  487.         This is the intensity field for light source objects.
  488.         an intensity of 255 for a sun-like light fully lights
  489.         object surfaces which are perpendicular to the direction
  490.         to the light source.  For lamp-like light sources, the
  491.         necessary intensity will depend on the distance to the light.
  492.  
  493.     STRY - size 56
  494.  
  495.         STORY   story;          ; a story structure for the object.
  496.  
  497.         The story structure is described above.
  498.  
  499.  
  500.     Again, most of these fields are optional, and defaults are supplied.
  501.     However, if there is a FACE chunk, there must also be a CLST chunk,
  502.     an RLST chunk and a TLST chunk -- all with matching "count" fields.
  503.     The SHAP chunk is not optional. 
  504.  
  505.     Defaults are:  Colors set to (240,240,240); reflection and
  506.     transmission coefficients set to zero; illegal shape; no story or
  507.     special surface types; position at (0,0,0); axes aligned to the
  508.     world axes; size fields all 32.0; intensity at 300; no name;
  509.     no points/edges or faces; texture parameters set to zero; refraction
  510.     type 0 with index 1.00; specular, hardness and roughness set to zero;
  511.     blending at 255; glossy off; phong shading on; not a light source;
  512.     not brightly lit;
  513.  
  514.  
  515.  
  516.     EXTR sub-sub-chunks
  517.     -------------------
  518.  
  519.     MTRX - size 60
  520.  
  521.         VECTOR  Translate;          ; translation vector
  522.         VECTOR  Scale;              ; X,Y and Z scaling factors
  523.         MATRIX  Rotate;             ; rotation matrix
  524.  
  525.         The translation vector is i world coordinates.
  526.         The scaling factors are with respect to local axes.
  527.         The rotation matrix is with respect to the world axes,
  528.         and it should be a "unit matrix".
  529.         The rotation is such that a rotated axis's X,Y, and Z
  530.         components are the dot products of the MATRIX's I,J,
  531.         and K vectors with the un-rotated axis vector.
  532.  
  533.     LOAD - size 80
  534.  
  535.         BYTE    Filename[80];       ; the name of the external file
  536.  
  537.         This chunk contains the name of an external object file.
  538.         The external file should be a FORM TDDD file.  It may contain
  539.         an any number of objects possibly grouped into heirarchy(ies).
  540.  
  541.     Both of these chunks are required.
  542.  
  543.