DIRECTORY Rope USING [ROPE], Atom USING [PropList], IO USING [STREAM], Imager USING [Rectangle, Context], ImagerColor USING [RGB], Vector2 USING [VEC], Pixels USING [Extent, PixelBuffer], ScanConvert USING [RealSequence, GetColorProc], Vector3d USING [Triple, Quad], Matrix3d USING [Matrix]; ThreeDScenes: CEDAR DEFINITIONS ~ BEGIN Error: SIGNAL [reason: ErrorDesc]; ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: Rope.ROPE]; RGB: TYPE ~ ImagerColor.RGB; Pair: TYPE ~ Vector2.VEC; -- RECORD [ x, y: REAL]; Triple: TYPE ~ Vector3d.Triple; -- RECORD [ x, y, z: REAL]; Quad: TYPE ~ Vector3d.Quad; -- RECORD [ x, y, z, w: REAL]; Rectangle: TYPE ~ Pixels.Extent; RealSequence: TYPE ~ ScanConvert.RealSequence; Xfm3D: TYPE ~ Matrix3d.Matrix; -- REF ARRAY [0..4) OF ARRAY [0..4) OF REAL ScaleAndAddXfm: TYPE ~ RECORD[scaleX, scaleY, scaleZ, addX, addY, addZ: REAL]; Box: TYPE ~ RECORD[left, right, bottom, top: NAT]; -- bounding box for limit tests SixSides: TYPE ~ {Left, Right, Bottom, Top, Near, Far}; OutCode: TYPE ~ RECORD[left, right, bottom, top, near, far: BOOLEAN]; NoneOut: OutCode ~ [FALSE, FALSE, FALSE, FALSE, FALSE, FALSE]; AllOut: OutCode ~ [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE]; Vertex: TYPE ~ RECORD[ x,y,z: REAL _ 0.0, -- object coordinates ex, ey, ez: REAL _ 0.0, -- eyespace coordinates sx, sy, sz: REAL _ 0.0, -- screen coordinates clip: OutCode _ NoneOut -- clip code ]; VertexSequence: TYPE ~ RECORD[SEQUENCE length: CARDINAL OF REF Vertex]; ShadingValue: TYPE ~ RECORD[ xn,yn,zn: REAL _ 0.0, -- normal vector to surface r,g,b: REAL _ 0.7, -- original color (default grey) t: REAL _ 0.0, -- original transmittance txtrX,txtrY,txtrZ: REAL _ 0.0, -- texture coordinates exn,eyn,ezn: REAL _ 0.0, -- normal in eyespace ir,ig,ib,it: CARDINAL _ 0 -- computed color and transmittance (for current lights, view, etc.) ]; ShadingSequence: TYPE ~ RECORD[SEQUENCE length: CARDINAL OF REF ShadingValue]; VertexInfo: TYPE ~ RECORD[coord: Vertex, shade: ShadingValue, props: Atom.PropList]; VertexInfoSequence: TYPE ~ RECORD [SEQUENCE length: CARDINAL OF REF VertexInfo]; VtxToRealSeqProc: TYPE ~ PROC[dest: REF RealSequence, source: VertexInfo] RETURNS[REF RealSequence]; ShadingProcs: TYPE ~ RECORD [VtxToRealSeqProc, ScanConvert.GetColorProc]; ClipState: TYPE ~ { in, out, clipped }; ShapeInstance: TYPE ~ RECORD[ type: ATOM _ NIL, -- eg. $ConvexPolygon, $Bezier, $Light, etc. insideVisible: BOOLEAN _ FALSE, -- closed (or open) surface name: Rope.ROPE _ NIL, -- local name for Shape (allows instancing) fileName: Rope.ROPE _ NIL, -- file name (should be on a server) location: Triple _ [0.,0.,0.], -- position in scene space (last transform) orientation: Triple _ [0.,0.,1.], -- vector defining orientation (second transform) rotation: REAL _ 0., -- rotation about rotation axis (first transform) axisBase: Triple _ [0.,0.,0.], -- rotation axis: direction = End - Base axisEnd: Triple _ [0.,0.,1.], -- rotation is about base point position: Xfm3D _ NIL, -- transform from definition space to world space positionInValid: BOOLEAN _ TRUE, -- location, orientation, or rotation changed clipState: ClipState _ in, -- { in, out, clipped } shadingInValid: BOOLEAN _ TRUE, -- true if light or object changed vtcesInValid: BOOLEAN _ TRUE, -- true if object or view changed centroid: Vertex, -- bounding sphere boundingRadius: REAL _ 0.0, screenExtent: Box _ [0, 0, 0, 0], -- extent on screen (when position valid) vertex: REF VertexSequence _ NIL, -- location and clip codes for defining points shade: REF ShadingSequence _ NIL, -- shading at defining points numSurfaces: NAT _ 0, -- number of surface elements surface: REF ANY _ NIL, -- surface definition using defining points shadingProps: Atom.PropList _ NIL, -- shading definition props: Atom.PropList _ NIL -- catchall ]; ShapeSequence: TYPE ~ RECORD[SEQUENCE length: CARDINAL OF REF ShapeInstance]; Context: TYPE ~ RECORD [ shapes: REF ShapeSequence _ NIL, -- current collection of shapes in environment lights: REF ShapeSequence _ NIL, -- current light sources environment: Atom.PropList _ NIL, -- for reflection map, ambient light proc, etc. eyePoint: Triple _ [1.0, -5.0, 2.0], -- defines point from which view is seen ptOfInterest: Triple _ [0.,0.,0.], -- defines center of image and focus rollAngle: REAL _ 0., -- rotational angle about direction of view upDirection: Triple _ [0.,0.,1.], -- defines "heads-up" direction (redundant) fieldOfView: REAL _ 40., -- horizontal angle included in field of view window: Imager.Rectangle _ [-1.,-1., 2., 2.], -- window clips field of view in eyespace hitherLimit: REAL _ 1., -- anything closer to eyepoint is clipped yonLimit: REAL _ 1000., -- anything further from eyepoint is clipped clippingPlanes: ARRAY SixSides OF Quad, -- computed clip planes eyeSpaceXfm: Xfm3D _ NIL, -- world space to eyespace eyeToNDC: ScaleAndAddXfm _ [1.,1.,1., 0.,0.,0.], -- eyespace to normalized display coords display: Pixels.PixelBuffer, -- display-specific info viewPort: Imager.Rectangle, -- viewport in floating pt. display coordinates extentCovered: Box _ [0, 0, 0, 0], -- bounds area used (while building image) renderMode: ATOM _ NIL, -- {$Dithered, $PseudoClr, $Grey, $Dorado24, $FullClr } alphaBuffer: BOOLEAN _ FALSE, -- buffer for matting and antialiasing depthBuffer: BOOLEAN _ FALSE, -- buffer for cheap hidden-surface removal lineDrawing: BOOLEAN _ FALSE, -- vector or shaded representation depthResolution: NAT _ 8192, -- number of buckets for depth sorting sortSequence: REF _ NIL, -- shapes or surfaces sorted for display props: Atom.PropList _ NIL -- catchall ]; GetFromImagerContext: PROC[ imagerCtx: Imager.Context, alpha, depth, grey: BOOLEAN _ FALSE ] RETURNS [REF Context]; Create: PROC[ width, height: NAT, renderMode: ATOM, alpha, depth: BOOLEAN _ FALSE ] RETURNS [REF Context]; 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, clear: BOOLEAN _ FALSE]; 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]; 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 ]; SetPosition: PROC[shape: REF ShapeInstance, concat: BOOLEAN _ FALSE]; PutShading: PROC[ shape: REF ShapeInstance, key: ATOM, value: REF ANY]; GetShading: PROC[ shape: REF ShapeInstance, key: ATOM ] RETURNS [value: REF ANY]; InitShades: PROC[ shape: REF ShapeInstance ] RETURNS[shade: REF ShadingSequence]; SetUpStandardFile: PROC[file: Rope.ROPE] RETURNS [stream: IO.STREAM, numEntries: NAT]; ReadVertexCoords: PROC[vtx: REF VertexSequence, in: IO.STREAM, nVtces: NAT]; ReadTextureCoords: PROC[shade: REF ShadingSequence, in: IO.STREAM, nVtces: NAT]; ReadColors: PROC[shade: REF ShadingSequence, in: IO.STREAM, length: NAT]; ReadNormals: PROC[shade: REF ShadingSequence, in: IO.STREAM, length: NAT]; 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, pt: Triple] RETURNS[Triple]; ShadePt: 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. ThreeDScenes.mesa Copyright c 1984, 1986 by Xerox Corporation. All rights reserved. Last Edited by: Crow, May 24, 1986 1:36:49 pm PDT Basic Types Vertex Definitions Shape Definitions (also used for lights) Uses for ShapeInstance.shadingProps: - $Type - {$Faceted, $Smooth, $Lines} - $Color - {REF RGB} - $Transmittance - {REF REAL} - $Shininess - {REF REAL} - $PatchColors - {ShadingValue for each Patch} Context Definition Procedures for Setting up Contexts Sets up context using imager context where possible, options: alpha, depth buffer & greyscale Procedures for Defining and Altering Environments Procedures for Manipulating Shapes Rotation about arbitrary axis Get new position matrix or concatenate to previous matrix Procedures for Manipulating Vertices Κ  ˜Ihead3šΟb™šœ Οmœ7™BJšœ1™1J˜šΟk ˜ Jšœ ŸœŸœ˜JšœŸœ ˜JšŸœŸœŸœ˜Idefaultšœ Ÿœ˜%LšœŸœŸœ˜Lšœ ŸœŸœ˜Lšœ Ÿœ˜'LšœŸœ˜1Lšœ ŸœŸ˜!Lšœ Ÿœ ˜——head2šœŸœŸ ˜JšœŸ˜—š ™ IašœŸœ˜"Jš œ ŸœŸœŸœŸœ˜?JšŸœŸœŸœ˜JšœŸœ Ÿœ Οc˜Jš œŸœŸœŸœŸœŸœŸœ˜7—š™šœŸœŸœ˜LšœŸœ  ˜,Lšœ Ÿœ  ˜1Lšœ Ÿœ  ˜0Lšœ  ˜$Lšœ˜—Jš œŸœŸœŸœ ŸœŸœŸœ ˜GN˜šœŸœŸœ˜Nšœ Ÿœ  ˜4NšœŸœ  !˜8NšœŸœ  ˜,NšœŸœ  ˜6Nšœ Ÿœ  ˜1Nšœ Ÿœ D˜_Nšœ˜—Jš œŸœŸœŸœ ŸœŸœŸœ˜NOšœ ŸœŸœ;˜TJš œŸœŸœŸœ ŸœŸœŸœ ˜PLš ΟnœŸœŸœŸœ"ŸœŸœ˜mJšœŸœŸœ.˜I—š(™(Lšœ Ÿœ˜'šœŸœŸœ˜JšœŸœŸœ  ,˜EJšœŸœŸœ ˜>Jšœ Ÿ œ Οi ˜HJšœŸœŸœ $˜DJšœ$ +˜OJšœ& 1˜WJšœ Ÿœ 1˜MJšœ$ )˜MJšœ# #˜FJšœŸœ 1˜MJš œŸœŸœ ’Πci’  ’ ˜QJšœ! ˜8JšœŸœŸœ "˜EJšœŸœŸœ !˜BJšœ ˜,JšœŸœ˜Jšœ% )˜NJšœŸœŸœ .˜RJšœŸœŸœ ˜BJšœ Ÿœ  ˜9Jšœ ŸœŸœŸœ +˜HJšœŸœ ˜:JšœŸœ  ˜+J˜—š œŸœŸœŸœ ŸœŸœŸœ˜Nšœ$™$Jšœ%™%Jšœ ŸœŸœ™JšœŸœŸœ™JšœŸœŸœ™Jšœ.™.———š™šœ ŸœŸœ˜LšœŸœŸœ /˜QLšœŸœŸœ ˜Lš‘œŸœŸœ˜OJš ‘ œŸœ Ÿœ)ŸœŸœ˜XJš ‘ œŸœ ŸœŸœ ˜KJš‘œŸœ Ÿœ  (˜VJš‘œŸœ Ÿœ7ŸœŸœAŸœŸœ ˜ΪJš‘œŸœ ŸœŸœŸœŸ œŸœ˜„Jš‘ œŸœ ŸœŸœ˜9Jš ‘œŸœ ŸœŸœŸœ˜IJš‘ œŸœ ŸœŸ œ˜8Jš‘ œŸœ ŸœŸ œ˜:—š"™"Jš ‘œŸœ ŸœŸœŸœ˜=Jš ‘ œŸœŸœŸœŸœŸœ˜VJš ‘œŸœŸœŸœŸ œŸœ˜dJš ‘ œŸœŸœŸœŸœŸœ˜XJš ‘ œŸœ ŸœŸœŸœŸœ˜bOš‘ œŸœ Ÿœ# ˜SJš‘ œŸœ Ÿœ# ˜RJš‘ œŸœ Ÿœ" ˜Tš ‘ œŸœŸœ Ÿœ2Ÿœ˜]Jšœ™—š ‘ œŸœŸœŸœŸœ ˜FJšœ9™9—Oš ‘ œŸœ ŸœŸœ ŸœŸœ˜GLš‘ œŸœ ŸœŸœŸœ ŸœŸœ˜QL˜—š$™$Jš ‘ œŸœ ŸœŸœŸœ˜QJš‘œŸœ ŸœŸœ ŸœŸœŸœ˜VJš ‘œŸœŸœŸœŸœ Ÿœ˜LJš ‘œŸœŸœŸœŸœ Ÿœ˜PJš ‘ œŸœŸœŸœŸœ Ÿœ˜IJš ‘ œŸœŸœŸœŸœ Ÿœ˜JOš‘œŸœ ŸœŸœ˜QOš‘œŸœ ŸœŸœ˜RLš‘œŸœ ŸœŸœ ˜GLš‘œŸœ Ÿœ%ŸœŸœŸœŸœ˜^Oš ‘ œŸœ ŸœŸœŸœ ˜XLš‘ œŸœ ŸœŸœ˜DJš‘ œŸœ ŸœŸœ˜EL˜—JšŸœ˜J˜—…—$ 1Δ