DIRECTORY Args, Atom, Commander, G3dBasic, G3dMatrix, G3dQuaternion, G3dRender, G3dShape, G3dSpline, G3dTimeTrees, IO, Random, Rope, ViewerClasses, ViewerTools; G3dScene: CEDAR DEFINITIONS ~ BEGIN Arg: TYPE ~ Args.Arg; PropList: TYPE ~ Atom.PropList; Handle: TYPE ~ Commander.Handle; Pair: TYPE ~ G3dBasic.Pair; Triple: TYPE ~ G3dBasic.Triple; Matrix: TYPE ~ G3dMatrix.Matrix; MatrixSequence: TYPE ~ G3dMatrix.MatrixSequence; SplineSequence: TYPE ~ G3dSpline.SplineSequence; Quaternion: TYPE ~ G3dQuaternion.Quaternion; Context3d: TYPE ~ G3dRender.Context3d; RenderStyle: TYPE ~ G3dRender.RenderStyle; Shape: TYPE ~ G3dShape.Shape; ShapeSequence: TYPE ~ G3dShape.ShapeSequence; TimeTree: TYPE ~ G3dTimeTrees.TimeTree; STREAM: TYPE ~ IO.STREAM; RandomStream: TYPE ~ Random.RandomStream; ROPE: TYPE ~ Rope.ROPE; Viewer: TYPE ~ ViewerClasses.Viewer; WriteCameraParameters: PROC [context3d: Context3d]; WriteParameters: PROC [context3d: Context3d, fileName: ROPE ¬ NIL]; WriteParametersToStream: PROC [context3d: Context3d, out: STREAM]; MakeFrameFromFile: PROC [context3d: Context3d, fileName: ROPE]; ReadParameters: PROC [context3d: Context3d, fileName: ROPE ¬ NIL, cmdOut: STREAM ¬ NIL] RETURNS [shouldRepaint: BOOL]; LogProc: TYPE ~ PROC [rope: ROPE, clientData: REF ANY]; WriteLog: PROC [ps: ParseState, msg: ROPE]; Parse: PROC [ context3d: Context3d, operation: ROPE, cmdOut: STREAM ¬ NIL, logProc: LogProc ¬ NIL, logErrors: BOOL ¬ TRUE, fileName: ROPE ¬ NIL, clientData: REF ANY ¬ NIL, parseState: ParseState ¬ NIL] RETURNS [ParseState]; InheritMaterial: PROC [ps: ParseState]; SaveCurrentShapeInTree: PROC [ps: ParseState]; SceneProc: TYPE ~ PROC [ps: ParseState, args: ROPE, data: REF ANY]; Registry: TYPE ~ LIST OF RECORD [key: ROPE, proc: SceneProc, data: REF ANY]; SourceText: TYPE ~ REF SourceTextRep; SourceTextRep: TYPE ~ RECORD [ fileName: ROPE ¬ NIL, position: INT ¬ 0 ]; ParseState: TYPE ~ REF ParseStateRep; ParseStateRep: TYPE ~ RECORD [ fileName: ROPE ¬ NIL, -- originating scene file (if any) index: INT ¬ 0, -- character position within scene file errorMessage: ROPE ¬ NIL, -- if any errors encountered errorViewer: Viewer ¬ NIL, -- viewer for displaying parse errors cmdHandle: Handle ¬ NIL, -- for Cedar command execution nesting: NAT ¬ 0, -- nesting of parse calls directory: ROPE ¬ NIL, -- working directory shouldRepaint: BOOL ¬ FALSE, -- operations necessitated a repaint? logProc: LogProc ¬ NIL, -- for logging operations clientData: REF ANY ¬ NIL, -- passed to registered procs context3d: Context3d ¬ NIL, -- rendering information command: ROPE ¬ NIL, -- currently executing command (key) currentShape: Shape ¬ NIL, -- currently active shape currentMaterial: Material ¬ [], -- currently active surface attributes ctm: Matrix ¬ NIL, -- current transformation matrix buildData: REF ANY ¬ NIL, -- state data for G3dBuild routines timeTree: TimeTree ¬ NIL, -- hiearchy with animation info changes: PropList ¬ NIL, -- what's changed in this key inKey: BOOL ¬ FALSE, -- TRUE when we're creating keys matrixStack: LIST OF Matrix ¬ NIL, -- matrix stack for pusing/popping randomStream: RandomStream ¬ NIL, -- for pseudo-variables materials: MaterialSequence ¬ NIL, -- accumulated surface attributes variables: VariableSequence ¬ NIL -- accumulated key-substitute pairs ]; Material: TYPE ~ RECORD [ name: ROPE ¬ NIL, backFaces: BOOL ¬ FALSE, renderStyle: RenderStyle ¬ smooth, color: Triple ¬ [0.7, 0.7, 0.7], diffuseReflectivity: REAL ¬ 1.0, specularReflectivity: REAL ¬ 1.0, metallicity: REAL ¬ 1.0, shininess: REAL ¬ 50.0, transmittance: REAL ¬ 0.0, visible: BOOL ¬ TRUE, textureOffset: Pair ¬ [0.0, 0.0], textureScale: Pair ¬ [1.0, 1.0], bumpScale: REAL ¬ 1.0, textureFiltering: BOOL ¬ FALSE, textureIntensityName: ROPE ¬ NIL, textureColorName: ROPE ¬ NIL, textureBumpName: ROPE ¬ NIL ]; MaterialSequence: TYPE ~ REF MaterialSequenceRep; MaterialSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Material ]; Variable: TYPE ~ RECORD [name, value: ROPE ¬ NIL]; VariableSequence: TYPE ~ REF VariableSequenceRep; VariableSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Variable ]; ParseError: ERROR [explanation: ROPE]; RegisterProc: PROC [key: ROPE, proc: SceneProc, data: REF ANY ¬ NIL]; UnregisterProc: PROC [key: ROPE]; GetRegistry: PROC RETURNS [Registry]; ResetRegistry: PROC; MakeTransformNode: PROC [ps: ParseState]; MakeKeysNode: PROC [ps: ParseState]; MakeShapeNode: PROC [ps: ParseState]; AssignCtmToShape: PROC [ps: ParseState, shape: Shape]; GetArgs: PROC [ps: ParseState, input, format: ROPE] RETURNS [Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg,Arg]; SubstituteVariables: PROC [ variables: VariableSequence, input: ROPE, rs: RandomStream ¬ NIL] RETURNS [out: ROPE]; LookupVariable: PROC [variables: VariableSequence, name: ROPE] RETURNS [ROPE]; END.   G3dScene.mesa Copyright Σ 1988, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 15, 1992 11:31 pm PDT Glassner, June 25, 1990 4:00:32 pm PDT Type Declarations Write Scene Descriptions to a File or Viewer Write the camera parameters to the primary selection. Write all the relevant parameters of the context3d to the specified file. If fileName = NIL, obtain it from the current mouse selection. If fileName = NIL and no fileName selected by the mouse, write to the primary selection. Write all the relevant parameters of the context3d to the output stream. Read Scene Descriptions from a File or Viewer Display a scene described in fileName, without altering context3d. Set context3d parameters based on the scene description. If fileName = NIL, obtain it from the current mouse selection. If fileName = NIL and no name selected with the mouse, read parameters from the primary selection. Parsing a Scene Description Send the message to the log, if a logProc has been assigned to ps. Perform the specified operation on the context3d. operation consists of an arbitrary number of operations: each operation is a keyword followed by arguments, if required. Only registered operations (see below) and a short number of internally defined operations are supported; see the graphics 3d documentation for the standard list of operations. If logProc # NIL, a message is written for each operation parsed. If logErrors, any errors encountered are printed in an error viewer. If fileName # NIL, it is used when printing errors. a parseState may be given for continuity between calls on Parse; otherwise one is allocated. Support for Shape Creation Assign the material information in ps.currentMaterial to the shape in ps.currentShape Save the active shape in the TimeTree associated with ps. Registering Procedures Callable from a Scene File book-keeping: 3d context3d: current attributes: build state: animation support: accumulated state: Procedures registered with the global registry may raise this error, output to a log file results. Register the proc as callable from a scene file under the name "key;" arguments following key (up to a carriage-return) are passed to proc, as is data. Proc must be a top level procedure and, naturally, must be registered before it is called. Remove the registered proc from the registry. Return the global registry. Set the global registry to NIL. TimeTree Node Construction Create a transform node in ps.timeTree if needed Create a keys node in ps.timeTree if needed Create a shape node in ps.timeTree if needed Utility Procs for Registered SceneProcs Assign the matrix at the top of the stack to the shape. Like Args.ArgsGetFromRope, but replaces all variable names in the input with their values before evaluation. In the specified rope replace all variable names with their values. Return the value of the variable with the given name. If no such variable exists, return the name itself as the value. Κw•NewlineDelimiter –"cedarcode" style™™ Jšœ Οeœ6™BJ™'J™&J˜JšΟk œ—˜ J˜—JšΠblœžœž ˜Jšœž˜headšΟl™Jšœžœ ˜Jšœ žœ˜!Jšœ žœ˜"Jšœžœ˜Jšœ žœ˜!Jšœ žœ˜"Jšœžœ˜0Jšœžœ˜0Jšœ žœ˜-Jšœ žœ˜'Jšœ žœ˜+Jšœžœ˜Jšœžœ˜-Jšœ žœ˜(Jšžœžœžœžœ˜Jšœžœ˜)Jšžœžœžœ˜Jšœ žœ˜&—š ,™,šΟnœžœ˜3J™5J™—š‘œžœ"žœžœ˜CJšœI™IJšœΟsœ-™>Jšœ’œG™XJ™—š‘œžœžœ˜BJšœH™H——š -™-š‘œžœ"žœ˜?JšœB™BJ™—š ‘œžœ"žœžœ žœžœ˜WJšžœžœ˜Jšœ8™8Jšœ’œ=’œ™XJšœI™I——š ™š œ žœžœžœžœžœ˜7J˜—š‘œžœžœ˜+J™BJ™—š‘œžœ˜ Jšœ˜Jšœ žœ˜Jšœžœžœ˜Jšœžœ˜Jšœ žœžœ˜Jšœ žœžœ˜Jšœ žœžœžœ˜Jšœžœ˜Jšžœ˜J˜Jšœ1™1šœ8™8Jšœ?™?—™ZJ™U—Jšœ ’œ1™AJ™DJšœ’œ"™3J™\——š ™š‘œžœ˜'J™U—J˜š‘œžœ˜.J™9——š 1™1Jš œ žœžœžœžœžœ˜DJšœ žœžœžœžœžœžœžœ˜NJšœ žœžœ˜&šœžœžœ˜Jšœžœžœ˜Jšœžœ˜J˜J˜—Jšœ žœžœ˜&šœžœžœ˜™ Jšœ žœžœΟc"˜?Jšœ žœ £'˜@Jšœžœžœ£˜;Jšœžœ£%˜EJšœžœ£˜(U