ThreeDScenes.mesa
Copyright © 1984, 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, October 2, 1986 10:20:13 am PDT
DIRECTORY
Rope     USING [ ROPE ],
IO      USING [ STREAM ],
Terminal    USING [ Virtual ],
Imager    USING [ Rectangle, Context] ,
ScanConvert   USING [ GetColorProc ],
ThreeDBasics  USING [ ClipState, Context, OutCode, RGB, ShadingSequence,
         ShapeInstance, ShapeSequence, Triple, VertexInfo,
         VertexInfoSequence, VertexSequence, VtxToRealSeqProc ];
ThreeDScenes: CEDAR DEFINITIONS
~ BEGIN
Basic Types
Error: SIGNAL [reason: ErrorDesc];
ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: Rope.ROPE];
RGB: TYPE ~ ThreeDBasics.RGB;
Triple: TYPE ~ ThreeDBasics.Triple;        -- RECORD [ x, y, z: REAL];
OutCode: TYPE ~ ThreeDBasics.OutCode;
VertexSequence: TYPE ~ ThreeDBasics.VertexSequence;
ShadingSequence: TYPE ~ ThreeDBasics.ShadingSequence;
VertexInfo: TYPE ~ ThreeDBasics.VertexInfo;
VertexInfoSequence: TYPE ~ ThreeDBasics.VertexInfoSequence;
ClipState: TYPE ~ ThreeDBasics.ClipState;
ShapeInstance: TYPE ~ ThreeDBasics.ShapeInstance;
ShapeSequence: TYPE ~ ThreeDBasics.ShapeSequence;
Context: TYPE ~ ThreeDBasics.Context;
ShadingProcs: TYPE ~ RECORD [ThreeDBasics.VtxToRealSeqProc, ScanConvert.GetColorProc];
Procedures for Setting up Contexts
 Gets context
Create: PROC[] RETURNS [REF Context];

Sets up context.display using imager context
DisplayFromImagerContext: PROC[ context: REF Context, imagerCtx: Imager.Context ];

Sets up context.display using virtual terminal, render mode from state of color display
DisplayFromTerminal: PROC[ context: REF Context, terminal: Terminal.Virtual ];

Sets up context.display using virtual memory (not visible) full-color assumed
DisplayFromVM: PROC[ context: REF Context, width, height: NAT,
        renderMode: ATOM ← $FullColor ];

Makes depth buffer in VM for context.display
AddDepthBuffer: PROC[ context: REF Context ];

Makes alpha buffer in VM for context.display
AddAlphaBuffer: PROC[ context: REF Context ];
Procedures for Defining and Altering Environments
SetEyeSpace: PROC[ context: REF Context ];    -- get worldspace to eyespace matrix
SetWindow: PROC[context: REF Context, size: Imager.Rectangle];
WindowFromViewPort: PROC[viewPort: Imager.Rectangle] RETURNS[Imager.Rectangle];
SetViewPort: PROC[context: REF Context, size: Imager.Rectangle];
FillViewPort: PROC[context: REF Context, clr: RGB]; -- clears for new image
FillInBackGround: PROC[context: REF Context]; -- loads background behind current image
SetView: PROC[context: REF Context, eyePoint, ptOfInterest: Triple, fieldOfView: REAL ← 40.0,
     rollAngle: REAL ← 0.0, upDirection: Triple ← [ 0., 0., 1.],
     hitherLimit: REAL ← .01, yonLimit: REAL ← 1000.0];
SetLight: PROC[context: REF Context, name: Rope.ROPE, position: Triple, color: RGB ← [1., 1., 1.]]
   RETURNS
[REF ShapeInstance];
DeleteLight: PROC[context: REF Context, name: Rope.ROPE];
GetAmbientLight: PROC[context: REF Context, normal: Triple] RETURNS[RGB];
ReadScene: PROC[context: REF Context, input: IO.STREAM];
WriteScene: PROC[context: REF Context, output: IO.STREAM];
Procedures for Manipulating Shapes
NewShape: PROC[ name: Rope.ROPE ] RETURNS[REF ShapeInstance];
FindShape: PROC[ set: REF ShapeSequence, name: Rope.ROPE ] RETURNS[REF ShapeInstance];
AddShape: PROC[ set: REF ShapeSequence, shape: REF ShapeInstance ]
    RETURNS
[REF ShapeSequence];
DeleteShape: PROC[ set: REF ShapeSequence, name: Rope.ROPE ] RETURNS[REF ShapeSequence];
CopyShape: PROC[ shape: REF ShapeInstance, newName: Rope.ROPE ]
    RETURNS
[REF ShapeInstance];
PlaceShape: PROC[ shape: REF ShapeInstance, location: Triple]; -- absolute position
MoveShape: PROC[ shape: REF ShapeInstance, delta: Triple];    -- relative position
OrientShape: PROC[ shape: REF ShapeInstance, axis: Triple];    -- tilt from vertical
RotateShape: PUBLIC PROC[ shape: REF ShapeInstance, axisBase, axisEnd: Triple, theta: REAL ];
Rotation about arbitrary axis
SetPosition: PROC[shape: REF ShapeInstance, concat: BOOLEANFALSE];
Get new position matrix or concatenate to previous matrix
PutShading: PROC[ shape: REF ShapeInstance, key: ATOM, value: REF ANY];
GetShading: PROC[ shape: REF ShapeInstance, key: ATOM ] RETURNS [value: REF ANY];
Procedures for Manipulating Vertices
InitShades: PROC[ shape: REF ShapeInstance ] RETURNS[shade: REF ShadingSequence];
GetClipCodeForPt: PROC[context: REF Context, pt: Triple] RETURNS[clip: OutCode];
XfmPtToEyeSpace: PROC[context: REF Context, pt: Triple] RETURNS[Triple, OutCode];
XfmPtToDisplay: PROC[context: REF Context, shape: REF ShapeInstance, pt: Triple]
      RETURNS[Triple];
ShadeVtx: PROC [context: REF Context, pt: VertexInfo, shininess: REAL]
   RETURNS [RGB, REAL];
XfmToEyeSpace: PROC[context: REF Context, shape: REF ShapeInstance] RETURNS[ClipState];
XfmToDisplay: PROC[context: REF Context, shape: REF ShapeInstance];
GetVtxShades: PROC[ context: REF Context, shape: REF ShapeInstance ];
END.