TextureMaps.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, October 14, 1986 9:24:41 am PDT
DIRECTORY
Atom     USING [PropList],
ScanConvert   USING [Spot],
ThreeDScenes  USING [Context, ShapeInstance],
Vector2    USING [VEC],
Rope     USING [ROPE];
TextureMaps: CEDAR DEFINITIONS
~ BEGIN
Basic Types
Pair: TYPE ~ Vector2.VEC;           -- [ x, y: REAL];
TextureMap: TYPE ~ RECORD[type: ATOM, pixels: REF ANY, props: Atom.PropList];
type: NIL, $Bump - intensity map, $Color - full color map.
Summed-Area Texture storage
IntSequence: TYPE ~ RECORD[SEQUENCE length: NAT OF INT];
ScanSequence: TYPE ~ RECORD[SEQUENCE length: NAT OF REF IntSequence];
SummedTexture: TYPE ~ RECORD[SEQUENCE length: NAT OF REF ScanSequence];
Procedures for Computing Texture Coordinates
MakeTxtrCoordsFromVtxNos: PROC[ shape: REF ThreeDScenes.ShapeInstance,
             vtcesInRow, numberOfRows: NAT,
         row0col0, rowNcol0, rowNcolM, row0ColM: Pair ];
For objects which are rectangular polygon grids pulled into a surface shape, eg. surfaces of revolution, this maps a texture onto the rectangular grid.
MakeTxtrCoordsFromNormals: PROC[ shape: REF ThreeDScenes.ShapeInstance,
        botLeft: Pair ← [0.0, 0.0], topLeft: Pair ← [0.0, 1.0],
        topRight: Pair ← [1.0, 1.0], botRight: Pair ← [1.0, 0.0],
           sw: Pair ← [180.0, -90.0], nw: Pair ← [180.0, 90.0],
           ne: Pair ← [-180.0, 90.0], se: Pair ← [-180.0, -90.0] ];
This takes the surface normals and maps from spherical coordinates into a rectangular texture. botLeft, topLeft, etc. allow mapping multiple, or skewed, instances of the texture onto the rectangle. longMin, longMax, etc. allow the area affected to be limited to a certain range of sperical coordinates.
Procedures for Reading and Preparing Texture Files
TextureFromAIS: PROC[context: REF ThreeDScenes.Context, fileName: Rope.ROPE,
        type: ATOM ← $Intensity]
      RETURNS[texture: REF TextureMap];
SetTexture: PROC[shape: REF ThreeDScenes.ShapeInstance, texture: REF TextureMap];
SumTexture: PROC[shape: REF ThreeDScenes.ShapeInstance];
Procedures for Evaluating Texture at a Spot
GetTxtrAt: PROC[smpl: ScanConvert.Spot] RETURNS[ScanConvert.Spot];
END.