<> <> <> <> DIRECTORY Atom, G3dBasic, G3dMatrix, G3dShape, Imager, ImagerPixel, ImagerSample, ImagerColor, IO, Rope, Terminal, ViewerClasses; G3dRender: CEDAR DEFINITIONS ~ BEGIN <> Error: SIGNAL [code: ATOM, reason: ROPE]; -- we're able to resume this error <> <> ROPE: TYPE ~ Rope.ROPE; PropList: TYPE ~ Atom.PropList; Virtual: TYPE ~ Terminal.Virtual; Viewer: TYPE ~ ViewerClasses.Viewer; RefSeq: TYPE ~ REF RefSeqRep; RefSeqRep: TYPE ~ RECORD [ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF REF ]; <> RealSequence: TYPE ~ G3dBasic.RealSequence; IntegerSequence: TYPE ~ G3dBasic.IntegerSequence; IntSequence: TYPE ~ G3dBasic.IntSequence; NatSequence: TYPE ~ G3dBasic.NatSequence; NatSequenceRep: TYPE ~ G3dBasic.NatSequenceRep; PairSequence: TYPE ~ G3dBasic.PairSequence; IntegerPairSequence: TYPE ~ G3dBasic.IntegerPairSequence; TripleSequence: TYPE ~ G3dBasic.TripleSequence; QuadSequence: TYPE ~ G3dBasic.QuadSequence; <> RGB: TYPE ~ ImagerColor.RGB; RGBSequence: TYPE ~ REF RGBSequenceRep; RGBSequenceRep: TYPE ~ RECORD [ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF RGB ]; NatRGB: TYPE ~ RECORD [r, g, b: NAT]; NatRGBSequence: TYPE ~ REF NatRGBSequenceRep; NatRGBSequenceRep: TYPE ~ RECORD [ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF NatRGB ]; Spot: TYPE ~ RECORD [ coverage: REAL _ 1.0, -- % of pixel area covered by surface mask: BYTE _ 255, -- code for covered area, default: all covered partShiny: REAL _ 1.0, -- amount shiny surface shows (1.0 = all) val: RealSequence _ NIL, -- interpolated values for shading yIncr: RealSequence _ NIL, -- vertical increments for interpolation xIncr: RealSequence _ NIL, -- horizontal increments for interpolation xySwapped: BOOL, -- if TRUE, xincr and yincr are swapped props: PropList _ NIL -- catchall ]; SpotProc: TYPE ~ PROC [ context: Context, shading: REF ShadingClass, spot: REF Spot, data: REF ANY _ NIL]; PixelPart: TYPE ~ {r, g, b, a, z}; -- addressing within Pixels Pixel: TYPE ~ ARRAY PixelPart OF CARDINAL; -- r, g, b, alpha, z (depth) <> Pair: TYPE ~ G3dBasic.Pair; IntegerPair: TYPE ~ G3dBasic.IntegerPair; -- RECORD [x, y: INTEGER]; Triple: TYPE ~ G3dBasic.Triple; Quad: TYPE ~ G3dBasic.Quad; -- RECORD [x, y, z, w: REAL]; Matrix: TYPE ~ G3dMatrix.Matrix; -- REF 4 by 4 ARRAY OF REAL MatrixRep: TYPE ~ G3dMatrix.MatrixRep; <> SampleMap: TYPE ~ ImagerSample.SampleMap; PixelMap: TYPE ~ ImagerPixel.PixelMap; Box: TYPE ~ G3dShape.Box2d; -- [min, max: Pair] Rectangle: TYPE ~ Imager.Rectangle; -- RECORD [x, y, w, h: REAL] ScaleAndAddXfm: TYPE ~ RECORD [scaleX, scaleY, scaleZ, addX, addY, addZ: REAL]; ClipState: TYPE ~ G3dShape.ClipState; -- {in, out, clipped, unknown} OutCode: TYPE ~ RECORD [left, right, bottom, top, near, far: BOOL]; SixSides: TYPE ~ {Left, Right, Bottom, Top, Near, Far}; <> NoneOut: OutCode ~ [FALSE, FALSE, FALSE, FALSE, FALSE, FALSE]; AllOut: OutCode ~ [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE]; IdentityXfm: ScaleAndAddXfm ~ [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]; <> TextureFunction: TYPE ~ RECORD [name: ATOM, proc: SpotProc, props: PropList]; TextureMap: TYPE ~ RECORD [type: ATOM, pixels: REF ANY, props: Atom.PropList]; SummedTexture: TYPE ~ RECORD [SEQUENCE length: NAT OF REF SumSequence]; SumSequence: TYPE ~ RECORD [SEQUENCE length: NAT OF IntSequence]; <> CtlPoint: 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 ]; CtlPointSequence: TYPE ~ REF CtlPointSequenceRep; CtlPointSequenceRep: TYPE ~ RECORD[ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF REF CtlPoint ]; Shading: TYPE ~ RECORD [ xn, yn, zn: REAL _ 0.0, -- normal vector to surface exn, eyn, ezn: REAL _ 0.0, -- normal in eyespace r, g, b: REAL _ 1.0, -- vertex color (default white) scaled by shape color t: REAL _ 1.0, -- original transmittance txtrX, txtrY: REAL _ 0.0, -- texture mapping coordinates er, eg, eb, et: REAL _ 0.0 -- computed color, transmittance (for lights, etc) ]; ShadingSequence: TYPE ~ REF ShadingSequenceRep; ShadingSequenceRep: TYPE ~ RECORD[ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF REF Shading ]; CtlPtInfo: TYPE ~ RECORD [ coord: CtlPoint _ [], shade: Shading _ [], vtxPtr: NAT _ 0, data: REF _ NIL ]; CtlPtInfoSequence: TYPE ~ REF CtlPtInfoSequenceRep; CtlPtInfoSequenceRep: TYPE ~ RECORD [ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF REF CtlPtInfo ]; CtlPtInfoProc: TYPE ~ PROC [context: Context, vtx: CtlPtInfo, data: REF ANY _ NIL] RETURNS [CtlPtInfo]; CtlPtToRealSeqProc: TYPE ~ PROC [dest: RealSequence, source: CtlPtInfo, data: REF _ NIL] RETURNS [RealSequence]; <> FacingDir: TYPE ~ {front, back, unknown}; Patch: TYPE ~ RECORD [ type: ATOM _ NIL, oneSided: BOOL _ TRUE, nVtces: NAT _ 0, clipState: ClipState _ unknown, dir: FacingDir _ unknown, renderData: REF RenderData, props: PropList _ NIL, ctlPt: SEQUENCE maxLength: NAT OF CtlPtInfo ]; <> <> PatchSequence: TYPE ~ REF PatchSequenceRep; PatchSequenceRep: TYPE ~ RECORD [ length: CARDINAL _ 0, element: SEQUENCE maxLength: CARDINAL OF REF Patch ]; PatchProc: TYPE ~ PROC [context: Context, patch: REF Patch, data: REF ANY _ NIL] RETURNS [REF Patch]; <> Shape: TYPE ~ G3dShape.Shape; ShapeSequence: TYPE ~ G3dShape.ShapeSequence; RenderData: TYPE ~ RECORD [ -- becomes shape.renderData class: REF ShapeClass _ NIL, -- surface type, display procs shadingClass: REF ShadingClass _ NIL, -- shading parameters and procs props: PropList _ NIL, -- catchall ($LinesList, $Hidden) fixedProps: PropList _ NIL, -- fixed attributes shadingProps: PropList _ NIL, -- shading status and parameters patch: PatchSequence _ NIL, -- built from vertex and surface data patchesValid: BOOL _ FALSE -- FALSE if patches need update ]; <> << $ClippedPatches, $ClippedVertices, $Hidden, $LinesList, >> <<>> <> << $Closed, $PatchColors, $PatchColorsInFile, $PatchInfo, $PatchNormalsInFile, $PatchTransmittancesInFile, $VertexColorsInFile, $VertexNormalsInFile, $VertexTextureInFile, $VertexTransmittanceInFile>> <<>> <> << $AuxiliaryVtxData, $PolygonInfoComputed, $Scale, $ShapeLerp, $TextureScale, $TxtrCoordParams, $TxtrCoordRange, $TxtrCoordType, $TxtrTranslation, $VtxInfoComputed>> <<>> ShapeClass: TYPE ~ RECORD [ type: ATOM _ NIL, -- eg, $ConvexPolygon, $Bezier, $Light, etc validate: ShapeProc _ NIL, -- update vtces and shading after changes display: ShapeProc _ NIL, -- display whole shape (speed optimized?) displayPatch: PatchProc _ NIL, -- display patch doBeforeFrame: LIST OF ShapeProc _ NIL -- do before disp. (for animation, etc) ]; ShadingClass: TYPE ~ RECORD [ type: ATOM _ NIL, -- eg. $Default, $MappedAndSolidTexture renderMethod: REF _ NIL, -- RenderStyle, or ShapeProc color: RGB _ [0.7, 0.7, 0.7], -- whole object color, mixable w/ vtx color shininess: REAL _ 0.0, -- hilight power, usu. 30.0-300.0, 0 = none transmittance: REAL _ 0.0, -- surface transmittance of object texture: LIST OF REF ANY _ NIL,-- textureMap, solid texture, etc. textureScale: Pair _ [1.0, 1.0], -- scale factors for texture coordinates bumpScale: REAL _ 1.0, -- scale factor for bump height cnvrtVtx: CtlPtToRealSeqProc _ NIL,-- converts vertex to sequence of reals getColor: SpotProc _ NIL, -- calculates shade at pixel shadeVtx: CtlPtInfoProc _ NIL -- calculates shade from vertex info ]; ShapeProc: TYPE ~ PROC [context: Context, shape: Shape, data: REF ANY _ NIL] RETURNS [Shape]; <> Context: TYPE ~ REF ContextRep; ContextRep: TYPE ~ RECORD [ <> class: REF ContextClass _ NIL, stopMe: REF BOOL _ NIL, -- stop flag for bailing out (ref for inheritance) imageReady: BOOL _ FALSE, -- flag for useable image in display changed: BOOL _ TRUE, -- call SurfaceRender.ValidateContext if true <> frameNumber: NAT _ 0, -- current frame for animation routines shapes: ShapeSequence _ NIL, -- current collection of shapes and lights visibleShapes: ShapeSequence _ NIL, -- computed by SurfaceRender.ValidateContext lightSources: ShapeSequence _ NIL, -- computed by SurfaceRender.ValidateContext environment: PropList _ NIL, -- for reflection map, ambient light proc, etc. <> eyePoint: Triple _ [1.0, -5.0, 2.0], -- defines point from which view is seen lookAt: Triple _ [0.0, 0.0, 0.0], -- defines center of image and focus rollAngle: REAL _ 0.0, -- rotational angle about direction of view upDirection: Triple _ [0.0, 0.0, 1.0], -- defines "heads-up" direction (redundant) fieldOfView: REAL _ 40.0, -- horizontal angle included in field of view window: REF Rectangle _ NIL, -- window clips field of view in eyespace hitherLimit: REAL _ 1.0, -- anything closer to eyepoint is clipped yonLimit: REAL _ 1000.0, -- anything further from eyepoint is clipped clippingPlanes: ARRAY SixSides OF Quad, -- computed clip planes eyeSpaceXfm: Matrix _ NIL, -- world space to eyespace eyeToNdc: ScaleAndAddXfm _ IdentityXfm, -- eyespace to normalized disp. coords ndcToPixels: ScaleAndAddXfm _ IdentityXfm, -- to screen coords <> viewer: Viewer, -- viewer record if in Viewer ELSE NIL terminal: Virtual _ NIL, -- virtual terminal for this context, if displayed displayInValid: BOOL _ TRUE, -- true whenever display parameter updated pixels: PixelMap _ NIL, -- where the bits are pixelAspectRatio: REAL _ 1.0, -- physical width/height of displayed pixel viewPort: REF Rectangle _ NIL, -- viewport in floating pt. display coordinates preferredViewPort: Rectangle _ [0., 0., 65536., 65536.], -- maximum viewport size screenExtent: Box _ [[0, 0], [0, 0]], -- bounds area used (while building image) preferredRenderMode: ATOM _ NIL, -- $Pixels, $Imager (fancy vs. device indep.) displayProps: PropList _ NIL, -- $Depth, $Alpha (Pixel posn), -- $FullDisplayMemory, $ViewerAdjusted <> autoRedraw: BOOL _ FALSE, -- quick image hint, redraw if viewer changes delayClear: BOOL _ FALSE, -- delay clearing buffer when rendering doVisibly: BOOL _ TRUE, -- build image on display antiAliasing: BOOL _ FALSE, -- flag for antialiasing and alpha buffer depthBuffering: BOOL _ FALSE, -- buffer for cheap hidden-surface removal depthResolution: NAT _ 8192, -- number of buckets for depth sorting sortSequence: REF _ NIL, -- shapes or surfaces sorted for display props: PropList _ NIL -- catchall, global uses: << $WDir - working directory>> << $Log - log file for messages>> << $BackGround - background color or context (images)>> << $DitherContext - for dithering RGB to pseudocolor>> << $OutputFile - output file for interpress or animation>> << $ImagerCtx - context for Imager calls, if no viewer>> << $SortToPriority - forces priority sort, poly intersections>> ]; ContextClass: TYPE ~ RECORD [ displayType: ATOM _ NIL, -- includes: << $PseudoColor,>> << $Gray,>> << $FullColor,>> << $ImagerGray>> << $ImagerDithered,>> << $ImagerFullClr,>> << $Bitmap,>> << $Interpress >> setUpDisplayType: ContextProc, -- ensures there are bits to write, sets up colors validateDisplay: ContextProc, -- makes sure viewPort changes, etc. take effect render: ContextProc, -- call this to display the scene loadBackground: ContextProc, -- clear to background << 2d drawing primitives use normalized display coordinates (-1.0 < x < 1.0, -.75 < y < .75)>> draw2DLine: PROC [context: Context, p1, p2: Pair, color: Pixel], -- display a line draw2DPolygon: PROC [context: Context, poly: PairSequence, color: Pixel], draw2DRope: PROC [context: Context, rope: ROPE, position: Pair, color: Pixel _[255,255,128,0,0], size: REAL _20, font: ROPE _NIL], displayPolygon: PatchProc, -- 3 dimensional shading drawInViewer: PROC [context: Context, procRec: REF ImagerProcRec], updateViewer: ContextProc ]; ContextProc: TYPE ~ PROC [context: Context, data: REF ANY _ NIL]; ImagerProc: TYPE ~ PROC [context: Context, imagerCtx: Imager.Context, data: REF _ NIL]; ImagerProcRec: TYPE ~ RECORD [proc: ImagerProc, data: REF ANY _ NIL]; RopeProc: TYPE ~ PROC [ context: Context, rope: ROPE, position: Pair, color: Pixel _ [255,255,255,0,0], size: REAL _ 20, font: ROPE _ NIL]; <> RegisterDisplayClass: PROC [class: ContextClass, type: ATOM]; <> GetDisplayClass: PROC [type: ATOM] RETURNS [class: ContextClass]; <> LoadDisplayClass: PROC [context: Context, type: ATOM]; <> RegisterShapeClass: PROC [class: ShapeClass, type: ATOM]; <> GetShapeClass: PROC [type: ATOM] RETURNS [class: ShapeClass]; <> LoadShapeClass: PROC [shape: Shape, type: ATOM _ $ConvexPolygon]; <> RegisterShadingClass: PROC [class: ShadingClass, type: ATOM]; <> GetShadingClass: PROC [type: ATOM] RETURNS [class: ShadingClass]; <> LoadShadingClass: PUBLIC PROC [shape: Shape, type: ATOM _ $Default]; <> <> Create: PROC RETURNS [Context]; <> InitializeRawColorDisplayContext: PROC [ antiAliasing: BOOL _ TRUE, background: RGB _ [0.2, 0.2, 0.7], displayMode: DisplayMode _ gray] RETURNS [context: Context]; <> <> <<>> CloseDisplay: PROC [context: Context]; <> <<>> CloseColorViewers: PROC; <> <<>> KillUntitledColorViewers: PROC; <> GetTmpContext: PUBLIC PROC [srcCtx: Context] RETURNS[dstCtx: Context]; <> CopyContextData: PUBLIC PROC [dstCtx, srcCtx: Context]; <> CopyContextShapes: PUBLIC PROC [dstCtx, srcCtx: Context]; <> <> SetViewFromParameters: PROC [ context: Context, fieldOfView: REAL _ 40.0, scale: REAL _ 1.0, moves, rotates: Triple _ []]; <> SetView: PROC [ context: Context, eyePoint: Triple, lookAt: Triple, fieldOfView: REAL _ 40.0, rollAngle: REAL _ 0.0, upDirection: Triple _ [0., 0., 1.], hitherLimit: REAL _ .01, yonLimit: REAL _ 1000.0]; <> <<>> SetViewPort: PROC [context: Context, size: Rectangle]; <> SetAmbientLight: PROC [context: Context, rgb: RGB]; <> <<>> NameAmbientLight: PROC [context: Context, color: ROPE]; <> GetAmbientLight: PROC [context: Context] RETURNS [RGB]; <> <<>> AddLight: PROC [context: Context, name: ROPE, position: Triple, color: RGB _ [1, 1, 1]]; <> DeleteLight: PROC [context: Context, name: ROPE]; <> <> NameBackgroundColor: PROC [context: Context, color: ROPE]; <> SetBackgroundColor: PROC [context: Context, color: RGB]; <> GetBackgroundColor: PROC [context: Context] RETURNS [color: RGB]; <> SetBackgroundImage: PROC [context: Context, aisFile: ROPE]; <> GetBackgroundImage: PROC [context: Context] RETURNS [ROPE]; <> <<>> SetBackgroundContext: PROC [context, bkGrdCtx: Context]; <> <<>> KillBackground: PROC [context: Context]; <> <> RenderStyle: TYPE ~ {faceted, smooth, lines, shadedLines, hiddenLines, linesWnormals}; AddShape: PROC [context: Context, shape: Shape]; <> AddShapeFromFile: PROC [ context: Context, shapeName: ROPE, fileName: ROPE, position: Triple _ [0.0, 0.0, 0.0]]; <> <> FindShape: PROC [context: Context, shapeName: ROPE] RETURNS [Shape]; <> <<>> ShapeFromRope: PROC [ name: ROPE _ NIL, message: ROPE, color: ROPE _ NIL, size: REAL _ 0.5, font: ROPE _ NIL] RETURNS [Shape]; <> <> ChangeRopeMessage: PUBLIC PROC [context: Context, shapeName: ROPE, newMessage: ROPE]; <> DeleteShape: PROC [context: Context, shapeName: ROPE]; <> DeleteAllShapes: PROC [context: Context]; <> <<>> SetRenderStyle: PROC [shape: Shape, renderStyle: RenderStyle]; <> <<>> SetShininess: PROC [shape: Shape, shininess: REAL]; <> <<>> SetColor: PROC [shape: Shape, color: RGB]; <> <<>> SetTransmittance: PROC [shape: Shape, transmittance: REAL]; <> <> <<>> SetInvisible: PROC [shape: Shape]; <> <<>> SetVisible: PROC [shape: Shape]; <> <<>> ShowBackfaces: PROC [shape: Shape]; <> <<>> HideBackfaces: PROC [shape: Shape]; <> <<>> <> RenderDataFrom: PROC [shape: Shape] RETURNS [REF RenderData]; ShapeClassFrom: PROC [shape: Shape] RETURNS [REF ShapeClass]; <> <<>> ShadingClassFrom: PROC [shape: Shape] RETURNS [REF ShadingClass]; <> PatchesFrom: PROC [shape: Shape] RETURNS [PatchSequence]; <> <> TextureStyle: TYPE ~ {none, intensity, color, bump, function}; TextureInfo: TYPE ~ RECORD [name: ROPE, type: TextureStyle, filtered: BOOL]; SetTextureMap: PROC [ context: Context, shapeName: ROPE, aisName: ROPE, textureStyle: TextureStyle _ intensity, textureFiltering: BOOL _ FALSE] RETURNS [error: ROPE]; <> <> <<>> OffsetTextureCoords: PROC [shape: Shape, offset: Pair]; <> <<>> GetTexture: PROC [shape: Shape] RETURNS [PairSequence]; <> <<>> GetTextureInfo: PROC [shape: Shape] RETURNS [LIST OF TextureInfo]; <> <<>> ScaleTexture: PROC [context: Context, shape: Shape, scale: Pair]; <> <<>> SetTextureScale: PROC [shape: Shape, scale: Pair _ [1.0, 1.0]]; <> <<>> GetTextureScale: PROC [shape: Shape] RETURNS [Pair _ [1.0, 1.0]]; <> <<>> SetTextureRange: PROC [shape: Shape, textureRange: Pair]; <> <> <<>> SetTextureFiltering: PROC [context: Context, shape: Shape, on: BOOL]; <> <<>> GetBumpScale: PROC [shape: Shape] RETURNS [REAL]; <> <<>> SetBumpScale: PROC [shape: Shape, scale: REAL _ 1.0]; <> <> DisplayMode: TYPE ~ {gray, dither, fullColor}; StartLog: PROC [context: Context] RETURNS[IO.STREAM]; <> FlushLog: PROC [context: Context]; <> CloseLog: PROC [context: Context]; <> Render: PROC [context: Context, fork: BOOL _ TRUE]; <> <<>> WaitTilRenderDone: PROC; <> NotRendering: PROC [context: Context] RETURNS [BOOL]; <> <<>> AbortRender: PROC [context: Context]; <> <<>> GetDisplayMode: PROC [context: Context] RETURNS [DisplayMode]; <> <<>> SetAntiAliasing: PROC [context: Context, on: BOOL _ TRUE]; <> <<>> AntiAliasingNeeded: PROC [context: Context] RETURNS [BOOL]; <> <> <<>> GetBuffer: PROC [context: Context, type: ATOM] RETURNS [SampleMap]; <> <<>> GetAlphaBuffer: PROC [context: Context] RETURNS [SampleMap]; <> <<>> GetDepthBuffer: PROC [context: Context] RETURNS [SampleMap]; <> <> PrependWorkingDirectory: PUBLIC PROC[context: Context, file: ROPE] RETURNS[ROPE]; TackOnExtension: PUBLIC PROC[file, extension: ROPE] RETURNS[ROPE]; IntersectRectangles: PROC [Rectangle, Rectangle] RETURNS [Rectangle]; <> <<>> AtomFromTextureStyle: PROC [textureStyle: TextureStyle] RETURNS [ATOM]; <> <<>> AtomFromDisplayMode: PROC [displayMode: DisplayMode] RETURNS [ATOM]; <> <<>> RopeFromDisplayMode: PROC [displayMode: DisplayMode] RETURNS [ROPE]; <> <<>> RopeFromRenderStyle: PROC [renderStyle: RenderStyle] RETURNS [ROPE]; <> <<>> RopeFromTextureStyle: PROC [textureStyle: TextureStyle] RETURNS [ROPE]; <> <<>> END.