ThreeDSurfaces.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, October 14, 1986 11:53:26 am PDT
DIRECTORY
Rope     USING [ROPE],
Vector2    USING [VEC],
ScanConvert   USING [RealSequence],
Vector3d    USING [Triple, Quad],
ThreeDBasics  USING [AllOut, ClipState, Context, FacingDir, NoneOut, OutCode, Patch,
        PatchSequence, PtrPatch, PtrPatchSequence, ShapeInstance,
        ShapeSequence, Vertex, VertexInfo, VertexInfoSequence];
ThreeDSurfaces: CEDAR DEFINITIONS
~ BEGIN
Basic Types
Context: TYPE ~ ThreeDBasics.Context;
Pair: TYPE ~ Vector2.VEC;           -- [ x, y: REAL];
Triple: TYPE ~ Vector3d.Triple;       -- [ x, y, z: REAL];
Quad: TYPE ~ Vector3d.Quad;        -- [ x, y, z, w: REAL];
RealSequence: TYPE ~ ScanConvert.RealSequence;
OutCode: TYPE ~ ThreeDBasics.OutCode;
NoneOut: OutCode ~ ThreeDBasics.NoneOut;
AllOut: OutCode ~ ThreeDBasics.AllOut;
Vertex Definitions
Vertex: TYPE ~ ThreeDBasics.Vertex;
VertexInfo: TYPE ~ ThreeDBasics.VertexInfo;
VertexInfoSequence: TYPE ~ ThreeDBasics.VertexInfoSequence;
Patch Definitions
FacingDir: TYPE ~ ThreeDBasics.FacingDir;
Patch: TYPE ~ ThreeDBasics.Patch;
 RECORD[type: ATOMNIL, oneSided: BOOLEANTRUE, nVtces: NAT ← 0,
    clipState: ClipState ← in, props: Atom.PropList ← NIL,
   vtx: SEQUENCE maxLength: NAT OF VertexInfo];
PatchProcs: TYPE ~ RECORD[
expand: PatchExpandProc,
subdivide: PatchExpandProc,
display: PatchDisplayProc,
displayLines: PatchDisplayProc
];
PatchSequence: TYPE ~ ThreeDBasics.PatchSequence;
RECORD [SEQUENCE length: CARDINAL OF REF Patch];
PtrPatch: TYPE ~ ThreeDBasics.PtrPatch;
RECORD[type: ATOMNIL, oneSided: BOOLEANTRUE, nVtces: NAT ← 0,
   clipState: ClipState ← in, props: Atom.PropList ← NIL,
   vtxPtr: SEQUENCE length: NAT OF NAT];
PtrPatchSequence: TYPE ~ ThreeDBasics.PtrPatchSequence;
RECORD[SEQUENCE length: CARDINAL OF REF PtrPatch];
ShapePatch: TYPE ~ RECORD[shape: REF ShapeInstance, patch, next: INT];
SortSequence: TYPE ~ RECORD[SEQUENCE length: CARDINAL OF REF ShapePatch];
Shape Definitions
ClipState: TYPE ~ ThreeDBasics.ClipState;
ShapeInstance: TYPE ~ ThreeDBasics.ShapeInstance;
Utility Procedures
GetPatch: PROC[size: NAT] RETURNS[REF Patch];
ReleasePatch: PROC[p: REF Patch];
ShapePatchToPatch: PROC[ context: REF Context, sPatch: REF ThreeDSurfaces.ShapePatch ]
       RETURNS
[patch: REF Patch];
Procedures for Reading and Writing Shape Descriptions
ReadShape: PROC[shape: REF ShapeInstance, fileName: Rope.ROPE]; -- full format shape read
CloneShape: PROC[newshape, oldShape: REF ShapeInstance]; -- copy shape data
WriteShape: PROC[shape: REF ShapeInstance, fileName: Rope.ROPE, -- full format shape write
      xyz: BOOLTRUE, normal, color, trans, texture, polyClr: BOOLFALSE];
Procedures for Transformations and Clipping
ClipPoly: PROC[ context: REF Context, poly: REF Patch] RETURNS [REF Patch];
GetPatchClipState: PROC[ patch: REF Patch];
Procedures for expansion of/to polygons
PatchExpandProc: TYPE ~ PROC[ shape: REF ShapeInstance, patch: REF PtrPatch,
          limitType: ATOM, limit: REAL]
        RETURNS[ v: REF VertexInfoSequence, p: REF PtrPatchSequence ];
Expands a patch in one step to displayable polygons
PatchDisplayProc: TYPE ~ PROC[ context: REF Context, patch: REF Patch,
          limitType: ATOM, limit: REAL,
          
action: PROC[context: REF Context, patch: REF Patch] ];
Expands and displays the patch in whatever way it chooses, using the supplied action proc
ShapeExpand: PROC[ context: REF Context, shape: REF ShapeInstance,
       limitType: ATOMNIL, limit: REAL ← 0.0]
     RETURNS [REF ShapeInstance];
Expands a whole shape, calling procedures supplied by the surface type
ShapeSubdivide: PROC[ context: REF Context, shape: REF ShapeInstance,
        limitType: ATOMNIL, limit: REAL ← 0.0]
     RETURNS [REF ShapeInstance];
Subdivide a whole shape once, calling procedures supplied by the surface type
RegisterSurfaceType: PROC[ context: REF Context, type: ATOM, procs: REF PatchProcs ];
Mechanism for a surface type to register its expansion, subdivision, and display procedures
Procedures for Shading Surfaces
BackFacing: PROC[ poly: REF Patch, useEyeSpace: BOOLEANFALSE] RETURNS [FacingDir];
ShadePoly: PROC[ context: REF Context, poly: REF Patch];
GetShades: PROC[context: REF Context, shape: REF ShapeInstance];
GetPolyNormals: PROC[shape: REF ShapeInstance];
GetVtxNormals: PROC[shape: REF ShapeInstance];
Procedures for Sorting and Display
LoadSortSequence: PROC[context: REF Context, sortOrder: LIST OF REF ANYNIL]
      RETURNS[LIST OF REF ANY];
 This builds a back-to-front ordered sequence of patch references
These call a procedure for each polygon in a set of objects
DoBackToFront: PROC[ context: REF Context, sortInfo: LIST OF REF ANY,
       action: PROC[REF ShapePatch]];
DoFrontToBack: PROC[ context: REF Context, sortInfo: LIST OF REF ANY,
       action: PROC[REF ShapePatch]];
DoForPatches: PROC[context: REF Context, set: REF ThreeDBasics.ShapeSequence,
       patchAction: PROC[REF ShapePatch],
       shapeAction: PROC[REF ThreeDBasics.ShapeInstance]];
These render entire scenes
ShowObjects: PROC[ context: REF Context, frontToBack: BOOLEANFALSE ];
ShowWireFrameObjects: PROC[context: REF Context];

These scan convert an individual patch
OutputPatchEdges: PROC[context: REF Context, patch: REF Patch];
OutputPatch: PROC[context: REF Context, patch: REF Patch];
END.