DIRECTORY ThreeDBasics USING [ ClipState, Context, FacingDir, OutCode, Patch, Pixel, PtrPatch, PtrPatchSequence, RGB, ShapeInstance, ShadingSequence, Triple, VertexInfo, VertexInfoSequence, VertexInfoProc, Xfm3D ]; ShapeUtilities: CEDAR DEFINITIONS ~ BEGIN Pixel: TYPE ~ ThreeDBasics.Pixel; -- [ r, g, b, a, z: CARDINAL] Triple: TYPE ~ ThreeDBasics.Triple; -- [ x, y, z: REAL]; RGB: TYPE ~ ThreeDBasics.RGB; Xfm3D: TYPE ~ ThreeDBasics.Xfm3D; OutCode: TYPE ~ ThreeDBasics.OutCode; ClipState: TYPE ~ ThreeDBasics.ClipState; Context: TYPE ~ ThreeDBasics.Context; VertexInfoSequence: TYPE ~ ThreeDBasics.VertexInfoSequence; ShapeInstance: TYPE ~ ThreeDBasics.ShapeInstance; ShadingSequence: TYPE ~ ThreeDBasics.ShadingSequence; FacingDir: TYPE ~ ThreeDBasics.FacingDir; VertexInfo: TYPE ~ ThreeDBasics.VertexInfo; Patch: TYPE ~ ThreeDBasics.Patch; PtrPatch: TYPE ~ ThreeDBasics.PtrPatch; PtrPatchSequence: TYPE ~ ThreeDBasics.PtrPatchSequence; ShapePatch: TYPE ~ RECORD[ shape: REF ShapeInstance, patch, next, prev: INT, awayness: REAL ]; SortSequence: TYPE ~ RECORD[SEQUENCE length: CARDINAL OF REF ShapePatch]; GetVertexInfo: PROC[] RETURNS[REF VertexInfo]; ReleaseVertexInfo: PROC[vtx: REF VertexInfo]; GetPatch: PROC[size: NAT] RETURNS[REF Patch]; ReleasePatch: PROC[p: REF Patch]; ShapePatchToPatch: PROC[ context: REF Context, sPatch: REF ShapePatch ] RETURNS [patch: REF Patch]; XfmToEyeSpace: PROC[context: REF Context, shape: REF ShapeInstance] RETURNS[ClipState]; XfmToDisplay: PROC[context: REF Context, shape: REF ShapeInstance, getBox: BOOL _ FALSE]; GetPolyShades: PROC[context: REF Context, shape: REF ShapeInstance]; GetVtxNmls: PROC[context: REF Context, shape: REF ShapeInstance]; GetVtxShades: PROC[ context: REF Context, shape: REF ShapeInstance ]; ClipPoly: PROC[ context: REF Context, poly: REF Patch] RETURNS [REF Patch]; GetPatchClipState: PROC[ patch: REF Patch]; GetClipCodeForPt: PROC[context: REF Context, pt: Triple] RETURNS[clip: OutCode]; XfmPtToEyeSpace: PROC[context: REF Context, pt: Triple, xfm: Xfm3D _ NIL] RETURNS[Triple, OutCode]; XfmPtToDisplay: PROC[context: REF Context, pt: Triple, shape: REF ShapeInstance _ NIL] RETURNS[Triple]; RegisterStandardSurface: PROC[context: REF Context, type: ATOM]; BackFacing: PROC[ context: REF Context, poly: REF Patch, useEyeSpace: BOOLEAN _ FALSE] RETURNS [FacingDir]; ShadePoly: PROC[ context: REF Context, poly: REF Patch]; ShadeVtx: ThreeDBasics.VertexInfoProc; END. @ShapeUtilities.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Last Edited by: Crow, March 29, 1988 6:01:24 pm PST Basic Types Patch Definitions RECORD[type: ATOM _ NIL, oneSided: BOOLEAN _ TRUE, nVtces: NAT _ 0, clipState: ClipState _ in, props: Atom.PropList _ NIL, vtx: SEQUENCE maxLength: NAT OF VertexInfo]; RECORD[type: ATOM _ NIL, oneSided: BOOLEAN _ TRUE, nVtces: NAT _ 0, clipState: ClipState _ in, props: Atom.PropList _ NIL, vtxPtr: SEQUENCE length: NAT OF NAT]; RECORD[SEQUENCE length: CARDINAL OF REF PtrPatch]; Caching Procedures Gets vertex from automatically expanding pool Returns vertex to pool Gets patch from automatically expanding pool Returns patch to pool Utility Procedures Converts pointers to vertices into self-contained patch data Procedures for Manipulating Shapes Calculate eyespace coords for all vertices, get clip state of vertices and whole shape Calculate display coords for all vertices, get screen extent whole shape Calculate shading for all polygons in shape, get polygon normals if not done Sum normals for vertices given by adjacent polygon corners, only for polygons! Calculate shading for all vertices in shape, get vertex normals if not done Procedures for Transformations and Clipping Clips one polygon (or polyline) to current state of context Clips one polygon (or polyline) to current state of context Evaluates clip codes for vertices (for easy acceptance and rejection tests) Transforms triple from object space to eyespace Transforms triple from eyespace to display coordinates Procedures for expansion of/to polygons Procedures for Shading Patches Tests if polygon faces away from viewer, thus on back side of object PROC[ context: REF Context, vtx: VertexInfo, data: REF ANY _ NIL ] RETURNS[VertexInfo] Calculate shade at vertices of polygon ΚQ˜Iheadšœ™šœ Οmœ1™