ThreeDPolygons.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, January 22, 1986 12:19:19 pm PST
DIRECTORY
Atom     USING [PropList],
Rope     USING [ROPE],
IO      USING [STREAM],
Vector2    USING [VEC],
ScanConvert   USING [RealSequence],
Linear3d    USING [Triple, Quad],
ThreeDScenes  USING [AllOut, ClipState, Context, NoneOut, OutCode,
        ShapeInstance, ShapeSequence, Vertex, VertexInfo];
ThreeDPolygons: CEDAR DEFINITIONS
~ BEGIN
Basic Types
ThreeDPolygonsError: SIGNAL [reason: ATOM];
Pair: TYPE ~ Vector2.VEC;           -- [ x, y: REAL];
Triple: TYPE ~ Linear3d.Triple;       -- [ x, y, z: REAL];
Quad: TYPE ~ Linear3d.Quad;        -- [ x, y, z, w: REAL];
RealSequence: TYPE ~ ScanConvert.RealSequence;
OutCode: TYPE ~ ThreeDScenes.OutCode;
NoneOut: OutCode ~ ThreeDScenes.NoneOut;
AllOut: OutCode ~ ThreeDScenes.AllOut;
Vertex Definitions
Vertex: TYPE ~ ThreeDScenes.Vertex;
VertexInfo: TYPE ~ ThreeDScenes.VertexInfo;
Polygon Definitions
Polygon: TYPE ~ RECORD[nVtces: NAT, clipState: ClipState, props: Atom.PropList,
        vtx: SEQUENCE length: NAT OF VertexInfo];
PolygonSequence: TYPE ~ RECORD [SEQUENCE length: NAT OF REF Polygon];
PtrPoly: TYPE ~ RECORD[nVtces: NAT, clipState: ClipState, props: Atom.PropList,
        vtxPtr: SEQUENCE length: NAT OF NAT];
PtrPolySequence: TYPE ~ RECORD[SEQUENCE length: NAT OF REF PtrPoly];
ShapePolygon: TYPE ~ RECORD[shape: REF ShapeInstance, polygon, next: NAT];
SortSequence: TYPE ~ RECORD[SEQUENCE length: NAT OF ShapePolygon];
Shape Definitions
ClipState: TYPE ~ ThreeDScenes.ClipState;
ShapeInstance: TYPE ~ ThreeDScenes.ShapeInstance;
Utility Procedures
EnableDisplay: PROC [];
StopDisplay: PROC [];
Procedures for Reading in Shape Descriptions
LoadShape: PROC[shape: REF ShapeInstance, fileName: Rope.ROPE, type: ATOM ← $Polyhedron];
ReadPolygons: PROC[shape: REF ShapeInstance, in: IO.STREAM, nPolys: NAT];
GetPolygonColors: PROC[shape: REF ShapeInstance, fileName: Rope.ROPE];
Procedures for Transformations and Clipping
ClipPoly: PROC[ context: REF ThreeDScenes.Context, shape: REF ShapeInstance,
     poly, poly2: REF Polygon]
    RETURNS [REF Polygon, REF Polygon];
Procedures for Shading
BackFacing: PROC[ poly: REF Polygon] RETURNS [BOOLEAN];
ShadePoly: PROC[ context: REF ThreeDScenes.Context, poly: REF Polygon];
GetShades: PROC[context: REF ThreeDScenes.Context, shape: REF ShapeInstance];
GetPolyNormals: PROC[shape: REF ShapeInstance];
GetVtxNormals: PROC[shape: REF ShapeInstance];
Procedures for Sorting and Display
 This builds a back-to-front ordered sequence of polygon references
LoadSortSequence: PROC[ context: REF ThreeDScenes.Context,
        buckets: REF ThreeDPolygons.SortSequence ← NIL ]
      RETURNS[REF SortSequence];
These call a procedure for each polygon in a set of objects
DoBackToFront: PROC[ context: REF ThreeDScenes.Context, sortSeq: REF SortSequence,
       action: PROC[ShapePolygon]];
DoFrontToBack: PROC[ context: REF ThreeDScenes.Context, sortSeq: REF SortSequence,
       action: PROC[ShapePolygon]];
DoForPolygons: PROC[set: REF ThreeDScenes.ShapeSequence, action1: PROC[ShapePolygon],
       action2: PROC[REF ThreeDScenes.ShapeInstance]];
ShowObjects: PROC[ context: REF ThreeDScenes.Context, frontToBack: BOOLEANFALSE ];
ShowWireFrameObjects: PROC[context: REF ThreeDScenes.Context];
These scan convert an individual polygon
OutputLines: PROC[context: REF ThreeDScenes.Context, p: ShapePolygon];
OutputPoly: PROC[context: REF ThreeDScenes.Context, p: ShapePolygon];
END.