G3dSortandDisplay.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, July 17, 1989 1:44:03 pm PDT
DIRECTORY Imager, G3dRender;
Definitions
Context: TYPE ~ G3dRender.Context;
ContextProc: TYPE ~ G3dRender.ContextProc;
Triple: TYPE ~ G3dRender.Triple;
Patch: TYPE ~ G3dRender.Patch;
PatchProc: TYPE ~ G3dRender.PatchProc;
Shape: TYPE ~ G3dRender.Shape;
ShapeProc: TYPE ~ G3dRender.ShapeProc;
ShapeSequence: TYPE ~ G3dRender.ShapeSequence;
FacingDir:
TYPE ~ G3dRender.FacingDir;
SortRecord:
TYPE ~
RECORD [
patch: REF Patch, -- ref to patch description
next, prev: INT, -- forward and backward links in bucket chain
dir: FacingDir -- patch backfacing?
];
SortSequence: TYPE ~ REF SortSequenceRep;
SortSequenceRep: TYPE ~ RECORD [SEQUENCE length: CARDINAL OF REF SortRecord];
LORA: TYPE ~ LIST OF REF ANY;
Procedures for Updating Context
ValidateContext:
PROC [context:
Context];
Updates all aspects of context (seen individually below), incorporates changes since last call.
ValidateDisplay:
PROC [context:
Context];
Updates display to react to changes to viewer or initialize new display.
ValidateView:
PROC [context:
Context];
Makes new matrices for initialization or changed viewing parameters, etc.
ValidateShape: ShapeProc;
Check that position and other info up to date. Calls type-specific routine such as following.
Returns FALSE if clipped out or otherwise not displayable.
ValidatePolyhedron: ShapeProc;
Builds new matrices, color values, etc. reflecting changes or for initialization.
DummyValidate: ShapeProc;
SetEyeSpace:
PROC [context:
Context];
Builds new eyespace matrix.
WindowFromViewPort:
PROC [context:
Context]
RETURNS [
REF Imager.Rectangle];
Fits window to shape of viewport.
Procedures for Sorting and Display
LoadPrioritySequence:
PROC [context:
Context, sortOrder:
LORA ←
NIL]
RETURNS [LORA, CARDINAL];
This builds a priority-ordered sequence of patch references, splitting polygons where needed.
LoadDepthSequence:
PROC [context:
Context, sortOrder:
LORA ←
NIL]
RETURNS [LORA, CARDINAL];
This builds a depth-ordered sequence of patch references.
DoBackToFront:
PROC [context:
Context, sortInfo:
LORA, action:
PROC [
REF Patch]];
Does action for each patch in sorted sequence running through sequence backward.
DoFrontToBack:
PROC [context:
Context, sortInfo:
LORA, action:
PROC [
REF Patch]];
Does action for each patch in order in sorted sequence.
DoForPatches:
PROC [
context: Context,
set: ShapeSequence,
patchAction: PROC [REF Patch],
shapeAction: PROC [Shape]];
Does action for each patch in order encountered in context.
CombineBoxes:
PROC [context: Context];
finds bounding box for all object's bounding boxes in scene (for speedups in matting).
ShowObjects:
PROC [context: Context, frontToBack:
BOOL ←
FALSE];
Displays entire context.
OutputPolygon: PatchProc;
RopeDisplay: PatchProc;
Displays a single polygon, handling differing rendering modes, backfacing cull, clipping.
Frame Generation and Animation
MakeFrame: ContextProc;
Makes new image from context, clears frame first, adds background, etc.
ShowShapes: ContextProc;
Makes image without clearing frame, for compositing contexts, etc.