<<>> <> <> <> <> <> DIRECTORY CedarProcess, Commander, Controls, Draw2d, G3dBasic, G3dControl, G3dDraw, G3dLight, G3dMatrix, G3dRender, G3dShape, G3dTimeTrees, G3dView, Imager, ImagerColor, ImagerSample, IO, Prop, Rope, SF, UnixSpawnTCP, UnixTypes, ViewerClasses; G3dTool: CEDAR DEFINITIONS ~ BEGIN <> Process: TYPE ~ CedarProcess.Process; CommandHandle: TYPE ~ Commander.Handle; ButtonList: TYPE ~ Controls.ButtonList; ClickProc: TYPE ~ Controls.ClickProc; ControlList: TYPE ~ Controls.ControlList; ControlSizes: TYPE ~ Controls.ControlSizes; OuterData: TYPE ~ Controls.OuterData; Typescript: TYPE ~ Controls.Typescript; Viewer: TYPE ~ Controls.Viewer; Zip: TYPE ~ Draw2d.Zip; IntegerPair: TYPE ~ G3dBasic.IntegerPair; Pair: TYPE ~ G3dBasic.Pair; Plane: TYPE ~ G3dBasic.Quad; Triple: TYPE ~ G3dBasic.Triple; CameraControl: TYPE ~ G3dControl.CameraControl; Light: TYPE ~ G3dLight.Light; LightSequence: TYPE ~ G3dLight.LightSequence; Matrix: TYPE ~ G3dMatrix.Matrix; TransformOrder: TYPE ~ G3dMatrix.TransformOrder; Viewport: TYPE ~ G3dMatrix.Viewport; Context3d: TYPE ~ G3dRender.Context3d; DrawOptions: TYPE ~ G3dDraw.Options; Shape: TYPE ~ G3dShape.Shape; ShapeProc: TYPE ~ G3dShape.ShapeProc; ShapeSequence: TYPE ~ G3dShape.ShapeSequence; ScreenSequence: TYPE ~ G3dShape.ScreenSequence; TTNode: TYPE ~ G3dTimeTrees.Node; TimeTree: TYPE ~ G3dTimeTrees.TimeTree; Camera: TYPE ~ G3dView.Camera; CameraRep: TYPE ~ G3dView.CameraRep; Context: TYPE ~ Imager.Context; RGB: TYPE ~ ImagerColor.RGB; Rectangle: TYPE ~ Imager.Rectangle; SampleMap: TYPE ~ ImagerSample.SampleMap; STREAM: TYPE ~ IO.STREAM; PropList: TYPE ~ Prop.PropList; ROPE: TYPE ~ Rope.ROPE; SFBox: TYPE ~ SF.Box; SpawnData: TYPE ~ UnixSpawnTCP.SpawnData; FileDescriptor: TYPE ~ UnixTypes.FileDescriptor; IconFlavor: TYPE ~ ViewerClasses.IconFlavor; <> ForkableProc: TYPE ~ CedarProcess.ForkableProc; ControlProc: TYPE ~ Controls.ControlProc; MouseProc: TYPE ~ Controls.MouseProc; DestroyProc: TYPE ~ Controls.DestroyProc; DrawProc: TYPE ~ PROC [ context: Context, viewer: Viewer, whatChanged: REF ANY, view: Matrix, vp: Viewport, v: View, tool: Tool, clientData: REF ANY]; StopProc: TYPE ~ PROC [clientData: REF ANY, reason: ROPE]; ChangeProc: TYPE ~ PROC [lastTool, activeTool: Tool, clientData: REF ANY]; AnimateProc: TYPE ~ PROC [frame: NAT, alpha, time: REAL, clientData: REF ANY]; << alpha = (frame-firstFrame)/(lastFrame-firstFrame)>> <> Animation: TYPE ~ REF AnimationRep; AnimationRep: TYPE ~ RECORD [ name: ROPE ¬ NIL, length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF SampleMap ]; Animations: TYPE ~ REF AnimationsRep; AnimationsRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Animation ]; <> NamedBuffer: TYPE ~ RECORD [id: ATOM, map: SampleMap]; WhichVertices: TYPE ~ {selectedOnly, all}; ShapeScreens: TYPE ~ REF ShapeScreensRep; ShapeScreensRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF ScreenSequence ]; View: TYPE ~ REF ViewRep; ViewRep: TYPE ~ RECORD [ tool: Tool ¬ NIL, once: BOOL ¬ FALSE, index: NAT ¬ 0, viewer: Viewer ¬ NIL, viewport: Viewport ¬ [], camera: Camera ¬ NIL, spare: Matrix ¬ NIL, idBuffer: LIST OF NamedBuffer ¬ NIL, -- buffer with id screens: ShapeScreens ¬ NIL, extent, previousExtent: SF.Box ¬ [[0, 0], [0, 0]] -- integer screen space ]; ViewProc: TYPE ~ PROC [view: View] RETURNS [continue: BOOL ¬ TRUE]; ViewSequence: TYPE ~ REF ViewSequenceRep; ViewSequenceRep: TYPE ~ RECORD [element: SEQUENCE length: CARDINAL OF View]; <<3d Command Registration>> Register: PROC [name: ROPE, proc: Commander.CommandProc, usage: ROPE]; < [arguments].>> <" removed.>> <> Client: TYPE ~ RECORD [ mouse: MouseProc ¬ NIL, -- client supplied mouse proc camera: ControlProc ¬ NIL, -- client supplied camera control proc draw: DrawProc ¬ NIL, -- client supplied draw proc destroy: DestroyProc ¬ NIL, -- client supplied destroy proc animate: AnimateProc ¬ NIL, -- client supplied animation proc stop: StopProc ¬ NIL, -- response to STOP button change: ChangeProc ¬ NIL, -- response to active tool change data: REF ANY ¬ NIL -- client supplied data ]; Operations: TYPE ~ RECORD [ lines: BOOL ¬ FALSE, -- provide Line Drawing Ops button render: BOOL ¬ FALSE, -- provide Render Ops button shape: BOOL ¬ FALSE, -- provide Shape Ops button scene: BOOL ¬ FALSE, -- provide Scene Ops button texture: BOOL ¬ FALSE, -- provide Texture Ops button light: BOOL ¬ FALSE, -- provide Light Ops button io: BOOL ¬ FALSE, -- provide IO Ops button animation: BOOL ¬ FALSE, -- provide Animation Ops button stop: BOOL ¬ FALSE, -- provide Stop button help: BOOL ¬ FALSE -- provide Help button ]; allOps: Operations ~ [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE]; noOps: Operations ~ []; DisplayMode: TYPE ~ {lined, shaded}; RIBMode: TYPE ~ {spawn, file}; Tool: TYPE ~ REF ToolRep; ToolRep: TYPE ~ RECORD [ <> ops: Operations ¬ allOps, -- generic operations supported by tool directory: ROPE ¬ NIL, -- directory whence tool was made name: ROPE ¬ NIL, -- name of tool cmd: CommandHandle ¬ NIL, -- commander command: ROPE ¬ NIL, -- to execute after forked process process: Process ¬ NIL, -- the current, forked process clock: REAL ¬ 0.0, -- for timing props: PropList ¬ NIL, -- miscellaneous storage <> client: Client ¬ [], -- one client per tool <> outer: Viewer ¬ NIL, -- parent viewer graphics: Viewer ¬ NIL, -- graphical viewer bounds: Rectangle ¬ [0,0,0,0], -- for subsequent draw use outerData: OuterData ¬ NIL, -- Control's data record camera: CameraControl ¬ NIL, -- viewing control controls: ControlList ¬ NIL, -- list of controls buttons: ButtonList ¬ NIL, -- menu typescript: Typescript ¬ NIL, -- for user IO displayMode: DisplayMode ¬ lined, -- lines or shaded regions? ipStrokeWidth: REAL ¬ 2.0, -- for interpress output <> views: ViewSequence ¬ NIL, -- multiple views activeViews: LIST OF NAT ¬ NIL, -- currently controlled view <> sprite: Triple ¬ [], -- user-positionable 3d sprite spritePlane: Plane ¬ [], -- plane in which sprite moves drawSprite: BOOL ¬ FALSE, -- display 3d sprite <> buffering: Buffering ¬ default, -- single, double or depends background: Triple ¬ [1.0, 1.0, 1.0], -- background color for line drawing nVerticesAndPolys: NAT ¬ 0, -- used to estimate display time previousDisplayTime: REAL ¬ 0.0, -- in seconds drawOptions: DrawOptions ¬ [], -- draw for drawing the shape drawPendant: BOOL ¬ FALSE, -- if display of axes "pendant" drawClient: BOOL ¬ TRUE, -- draw any client graphics forInterpress: BOOL ¬ FALSE, -- if output is to an ip file drawCurves: BOOL ¬ FALSE, -- draw shape as curves queryVertices: BOOL ¬ FALSE, -- interactively query vertex info timing: BOOL ¬ FALSE, -- if display line-drawing time drawLights: BOOL ¬ FALSE, -- draw light sources drawAxes: BOOL ¬ FALSE, -- x, y, z axes (also for rendering) previousWhatChanged: REF ANY ¬ NIL, -- previous reason for paint <> context3d: Context3d ¬ NIL, -- for shaded imaging color: BOOL ¬ FALSE, -- or black/white? rMap, gMap, bMap: SampleMap ¬ NIL, -- to buffer image lights: LightSequence ¬ NIL, -- lights for shaded images frameSize: IntegerPair ¬ [400, 300], -- render size unixSpawn: REF SpawnData ¬ NIL, -- spawn data for Unix renderer ribMode: RIBMode ¬ spawn, -- spawn or via file annotation: BOOL ¬ FALSE, -- if annotate rendered images autoRender: BOOL ¬ FALSE, -- if render image when new view antiAliasing: BOOL ¬ FALSE, -- if anti-aliasing depthBuffering: BOOL ¬ FALSE, -- if z-buffer normalCoding: BOOL ¬ FALSE, -- if normal encoding is on textureFiltering: BOOL ¬ FALSE, -- sum area tables if true <> hitList: LIST OF NAT, -- indices into shape list <> shapes: ShapeSequence ¬ NIL, -- central shape collection selectedLight: INT ¬ -1, -- index to currently selected light selectedShape: INT ¬ -1, -- index to currently selected shape selectedVertex: INT ¬ -1, -- currently selected vertex timeTree: TimeTree ¬ NIL, -- root of the time tree focusNode: TTNode ¬ NIL, -- the currently active time tree node <> time0: REAL ¬ 0.0, -- time at first frame of animation time1: REAL ¬ 0.0, -- time at last frame of animation nFrames: NAT ¬ 0, -- number of frames in animation time: REAL ¬ 0.0, -- the current time frame: NAT ¬ 0, -- current frame of animation playbackPause: REAL ¬ 0.0, -- if positive, just run-through playback: Animation ¬ NIL, -- the current animation animations: Animations ¬ NIL, -- saved for possible playback animateIPName: ROPE ¬ NIL -- root for ip file(s) ]; <> MakeTool: PUBLIC PROC [ name: ROPE, -- name of the tool extraButtons: ButtonList ¬ NIL, -- extra buttons desired by the client extraControls: ControlList ¬ NIL, -- extra controls desired by the client controlSizes: ControlSizes ¬ [], -- adjust size of controls ops: Operations ¬ allOps, -- default operations provided by the tool client: Client ¬ [], -- client supplied data and procs nViews: NAT ¬ 1, -- number views (0 if tool only: no viewers) noOpen: BOOL ¬ FALSE, -- if noOpen, leave the viewer iconic useArcBalls: BOOL ¬ TRUE, -- arc ball for orientations, or separate controls arcBallSize: INTEGER ¬ 136, -- size in pixels of the arc ball controllers graphicsHeight: INTEGER ¬ 475, -- height of main graphics viewer icon: IconFlavor ¬ document, -- for client-supplied icon useExistingTool: BOOL ¬ FALSE, -- latch onto last moused tool, if one exists camera: CameraRep ¬ [[0, 2, 0], [], 1, 60], -- client can preset camera background: Triple ¬ [1.0, 1.0, 1.0], -- background for line drawing display typescriptHeight: INT ¬ 36, -- height of typescript (0 for no typescript) toolSettings: ToolRep ¬ []] -- client can preset tool RETURNS [t: Tool]; <> <> <> <> <> <<-- or -->> <> <> <> <<$Camera: the user has modified the viewing parameters>> <<$Moused: the user moused in the display>> <<$Sprite: the user CONTROL-moused in the display; this moves the `sprite'>> <<$Vertex: the user SHIFT-moused in the display; this locates the nearest shape vertex>> <<$DrawOps: the user selected a line-drawing operation; the display is redrawn>> <<$ShapeOps: the user selected a Shape operation; the display is redrawn>> <<$Shape: a new shape is added to the scene; the display is redrawn>> <<$Scene: the scene description is modified; the display is redrawn>> <<$Overlay: the client DrawProc is prompted for any display that is not to be buffered.>> << Whenever the display is redrawn and all mouse buttons are up, the display>> << is buffered (in view.contextBuffer), allowing a subsequent call to Restore. >> << This permits the sprite (or a client defined object), to be overlayed on a>> << (possibly complex) displayed object without redrawing the object.>> <<>> Context3dOk: PROC [t: Tool]; <> <<>> SetActiveTool: PROC [tool: Tool]; <> <<>> GetActiveTool: PROC RETURNS [Tool]; <> <<>> GetActiveClients: PROC RETURNS [LIST OF Client]; <> <<>> ToolBusy: PROC [tool: Tool] RETURNS [BOOL]; <> <<>> MaybeFork: PROC [tool: Tool, proc: ForkableProc, data: REF ANY ¬ NIL] RETURNS [forked: BOOL]; <> <> <<>> ForceFork: PROC [tool: Tool, proc: ForkableProc]; <> <<>> Stop: PROC [tool: Tool, reason: ROPE ¬ NIL, waitTilAborted: BOOL ¬ FALSE]; <> <<>> Finish: PROC [tool: Tool, reason: ROPE ¬ NIL]; <> <> MakeViews: PROC [tool: Tool, nViews: NAT] RETURNS [ViewSequence]; <> <<>> DoWithViews: PROC [tool: Tool, action: ViewProc, activeOnly: BOOL ¬ TRUE]; <> <> <<>> GetFirstActiveView: PROC [tool: Tool] RETURNS [View]; <> <<>> GetView: PROC [viewer: Viewer, tool: Tool ¬ NIL] RETURNS [View]; <> <<>> GetViewTransform: PROC [viewer: Viewer ¬ NIL, tool: Tool ¬ NIL, out: Matrix ¬ NIL] RETURNS [Matrix]; <> <<>> GetBufferedSampleMap: PROC [view: View, id: ATOM ¬ $Frame] RETURNS [SampleMap]; <> <<>> SetBufferedSampleMap: PROC [map: SampleMap, view: View, id: ATOM ¬ $Frame]; <> <<>> InvalidateViewScreens: PROC [view: View]; <> <> SetRenderView: PROC [context3d: Context3d, camera: CameraControl]; <> <<>> UpdateCamera: PROC [tool: Tool]; <> <<>> MatrixFromCamera: PROC [scale: REAL, moves, rotates: Triple, leftHanded: BOOL] RETURNS [Matrix]; <> <<>> SetCameraToIdentity: PROC [camera: CameraControl]; <> <> Buffering: TYPE ~ {single, double, default}; SetMinFPS: PROC [fps: NAT]; <> <<>> Repaint: PROC [tool: Tool, whatChanged: REF ¬ $Client, buffering: Buffering ¬ default]; <> <> <> <> <> <<>> Store: PROC [context: Context, view: View, id: ATOM ¬ $Frame]; <> <<>> Restore: PROC [context: Context, view: View, id: ATOM ¬ $Frame]; <> <<>> InvalidateVertexScreens: PROC [t: Tool, which: WhichVertices]; <> Draw: DrawProc; <> <> <> EnableClear: PROC [tool: Tool, on: BOOL]; <> SetAntiAliasing: PROC [tool: Tool, antiAliasing: BOOL]; <> <<>> SetDepthBuffering: PROC [tool: Tool, depthBuffering: BOOL]; <> SetNormalCoding: PROC [tool: Tool, normalBuffering: BOOL]; <> <<>> Render: PROC [tool: Tool, fork: BOOL ¬ TRUE]; <> <> <> <<>> RenderFromCamera: PROC [ context3d: Context3d, context: Context, camera: CameraControl, fork: BOOL ¬ TRUE]; <> <<>> RenderToFile: PROC [ context3d: Context3d, camera: CameraControl, fileName: ROPE, width: NAT ¬ 1024, height: NAT ¬ 768, fork: BOOL ¬ TRUE]; <> <> <<>> WriteProc: TYPE ~ PROC [rope: ROPE] RETURNS [continue: BOOL ¬ TRUE]; WriteRIBtoFile: PROC [tool: Tool, fileName: ROPE]; <> WriteRIBtoStream: PROC [tool: Tool, out: IO.STREAM]; <> ToRIB: PROC [ imageName: ROPE ¬ NIL, frameSize: G3dBasic.IntegerPair, color: BOOL, scale, fieldOfView: REAL, moves, rotates: Triple, shapes: G3dShape.ShapeSequence, lights: G3dLight.LightSequence, writer: WriteProc, comment: ROPE ¬ NIL]; <> <> <> ReadFromShapeFile: PROC [tool: Tool, name: ROPE, autoScale: BOOL ¬ FALSE] RETURNS [err: ROPE ¬ NIL]; <> AddShape: PROC [tool: Tool, shape: Shape]; <> <<>> DeleteShape: PROC [tool: Tool, name: ROPE]; <> <<>> DeleteShapeEntry: PROC [tool: Tool, shapeID: NAT]; <> <<>> ChooseShape: PROC [t: Tool, header: ROPE ¬ NIL] RETURNS [choice: INT]; <> <<>> DoWithSelectedShapes: PROC [shapes: ShapeSequence, proc: ShapeProc, choice: INT]; <> <<-2: no op, -1: apply to all shapes; else, apply to shapes[choice].>> <<>> SelectShape: PROC [t: Tool, s: Shape, mb: Controls.MouseButton ¬ none]; <> <> <> <> <> <> <> <> <> <<>> GetShape: PROC [t: Tool, name: ROPE] RETURNS [Shape]; <> <<>> GetSelectedShape: PROC [t: Tool] RETURNS [Shape]; <> <<>> GetSelectedLight: PROC [t: Tool] RETURNS [Light]; <> <<>> SaveShape: PROC [s: Shape]; <> <<>> RestoreShape: PROC [s: Shape]; <> <<>> PrepareForDrawing: PROC [tool: Tool]; <> <> <<>> ShapePoint: TYPE ~ RECORD [shape, point: INTEGER ¬ -1]; ScreenPick: PROC [tool: Tool, viewer: Viewer, screen: IntegerPair] RETURNS [ShapePoint]; <> <> LightOptions: PROC [lights: LightSequence, eyeView: Triple, ts: Typescript] RETURNS [LightSequence]; <> <> <> <> <> <> <> <> <> Mouse: MouseProc; <> Controller: ControlProc; <> IOOpsButton: ClickProc; <> <<>> LightOpsButton: ClickProc; <> <<>> TextureOpsButton: ClickProc; <> <<>> ShapeOpsButton: ClickProc; <> <<>> DrawOpsButton: ClickProc; <> <<>> RenderOpsButton: ClickProc; <> <<>> SceneOpsButton: ClickProc; <> AnimateOpsButton: ClickProc; <> AbortButton: ClickProc; <> <<>> HelpButton: ClickProc; <> <<>> FinishButton: ClickProc; <> <<>> StopButton: ClickProc; <> <> StartTimer: PROC [tool: Tool]; <> <<>> ElapsedTime: PROC [tool: Tool] RETURNS [seconds: REAL]; <> PrintElapsedTime: PROC [tool: Tool, elapsedTime: REAL ¬ 0.0, action: ROPE ¬ NIL]; <> <> <> OpenHelp: PROC [key: ROPE]; <> <<>> TSWrite: PROC [tool: Tool, message: ROPE]; <> <<>> SetCursor: PROC [tool: Tool, waiting: BOOL]; <> <> LeftRight: TYPE ~ {left, right}; Traversal: TYPE ~ {selfOnly, childrenOnly, selfAndChildren}; ParentObjectNode: PROC [node: TTNode] RETURNS [parent: TTNode]; <> <<>> Sibling: PROC [node: TTNode, which: LeftRight] RETURNS [TTNode]; <> <<>> DoWithShape: PROC [node: TTNode, action: ShapeProc, traversal: Traversal ¬ selfAndChildren]; <> <<>> SelectNodeShapes: PROC [node: TTNode, traversal: Traversal ¬ selfAndChildren]; <> <<>> PropagateShapeMatrices: PROC [node: TTNode]; <> <> TransformAndPropagateNode: PROC [ node: TTNode, matrix: Matrix, order: TransformOrder]; <> <> <> ChangeShapeFromMenu: PROC [t: Tool, s: Shape]; <> <<>> CleanAllShapes: PROC [t: Tool]; <> <<>> CleanShape: PROC [s: Shape]; <> <<>> LatchAllShapes: PROC [t: Tool]; <> <<>> LatchShape: PROC [s: Shape]; <> <<>> END.