
                   Quad Texturing Mode in PowerAnimator
                   ------------------------------------

Last revision of Document: July 9, 1996.

Overview
--------

This document details the "Quad Texturing" mode for polygons in Alias|Wavefront
PowerAnimator. This is a special mode that provides support for per polygon
textures, where a rectangular texture swatch maps to the corners or vertices of
a quad polygon. When a polygon is in this mode it's actual vertex texture
coordinates are ignored.

This mode is supported by the renderer and toggle shade, as well as the
OpenModel/OpenAlias API.

The components required to set up "Quad Texturing" mode polygons are:

    1. A file texture Shader containing a special "Texture Group" (or TexGrp)
       image.

    2. The above shader applied to a polygon or polygons.

    3. Setting the 'Quad Texturing Flag' ON for those polygons, using
       the GamePoly, or TagPolys plugins.

    4. Assigning 'Quad Texture Index' values to those polygons, using
       the GamePoly, or TagPolys plugins. These index values determine
       which "Texture Tile" (or "Texture Swatch") in the Texture Group
       is assigned to a polygon.


The Texture Group Image
-----------------------

The Texture Group (TexGrp) image is a file made up of a number of texture tiles
or texture swatches, each having common pixel dimensions (e.g. all of them
being 32 by 32, or all 64 by 16, or 24 by 48, etc). It is NOT required that
the source texture tiles be of common pixel dimensions but it is very much
RECOMMENDED that you group textures this way. This method of grouping makes
processing easier when converting these kinds of textures to a game platform,
as well as keeping things organized. Each of these TexGrp images is exactly
8 texture tiles by 8 texture tiles, and so can contain up to 64 texture tiles.

Example of Building a TexGrp image ...

1. Create a directory to store the texture tile image files for the TexGrp
   image you are building. For this example create a directory called TG_32x32
   in your home directory.

2. Copy all the texture tile image files into $HOME/TG_32x32 and ensure they
   are all in image file formats supported by PowerAnimator. For this example
   make sure that the textures are all 32 by 32 in resolution.

3. Use the 'makeTexGrp' utility in the $GAMES_LOCATION/bin directory
   to build your TexGrp image from the textures in the $HOME/TG_32x32
   directory.

   NOTE: to use 'makeTexGrp' on the command line from any directory do the
         following ...

         a. edit your .cshrc file and add $GAMES_LOCATION/bin to
            your path setup.

         b. logout then login again. This ensures that all UNIX shells will
            have that directory in their search paths.

         c. now you can use makeTexGrp from any location in your directory
            tree ...

   Useage for 'makeTexGrp':

      makeTexGrp <xres> <yres> <outprefix> <srcpath> [ pix | sgi ]

      where:
 
        <xres> ..... X resolution of each tile
 
        <yres> ..... Y resolution of each tile
 
        <outprefix> .. output image file prefix - this will be appended
                       with the x and y res input and the .pix extension
                       (for Alias pix file format)
 
        sgi ........ If found as the fifth param then an sgi image file
                     will be generated & and the .rgb extension used
                     instead of .pix ... otherwise any other tag found
                     as the fifth param (or if none found) the image
                     generated will be an Alias pix file.

   ... for this example enter the following at the UNIX command line:

       makeTexGrp 32 32 $HOME/mytest $HOME/TG_32x32 sgi

   ... the utility will process the images in the TG_32x32 directory and create
   a single tiled image of those source files with each tile being 32 by 32
   in resolution (the total TexGrp image being 8 x 32 = 256 by 8 x 32 = 256).
   If less than 64 source textures are found the rest of the tile locations
   in the 8 tile by 8 tile TexGrp is filled in with black. If more than 64
   textures are found then only the first 64 found in the TG_32x32 directory
   will be processed and put into the TexGrp image.

   ... for the above example the output file is:

       $HOME/mytest_x32_y32.rgb

   Creating the image in SGI rgb format (use 'sgi' as the 5th param) allows
   you to read it into most image editing utilities found on the SGI.

   If either of the specified <xres> or <yres> parameters is less than 32
   pixels then the resolution is increased in order to provide a minimum
   resolution for viewing in PowerAnimator (there are problems if low pixel
   resolution textures are not oversampled) ... the output file is still
   appended with the original x and y resolutions specified. This oversampling
   should not create any problems especially if you specify resolutions in
   multiples of 8.

   Source textures are tiled starting at the top row, going left to right,
   and ending at the rightmost tile location on the bottom row. Below is a
   diagram of the order of tiling when building a TexGrp:

         +----+----+----+----+----+----+----+----+
         | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 9  | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+
         | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |
         |    |    |    |    |    |    |    |    |
         +----+----+----+----+----+----+----+----+


   The final TexGrp image generated represents a collection or group of
   texture tiles (or swatches) where each tile can represent a per polygon
   texture in a game engine.

   For our example, copy the mytest_x32_y32.rgb image file to your:

       $ALIAS_WORKENV/user_data/$ALIAS_PROJECT/pix/

   directory.


Setting up Quad Texturing in PowerAnimator
------------------------------------------

Once you have some TexGrp images to work with for Quad Texturing you can start
up PowerAnimator and set shaders and polygons up for this special mode ...

1. Launch PowerAnimator.

2. Create or load in some polygonal geometry (say a cube).

3. Open the multi-lister to edit shaders.

4. Create a new shader.

5. Double click on the new shader to edit.

6. Click on the 'map' widget on the Color parameter in the 'Common Shader
   Parameters' section of the shader edit window.

7. Click on 'file' in the 'Surface' sub-section of the Texture Procedures
   section.

8. In the 'File Texture Paramaters' section enter a TexGrp image file name,
   with the full path to it, or click on 'Browse' to search for and select
   one. Continuing with the above example use the 'Browse' then 'Show List'
   buttons to open the File Browser. The browser should put you in the pix
   directory that you copied the mytest_x32_y32.rgb image into.

9. Double click on the mytest_x32_y32.rgb name or icon to select it.

10. In the same 'File Texture Parameters' section set the 'Filter' parameter
    to 'OFF'. Otherwise when you try to convert your data some pixel values
    may get some sort of blending/anti-aliasing artifacts that you do not
    want in your game.

11. Also in the 'Blur' section set both the Blurmult and the Bluroffset right
    down to 0.0000.

12. IMPORTANT NOTE: When using a TexGrp image as a file texture for Quad
                    Texturing polygons you must make sure that all of the
    'Surface Placement' and 'Label Mapping' parameters are at their initial
    or default values (on a newly created shader the parameters are at their
    default values - so you just have to make sure that you don't change
    them). Otherwise the Quad Texturing will not map correctly and things
    may end up looking pretty messed up.

    To verify that these are at their default values here is a list of the
    parameters and what values they should have for Quad Texturing mode:

        'Surface Placement'
            Rotate        0.000
            Urepeat       1.000
            Vrepeat       1.000
            Uoffset       0.000
            Voffset       0.000
            Mirror        OFF
            Stagger       OFF
            Woldspace     OFF
            Chord Length  OFF

        'Lable Mapping'
            Ucoverage     1.000
            Vcoverage     1.000
            Utranslate    0.000
            Vtranslate    0.000
            Uwrap         ON
            Vwrap         ON

13. Double click on this new shader again and edit the Shader Name at the
    top of the window. You can do this by double clicking in the text box
    containing the shader name and editing.

    To help maintain a reference to how the TexGrp image was organized (i.e.
    by texture resolutions) use the following convention to prefix the
    shader's name:

        x<xres>y<yres>#MyShader

    For our example the shader name would become:

        x32y32#MyShader

    NOTE: this encoding is used by some of the games converters available
          from Alias|Wavefront. The '#' mark is used also by some converters
          as an encoding terminator - everthing after it will be taken as
          just a name (no more encoding).

          Using this kind of encoding in the shader name also keeps the tile
          resolution for the TexGrp visible when working in PowerAnimator.

14. Select some polygons - do this by making all of the vertices of the
    polygons you want to select 'active' (Pick->CV or PolygonEdit->PickVertex)
    or by picking entire polysets of polygons.

15. Assign your new shader to these polygons.

16. Double-click on the TagPolys plugin. Set the following fields OFF (i.e.
    click to remove check in tick-box):

          Updt User1 field
          Updt User2 field

          Updt H flip
          Updt V flip
          Updt Rotation

    Make sure that the following fields are ON (i.e. click to put check in
    tick-box):

          Updt Quad Tex Flag
          Updt X,Y QT Select

          Quad Tex Flag

    Set both the 'QT select X' and the 'QT select Y' options to zero.

    Then click on 'Go'.

    This will set the Quad Texturing Flag ON for all selected ('active')
    polygons, as well as set the Quad Texturing X tile index and Y tile index
    each to zero (on those polygons).

17. Click once in the perspective window.

18. Select the 'Tgl Shade' option box on the 'Display' menu (off of main menu).

19. In the Toggle Shade Options option box select Windows: Current, Geometry:
    All, Interruptible ON (check in tickbox), and Fast Options OFF (no check
    in tick box). Then click on 'Go'. This may take a moment as it builds
    textures for display.

20. Now in shaded mode you will see that the bottom left tile of your TexGrp
    has been assigned to each of your selected polygons. NOTE: if your TexGrp
    image did not have enough texture tiles to fill the group then all polygons
    may be rendered black.

21. Click on the GamePoly plugin icon. Then click on one of the polygons that
    you had set to Quad Texturing mode. It highlights and it's normal is
    displayed. Also a Polygon edit info window comes up. This window contains
    fields pertinent to the Quad Texturing mode as well as 2 User tag fields
    that can be used for other data (some converters look for specifically
    encoded data in the user tag fields).

    You will see that the Quad Texturing flag is ON, and that Tile X is 0 and
    that Tile Y is 0.

22. Click on 'SHOW PALETTE' in the polygon edit window. Another window pops up
    showing the mytest_x32_y32.rgb image that you built and assigned as a file
    texture to the x32y32#MyShader shader you created. The texture tiles are
    visually separated by red grid lines to more easily identify individual
    texture tiles.

23. By clicking on various tiles in the 'SHOW PALETTE' window you can re-
    assign a new texture tile to the polygon you are editing. As you click
    on a new tile position the polygon edit window updates it's Tile X and
    Tile Y values and your shaded model should reflect the change as well.

    IMPORTANT NOTE:

    You will notice that the Tile X and Tile Y index numbering is a little
    unusual (for various reasons it was unavoidable). Tile X index numbering
    goes from 0 (leftmost column) to 7 (rightmost column) and the Tile Y index
    numbering goes from 0 (bottom row) to 7 (top row).

                           Tile X index

                0    1    2    3    4    5    6    7
             +----+----+----+----+----+----+----+----+
          7  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
          6  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
          5  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
   Tile   4  |    |    |    |    |    |    |    |    |
    Y        |    |    |    |    |    |    |    |    |
  index      +----+----+----+----+----+----+----+----+
          3  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
          2  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
          1  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+
          0  |    |    |    |    |    |    |    |    |
             |    |    |    |    |    |    |    |    |
             +----+----+----+----+----+----+----+----+


24. You can also adjust the Quad Texture rotation and flips on the polygon.
    The rotations go Counter Clock-wise. These changes should update and be
    reflected in your shaded model.



Assigning Quad Texture Parameters to Multiple Polygons
------------------------------------------------------

In many situations you will want to assign Quad Texture index values across
multiple polygons. In some games converters multiple polygons in QT mode that
are assigned the same QT tile, i.e. the same X Tile index and same Y Tile
index, from the same TexGrp Shader will generate only one texture on output.
All of these polygons will then reference only that single texture.

Use the TagPolys plugin to assign Quad Texture parameter values across
multiple polygons. When assigning Tile X and Y index values you can use, in
conjunction with TagPolys, the ShowTexGrp plugin to display a reference image
of the TexGrp (with this ref image up you still must assign the numeric values
for Tile X and Tile Y params - clicking on a ref image will close it's window).

For more info on how to use these special plugins see the README_GameTools
file in your $GAMES_LOCATION/plugins/files directory.

[END]
