DIRECTORY Atom, G2dBasic, G3dBasic, G3dMatrix, G3dQuaternion, IO, Rope; G3dShape: CEDAR DEFINITIONS ~ BEGIN Error: SIGNAL [code: ATOM, reason: ROPE]; PropList: TYPE ~ Atom.PropList; Box2d: TYPE ~ G2dBasic.Box; IntegerPair: TYPE ~ G2dBasic.IntegerPair; Box3d: TYPE ~ G3dBasic.Box; NatSequence: TYPE ~ G3dBasic.NatSequence; Pair: TYPE ~ G3dBasic.Pair; PairSequence: TYPE ~ G3dBasic.PairSequence; Quad: TYPE ~ G3dBasic.Quad; Ray: TYPE ~ G3dBasic.Ray; RealSequence: TYPE ~ G3dBasic.RealSequence; Screen: TYPE ~ G3dBasic.Screen; Sphere: TYPE ~ G3dBasic.Sphere; SurfaceSequence: TYPE ~ G3dBasic.SurfaceSequence; Triple: TYPE ~ G3dBasic.Triple; TripleSequence: TYPE ~ G3dBasic.TripleSequence; Matrix: TYPE ~ G3dMatrix.Matrix; Viewport: TYPE ~ G3dMatrix.Viewport; Quaternion: TYPE ~ G3dQuaternion.Quaternion; STREAM: TYPE ~ IO.STREAM; ROPE: TYPE ~ Rope.ROPE; zAxis: Ray ~ [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]; Shape: TYPE ~ REF ShapeRep; ShapeRep: TYPE ~ RECORD [ renderData: REF ¬ NIL, -- rendering params/procs, (see G3dRender) modelData: REF ¬ NIL, -- modeling parameters (see G3dModel) hierarchyData: REF ¬ NIL, -- node within hierarchy (see G3dTimeTrees) clientData: REF ¬ NIL, -- data for a client name: ROPE ¬ NIL, -- local shape name (allows instancing) fileName: ROPE ¬ NIL, -- file name props: PropList ¬ NIL, -- for extensibility centroid: Triple ¬ [], -- vertex average scale: REAL ¬ 1.0, -- scale of the object translation: Triple ¬ [], -- within a scene orientation: Quaternion ¬ [], -- rotation (degrees) about an axis rotationBase: Triple ¬ [], -- origin point of axis of rotation matrix: Matrix ¬ NIL, -- within world space; presumed always valid visible: BOOL ¬ TRUE, -- display shape or not? centroidValid: BOOL ¬ FALSE, -- centroid computed? renderValid: BOOL ¬ FALSE, -- are vertex normals, etc. valid? showBackfaces: BOOL ¬ FALSE, -- if back facing polygons to be displayed triangulated: BOOL ¬ FALSE, -- all surfaces are three-sided normalsNegated: BOOL ¬ FALSE, -- if file vertex normals negated surfacesReversed: BOOL ¬ FALSE, -- if file surfaces order reversed verticesIsolated: BOOL ¬ FALSE, -- if vertices have been isolated selected: BOOL ¬ FALSE, -- true if chosen sphereExtent: Sphere ¬ [], -- center and radius of bounding sphere objectExtent: Box3d ¬ [], -- 3d bounds vertices: VertexSequence ¬ NIL, -- vertices used by the renderer type: ATOM ¬ $ConvexPolygon, -- patches, polygons, or other faces: FaceSequence ¬ NIL, -- polygon normals, colors, and transmittances surfaces: SurfaceSequence ¬ NIL, -- vertex connectivity (polygons or patches) edges: EdgeSequence ¬ NIL -- for fast line drawing and other operations ]; Validity: TYPE ~ {normal, color, texture, transmit, center}; ShapeSequence: TYPE ~ REF ShapeSequenceRep; ShapeSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Shape ]; ShapeProc: TYPE ~ PROC [shape: Shape] RETURNS [continue: BOOL ¬ TRUE]; SurfaceProc: TYPE ~ PROC [surface: NatSequence, index: INTEGER] RETURNS [continue: BOOL ¬ TRUE]; Vertex: TYPE ~ REF VertexRep; VertexRep: TYPE ~ RECORD [ -- 31 words point: Triple ¬ [], -- 6 words: location of vertex normal: Triple ¬ [], -- 6 words: surface normal color: Triple ¬ [1, 1, 1], -- 6 words: color of surface texture: Pair ¬ [0.0, 0.0], -- 4 words: texture coordinates transmittance: REAL ¬ 1.0, -- 2 words: transmittance of surface ref: REF ¬ NIL -- 2 words: client data ]; VertexSequence: TYPE ~ REF VertexSequenceRep; VertexSequenceRep: TYPE ~ RECORD [ valid: ARRAY Validity OF BOOL ¬ ALL[FALSE], length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Vertex ]; VertexProc: TYPE ~ PROC [vertex: Vertex, index: INTEGER] RETURNS [continue: BOOL ¬ TRUE]; ScreenSequence: TYPE ~ REF ScreenSequenceRep; ScreenSequenceRep: TYPE ~ RECORD [ screensValid: BOOL ¬ FALSE, extentValid: BOOL ¬ FALSE, extent: Box2d ¬ [[0, 0], [0, 0]], -- 2d bounds (depends on view, device) length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Screen ]; Face: TYPE ~ REF FaceRep; FaceRep: TYPE ~ RECORD [ -- 22 words normal: Triple ¬ [], -- 6 words: surface normal center: Triple ¬ [], -- 6 words: center of surface color: Triple ¬ [1, 1, 1], -- 6 words: color of surface transmittance: REAL ¬ 1.0, -- 2 words: transmittance of surface fwdFacing: BOOL ¬ FALSE, -- 1 bit: is this face forward facing? ref: REF ¬ NIL -- 2 words: client data ]; FaceSequence: TYPE ~ REF FaceSequenceRep; FaceSequenceRep: TYPE ~ RECORD [ valid: ARRAY Validity OF BOOL ¬ ALL[FALSE], length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Face ]; Edge: TYPE ~ REF EdgeRep; EdgeRep: TYPE ~ RECORD [ v0, v1: INTEGER ¬ -1, -- vertex indices, v0 < v1 p0, p1: INTEGER ¬ -1 -- polygon indices ]; EdgeSequence: TYPE ~ REF EdgeSequenceRep; EdgeSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Edge ]; ShapeFromFile: PROC [fileName: ROPE] RETURNS [Shape]; ShapeFromStream: PUBLIC PROC [stream: STREAM] RETURNS [Shape]; ShapeToFile: PROC [ fileName: ROPE, shape: Shape, index: BOOL ¬ FALSE, tallyOnPolys: BOOL ¬ FALSE, comment: ROPE ¬ NIL]; ShapeToStream: PROC [ shape: Shape, out: STREAM, index: BOOL ¬ FALSE, tallyOnPolys: BOOL ¬ FALSE]; ShapeToStreamPerFormat: PROC [shape: Shape, out: STREAM, format: ATOM] RETURNS [success: BOOL]; ShapeFromData: PROC [ name: ROPE ¬ NIL, surfaces: SurfaceSequence, vertices: TripleSequence, normals: TripleSequence ¬ NIL, colors: TripleSequence ¬ NIL, transmittances: RealSequence ¬ NIL, textures: PairSequence ¬ NIL, showBackfaces: BOOL ¬ TRUE, faceted: BOOL ¬ FALSE, type: ATOM ¬ $ConvexPolygon] RETURNS [Shape]; CopyShape: PROC [shape: Shape] RETURNS [Shape]; CombineShapes: PROC [shape1, shape2: Shape] RETURNS [Shape]; ComputeMatrix: PROC [shape: Shape]; SetMatrix: PROC [shape: Shape, matrix: Matrix]; TransformShape: PROC [ shape: Shape, translate: Triple ¬ [], axis: Ray ¬ zAxis, rotation: REAL ¬ 0, scale: REAL ¬ 1.0, concat: BOOL ¬ FALSE]; TransformVertices: PROC [shape: Shape, matrix: Matrix]; ApplyTransformsToShape: PUBLIC PROC [shape: Shape]; DoWithVertices: PROC [shape: Shape, vertexProc: VertexProc]; VertexValid: PROC [shape: Shape, test: Validity] RETURNS [BOOL]; SetVertexNormals: PROC [shape: Shape]; SetFwdFacingVertices: PROC [shape: Shape, view: Matrix, screens: ScreenSequence]; UnitizeVertexNormals: PROC [shape: Shape]; NegateVertexNormals: PROC [shape: Shape]; NumberOfVertices: PROC [shapes: ShapeSequence] RETURNS [INTEGER]; SetExtent: PROC [screens: ScreenSequence]; InterpolateVertex: PROC [t: REAL, v0, v1: Vertex] RETURNS [v: Vertex]; DoWithAllPolygons: PROC [shape: Shape, action: SurfaceProc]; DoWithFacingPolygons: PROC [ shape: Shape, view: Matrix, frontFacingAction, backFacingAction: SurfaceProc ¬ NIL]; FaceValid: PROC [shape: Shape, test: Validity] RETURNS [BOOL]; SetFwdFacingFaces: PROC [shape: Shape, view: Matrix]; GetPolygonPoints: PROC [shape: Shape, nPoly: INTEGER, points: TripleSequence ¬ NIL] RETURNS [TripleSequence]; SetFaceNormals: PROC [shape: Shape, complyWithVertices: BOOL ¬ TRUE]; SetFaceCenters: PROC [shape: Shape]; UnitizeFaceNormals: PROC [shape: Shape]; ReversePolygons: PROC [shape: Shape]; NegateFaceNormals: PROC [shape: Shape]; Triangulate: PROC [shape: Shape]; NumberOfPolygons: PROC [shapes: ShapeSequence] RETURNS [INTEGER]; MakeEdges: PROC [shape: Shape] RETURNS [EdgeSequence]; FindEdge: PROC [edges: EdgeSequence, v0, v1: INTEGER] RETURNS [index: INT]; ObjectScale: PROC [shape: Shape] RETURNS [REAL]; PointsFromShape: PROC [shape: Shape, points: TripleSequence ¬ NIL] RETURNS [TripleSequence]; FindShape: PROC [shapes: ShapeSequence, shapeName: ROPE] RETURNS [Shape]; SetTextureCoords: PROC [shape: Shape, textures: PairSequence]; BoundingBox: PROC [shape: Shape] RETURNS [Box3d]; BoundingSphere: PROC [shape: Shape] RETURNS [Sphere]; CopyShapeSequence: PROC [shapes: ShapeSequence] RETURNS [ShapeSequence]; AddToShapeSequence: PROC [shapes: ShapeSequence, shape: Shape] RETURNS [ShapeSequence]; LengthenShapeSequence: PROC [shapes: ShapeSequence, amount: REAL ¬ 1.3] RETURNS [ShapeSequence]; CopyVertexSequence: PROC [vertices: VertexSequence] RETURNS [VertexSequence]; AddToVertexSequence: PROC [vertices: VertexSequence, vertex: Vertex] RETURNS [VertexSequence]; LengthenVertexSequence: PROC [vertices: VertexSequence, amount: REAL ¬ 1.3] RETURNS [VertexSequence]; CopyFaceSequence: PROC [faces: FaceSequence] RETURNS [FaceSequence]; AddToFaceSequence: PROC [faces: FaceSequence, face: Face] RETURNS [FaceSequence]; LengthenFaceSequence: PROC [faces: FaceSequence, amount: REAL ¬ 1.3] RETURNS [FaceSequence]; END. ή G3dShape.mesa Copyright Σ 1985, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, October 21, 1992 5:00 pm PDT Crow, May 5, 1989 4:55:50 pm PDT Errors Imported Types and Constants Shape Types Data for rendering, modeling, organizing, and the client Bookkeeping Transformation State Interaction Bounds Vertices Surfaces Edges Vertex Types The default vertex is transparent, and is scaled by a global transmission factor defaulted to 0. This allows affect by global transmission whereas a default transmission of 0 would not. Screen Types Polygon Types Edge Types An edge sequence is presumed ordered: edges[i].v0 < edges[i+1].v0. File IO Return the shape given in the file. Return the shape given the input file stream. Write the shape to the given file. If index, add indexing for vertices and polygons. If tallyOnPolys, write the polygon length for each polygon before the vertex ids. If comment not NIL, write comment after the keyword "Comment ." Write the shape to the given stream. If index, add indexing for vertices and polygons. If tallyOnPolys, write the polygon length for each polygon before the vertex ids. Write the shape to the stream per the specified format. See G3dShapeImpl.mesa for supported formats. Creation Create a shape from the supplied data. If faceted, then colors are applied to surfaces (facets) rather than vertices. Copying/Combining Return a copy of the input shape. Everything defined in this definitions file is physically duplicated, so changes to a copy won't affect the original. RenderData, modelData and clientData are copied as pointers. Code specific to those fields should treat them as it sees fit. Return a shape that is a combination of the two input shapes. Coincident vertices and redundant polygons are not culled. Transformations Set shape.matrix based on shape.position, orientation, and scale. Set shape.matrix to be matrix. Places the local origin of shape at absolute position in world space. Apply a rotation (in degrees) to the shape around the given axis. Note the axis need not pass through [0, 0, 0]. This does not modify vertex fields. If concat, concatenate the transform to the current matrix; otherwise, begin with identity. Modify the vertex locations and normals by the given matrix. Call TransformVertices, set the shape's matrix to identity, and recompute bounding sphere and box. Set validities to force recomputation of face information if needed later. Vertex Procedures Apply vertexProc to each of the shape's vertices. Test the given vertex attribute for validity. Compute the vertex normal as an average of the surrounding face normals. Computes face normals if not previously computed. Set the fwdFacing boolean for each vertex, depending on whether the vertex belongs to a forward facing polygon or not. Set the shape vertex normals to unit length. Invert the direction of the vertex normals. Return sum of all vertices in all shapes; Recompute screens.extent. Return a vertex linearly interpolated such that v = v0+t*(v1-v0). Interpolates normal, color, and texture if non-zero. Polygon Procedures Apply action to all polygons. Apply frontFacingAction (if non-NIL) to front facing polygons. Apply backFacingAction (if non-NIL) to back facing polygons. Test the given face attribute for validity. Set the fwdFacing boolean for each of shape.faces. Return the vertices of the nPolyth polygon. Set the face normals for the polygons, assuming shape.pts or shape.vertices is defined. If complyWithVertices and shape.vertices # NIL, then the face normals are inverted, if necessary, to face in the same half plane as their first vertex. Set the face centers for the polygons. Set the shape face normals to unit length. Reverse the ordering of the polygons and negate the face normals. Invert the direction of the face normals. Convert the shape's polygons into triangles. Return sum of all polygons in all shapes. Edge Procedures Return the non-duplicating edges of a points-polygons shape. Return index so that edges[index].v0 = MIN[v0,v1] and edges[index].v1 = MAX[v0,v1]; return -1 if no such index exists. Miscellany Return the scale necessary to fit the shape into a +1/-1 range. Return the locations of shape.vertices, using points if non-NIL. Finds the shape with the given name; return NIL if no such shape. Assign the texture coordinates to the shape's vertices. Bounds Return the bounding box for the given shape. Return the bounding sphere for the given shape. Sequences Return a copy of the input sequence of shapes. This does not allocate new shapes. Add shape to the sequence. Return a copy of the input sequence whose maxLength is amount*input.maxLength. Return a copy of the input sequence of vertices. This does not allocate new vertices. Add vertex to the sequence. Return a copy of the input sequence whose maxLength is amount*input.maxLength. Return a copy of the input sequence of faces. This does not allocate new faces. Add face to the sequence. Return a copy of the input sequence whose maxLength is amount*input.maxLength. Κ]–"cedarcode" style•NewlineDelimiter ™™ Jšœ Οeœ6™BJ™)J™ J˜JšΟk œ>˜GJ˜—JšΠblœžœž ˜Jšœž˜headšΟl™Jšœž œžœ žœ˜-—š ™Jšœ žœ˜"Jšœž œ˜Jšœ žœ˜+Jšœž œ˜Jšœ žœ˜+Jšœž œ˜Jšœ žœ˜,Jšœž œ˜Jšœž œ˜Jšœ žœ˜,Jšœžœ˜"Jšœžœ˜"Jšœžœ˜1Jšœžœ˜"Jšœžœ˜0Jšœžœ˜#Jšœ žœ˜'Jšœ žœ˜.Jšžœžœžœžœ˜šžœžœžœ˜J˜—J˜4—š  ™ Jšœž œžœ ˜šœ žœžœ˜šΟz8™8Jšœ žœžœΟc*˜FJšœ žœžœ’%˜@Jšœžœžœ’Πcs’#˜IJšœ žœžœ’˜0—š‘ ™ Jšœ žœžœ’'˜@Jšœ žœžœ’ ˜(Jšœžœ’˜1—š‘™Jšœ’˜.Jšœ žœ ’˜0Jšœ’˜0Jšœ!’#˜DJšœ ’#˜CJšœžœ’,˜G—š‘™Jšœ žœžœ’˜3Jšœžœžœ’˜5Jšœžœžœ’"˜AJšœžœžœ’*˜JJšœžœžœ’˜?Jšœžœžœ’!˜BJšœžœžœ’"˜DJšœžœžœ’!˜D—š‘ ™ Jšœ žœžœ’˜.—š‘™Jšœ’'˜FJšœ’ ˜+—š‘™Jšœžœ’ ˜C—š‘™Jšœ žœΟs œ’˜?Jšœžœ’.˜MJšœžœ’,˜P—š‘™Jšœžœ’-˜K—J˜J™—š œ žœ €œ€œ€œ˜?J˜—Jšœžœžœ˜,šœžœžœ˜!Jšœžœ˜Jšœžœ žœžœ˜3J˜J˜—š œ žœžœžœ žœžœ˜HJ˜—šœžœžœžœ˜AJšœžœ žœžœ˜(——š  ™ J˜Jšœ žœžœ ˜ šœ žœžœ’ ˜-Jšœ’˜:Jšœ’˜6Jšœ!’˜=Jšœ"’˜AJšœžœ ’$˜DJšœ žœžœ’˜.J˜J™`™XJ˜——Jšœžœžœ˜.šœžœžœ˜"Jšœ ž€œ€ž€ž€œ€žœžœ˜1Jšœžœ˜Jšœžœ žœžœ˜4J˜J˜—šœžœžœžœ˜:Jšœžœ žœžœ˜(——š  ™ Jšœžœžœ˜.šœžœžœ˜"Jšœžœžœ˜Jšœžœžœ˜Jšœ'’&˜MJšœ žœ˜Jšœžœ žœžœ˜4J˜——š  ™ Jšœ žœžœ ˜šœ žœžœ’ ˜,Jšœ’˜6Jšœ’˜9Jšœ!’˜=Jšœžœ ’$˜DJšœžœžœ’&˜DJšœ žœžœ’˜.˜J˜——Jšœžœžœ˜*šœžœžœ˜ Jš œ žœ žœžœžœžœ˜1Jšœžœ˜Jšœžœ žœžœ˜2J˜——š  ™ Jšœžœžœ ˜šœ žœžœ˜Jšœ žœ’˜5Jšœ žœ’˜,J˜J™—Jšœžœžœ˜*šœžœžœ˜ Jšœžœ˜Jšœ ž œ žœžœ˜2J˜J™B——š ™šΟn œžœ žœžœ ˜5J™#J™—š ₯œžœžœ žœžœ ˜>J™-J˜—š₯ œžœ˜Jšœ žœ˜J˜ Jšœžœžœ˜Jšœžœžœ˜Jšœ žœžœ˜J™UJ™QJšœ€œ-™?J™—š₯ œžœ˜J˜ Jšœžœ˜ Jšœžœžœ˜Jšœžœžœ˜J™WJ™QJ™—š₯œžœžœ žœ˜FJšžœ žœ˜J™7J™,——š ™š₯ œžœ˜Jšœžœžœ˜J˜J˜Jšœžœ˜Jšœžœ˜Jšœžœ˜#Jšœžœ˜Jšœžœžœ˜Jšœ žœžœ˜Jšœžœ˜Jšžœ ˜J™&J™N——š ™š₯ œžœžœ ˜/Jš’5œβ™—J™—š₯ œžœžœ ˜Jšœ€œ™J™+J™—š₯œžœ˜5Jšœ2™2J™—š₯œžœžœžœ˜SJšžœ˜Jšœ Οuœ ™,J™—š₯œžœ$žœžœ˜EJ™WJšœ+€œ%™SJ™CJ™—š₯œžœ˜$J™&J™—š₯œžœ˜(J™*J™—š₯œžœ˜%J™AJ™—š₯œžœ˜'J™)J™—š₯ œžœ˜!J™,J™—š₯œžœžœžœ˜AJ™)——š ™š₯ œžœžœ˜6J™J™7——š ™š₯ œžœžœ ˜1J™,J™—š₯œžœžœ ˜5J™/——š  ™ š₯œžœžœ˜HJ™RJ™—š₯œžœ&˜>Jšžœ˜J™J™—š₯œžœ!žœ˜GJšžœ˜J™NJ˜—š₯œžœžœ˜MJ™VJ™—š₯œžœ+˜DJšžœ˜J™J™—š₯œžœ$žœ˜KJšžœ˜J™NJ™—š ₯œ€ž€œ€œ €ž€œ˜DJ™PJ˜—š₯œžœ"žœ˜QJ™J™—š₯œžœžœ˜DJšžœ˜J™N——J˜Jšžœ˜J˜J˜—…—#<Ew