G3dMappedAndSolidTexture.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, May 4, 1989 6:58:55 pm PDT
Perlin, August 5, 1985 0:23:18 am PDT
DIRECTORY Atom, G3dRender, Rope;
G3dMappedAndSolidTexture: CEDAR DEFINITIONS
~ BEGIN
Basic Types
PropList:    TYPE ~ Atom.PropList;
LORA:     TYPE ~ LIST OF REF ANY;
Context:    TYPE ~ G3dRender.Context;
Pair:     TYPE ~ G3dRender.Pair;
Patch:     TYPE ~ G3dRender.Patch;
SpotProc:    TYPE ~ G3dRender.SpotProc;
TextureMap:   TYPE ~ G3dRender.TextureMap;
TextureFunction: TYPE ~ G3dRender.TextureFunction;
ROPE:     TYPE ~ Rope.ROPE;
Procedures for Controlling Texture
AddSolidTexture: PROC [context: Context, shapeName: ROPE, name: ATOM];
Allows client to pass name of solid texturing procedure for shape as an ATOM.
AddMappedTexture: PROC [context: Context, shapeName: ROPE, texture: REF TextureMap];
Sets up supplied texture map.
SumAllMappedTextures: PROC [context: Context, shapeName: ROPE];
Converts texture maps to summed area table form for antialiasing.
RemoveAllTexture: PROC [context: Context, shapeName: ROPE];
Deletes all texture references for object.
Support Procedures for setting up texture for tiler
AdjustTexture: PROC [poly: REF Patch, texture: LORA, txtrRange: Pair];
Adjusts mapped texture coordinates to avoid coordinate wraparound.
Procedures for Evaluating Texture at a Spot
GetTxtrAt: SpotProc;
Layers textures from a list to onto a pixel.
Procedures for solid texture calculation
RegisterTextureFunction: PROC [name: ATOM, proc: SpotProc, props: PropList ← NIL];
Registers a procedure for computing on a spot (usually for solid textures).
GetRegisteredTextureFunction: PROC [name: ATOM] RETURNS[txtrFn: TextureFunction];
Returns a previously registered procedure.
Chaos: PROC [x, y, z: REAL] RETURNS [REAL];
A function built on noise, used in some solid texture functions.
Noise: PROC [vx, vy, vz: REAL] RETURNS [REAL];
Perlin's noise function. Fills space with random blobs.
Procedures for Computing Texture Coordinates
ScaleTxtrCoords: PROC [context: Context, shapeName: ROPE, scale, xRatio, yRatio: REAL ← 1.0];
Scale texture coordinates of vertices. xRatio, etc. can be used to set scale assymetrically.
eg. texture.x ← texture.x * scale * xRatio.
Accumulated scale factor is stored on shape shadingProps list ($TextureScale).
SetPatchTextureCoords: PROC [
context: Context,
shapeName: ROPE,
corner0: Pair ← [0.,0.], corner1: Pair ← [0.,1.], corner2: Pair ← [1.,1.], corner3: Pair ← [1.,0.]
];
Sets all quadrilateral patches with the given texture coordinates at the corners, inner control points on Bezier patches are interpolated from the input corner values
MakeTxtrCoordsFromVtxNos: PROC [
context: Context,
shapeName: ROPE,
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 [
context: Context,
shapeName: ROPE,
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: Context,
fileName: ROPE,
type: ATOM ← $Intensity,
factor: REAL ← 1.0]
RETURNS[texture: REF TextureMap];
Reads AIS file and converts it to texture map form.
Factor is for scaling, (height of bump map - default 1, other uses may come).
SumTexture: PROC [texture: REF TextureMap];
Turn texture map into Summed Table form for anti-aliased texture.
END.