DIRECTORY CSGGraphics, DisplayList3d, GraphicsColor, IO, Matrix3d, Rope, SV2d, SVArtwork, SVMappings, SVMatrix2d, SVPolygon3d, TFO3d; TFO3dImpl: PROGRAM IMPORTS CSGGraphics, GraphicsColor, IO, SVArtwork EXPORTS TFO3d = BEGIN Assembly: TYPE = DisplayList3d.Assembly; Box: TYPE = SVMappings.Box; Color: TYPE = GraphicsColor.Color; DrawStyle: TYPE = CSGGraphics.DrawStyle; Point2d: TYPE = SV2d.Point2d; FileCamera: TYPE = DisplayList3d.FileCamera; FrameBox: TYPE = CSGGraphics.FrameBox; Material: TYPE = SVArtwork.Material; Matrix3by3: TYPE = SVMatrix2d.Matrix3by3; Matrix4by4: TYPE = Matrix3d.Matrix4by4; OMap: TYPE = SVArtwork.OMap; Plane: TYPE = SVPolygon3d.Plane; Point3d: TYPE = Matrix3d.Point3d; Tube: TYPE = SVMappings.Tube; SMap: TYPE = SVArtwork.SMap; FileoutBOOL: PUBLIC PROC [f: IO.STREAM, bool: BOOL] = { IF bool THEN f.PutRope["TRUE"] ELSE f.PutRope["FALSE"]; }; FileoutMatrix: PUBLIC PROC [f: IO.STREAM, mat: Matrix4by4] = { f.PutF["[[%g",[real[mat[1][1]]]]; FOR j: NAT IN[2..4] DO f.PutF[",%g",[real[mat[1][j]]]]; ENDLOOP; f.PutF["]"]; FOR i: NAT IN[2..3] DO f.PutF[", [%g",[real[mat[i][1]]]]; FOR j: NAT IN[2..4] DO f.PutF[",%g",[real[mat[i][j]]]]; ENDLOOP; f.PutF["]"]; ENDLOOP; f.PutF["]"]; }; FileoutMatrix3by3: PUBLIC PROC [f: IO.STREAM, mat: Matrix3by3] = { f.PutF["[[%g",[real[mat[1][1]]]]; FOR j: NAT IN[2..3] DO f.PutF[",%g",[real[mat[1][j]]]]; ENDLOOP; f.PutF["]"]; f.PutF[", [%g",[real[mat[2][1]]]]; FOR j: NAT IN[2..3] DO f.PutF[",%g",[real[mat[2][j]]]]; ENDLOOP; f.PutF["]]"]; }; FileoutPoint3d: PUBLIC PROC [f: IO.STREAM, point3d: Point3d] = { f.PutF["[%g,%g,%g]",[real[point3d[1]]],[real[point3d[2]]],[real[point3d[3]]]]; }; FileoutPoint3dAsPoint2d: PUBLIC PROC [f: IO.STREAM, point3d: Point3d] = { f.PutF["[%g,%g]",[real[point3d[1]]],[real[point3d[2]]]]; }; FileoutColor: PUBLIC PROC [f: IO.STREAM, color: Color] = { r, g, b: REAL; [r, g, b] _ GraphicsColor.ColorToRGB[color]; f.PutF["[%g,%g,%g]",[real[r]], [real[g]], [real[b]]]; }; FileoutSurface: PUBLIC PROC [f: IO.STREAM, surface: REF ANY] = { IF surface = NIL THEN f.PutF["NIL"] ELSE { WITH surface SELECT FROM tube: Tube => f.PutF["tube [radius: %g, height: %g]", [real[tube.R]], [real[tube.H]]]; box: Box =>{ f.PutF["box "]; FileoutPoint3d[f, [box.x, 2*box.halfY, box.z]]; }; ENDCASE => ERROR; }; }; FileoutMaterial: PUBLIC PROC [f: IO.STREAM, material: Material] = { matRope: Rope.ROPE; matRope _ SVArtwork.MaterialToRope[material]; f.PutRope[matRope]; }; FileoutSMap: PUBLIC PROC [f: IO.STREAM, sMap: SMap] = { mapRope: Rope.ROPE; mapRope _ SVArtwork.SMapToRope[sMap]; f.PutRope[mapRope]; }; FileoutOMap: PUBLIC PROC [f: IO.STREAM, oMap: OMap] = { mapRope: Rope.ROPE; mapRope _ SVArtwork.OMapToRope[oMap]; f.PutRope[mapRope]; }; FileoutCamera: PUBLIC PROC [f: IO.STREAM, fileCamera: FileCamera] = { f.PutRope["Camera: "]; f.PutRope[fileCamera.name]; f.PutRope[" origin: "]; FileoutPoint3d[f, fileCamera.origin]; f.PutRope[" focusPoint: "]; FileoutPoint3d[f, fileCamera.focusPoint]; f.PutF[" slant: %g", [real[fileCamera.slant]]]; f.PutChar[IO.CR]; f.PutF["resolution: %g", [real[fileCamera.resolution]]]; f.PutF[" focalLength: %g", [real[fileCamera.focalLength]]]; f.PutChar[IO.CR]; f.PutRope[" frame: "]; FileoutFrame[f, fileCamera.frame]; f.PutChar[IO.CR]; f.PutRope["clippingPlanes: "]; FileoutClippingPlanes[f, fileCamera.clippingPlanes]; f.PutChar[IO.CR]; f.PutRope["visibleAssemblies: "]; FileoutListOfRope[f, fileCamera.visibleAssemblies]; f.PutChar[IO.CR]; }; FileoutClippingPlanes: PUBLIC PROC [f: IO.STREAM, clippingPlanes: LIST OF Plane] = { firstPlane: Plane; IF clippingPlanes = NIL THEN RETURN; firstPlane _ clippingPlanes.first; FileoutPlane[f, firstPlane]; FOR list: LIST OF Plane _ clippingPlanes.rest, list.rest UNTIL list = NIL DO f.PutChar[',]; FileoutPlane[f, list.first]; ENDLOOP; }; CountClippingPlanes: PROC [clippingPlanes: LIST OF Plane] RETURNS [count: NAT] = { count _ 0; FOR list: LIST OF Plane _ clippingPlanes, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutPlane: PUBLIC PROC [f: IO.STREAM, plane: Plane] = { f.PutF["[%g,%g,%g,%g]", [real[plane.A]], [real[plane.B]], [real[plane.C]], [real[plane.D]]]; }; FileoutStyle: PUBLIC PROC [f: IO.STREAM, style: DrawStyle] = { styleRope: Rope.ROPE _ CSGGraphics.DrawStyleToRope[style]; f.PutRope[styleRope]; }; FileoutFrame: PUBLIC PROC [f: IO.STREAM, frame: FrameBox] = { f.PutChar['[]; FileoutPoint2d[f, [frame.downLeft[1], frame.upRight[2]]]; f.PutRope[", "]; FileoutPoint2d[f, [frame.upRight[1], frame.downLeft[2]]]; f.PutRope[" fullScreen: "]; FileoutBOOL[f, frame.fullScreen]; f.PutChar[']]; }; FileoutPoint2d: PUBLIC PROC [f: IO.STREAM, point2d: Point2d] = { f.PutF["[%g,%g]", [real[point2d[1]]], [real[point2d[2]]]]; }; FileoutListOfRope: PUBLIC PROC [f: IO.STREAM, ropeList: LIST OF Rope.ROPE] = { IF ropeList = NIL THEN RETURN; f.PutRope[ropeList.first]; FOR list: LIST OF Rope.ROPE _ ropeList.rest, list.rest UNTIL list = NIL DO f.PutRope[", "]; f.PutRope[list.first]; ENDLOOP; }; FileoutVisibleAssemblies: PUBLIC PROC [f: IO.STREAM, assemblyList: LIST OF Assembly] = { IF assemblyList = NIL THEN RETURN; f.PutRope[assemblyList.first.name]; FOR list: LIST OF Assembly _ assemblyList.rest, list.rest UNTIL list = NIL DO f.PutRope[", "]; f.PutRope[list.first.name]; ENDLOOP; }; END. bFile: TFO3dImpl.mesa Last edited by Bier on August 12, 1983 11:56 am Contents: Useful functions for creating text files to describe 3d objects and scenes. (used by Fileout3dImpl, BasicObject3dImpl and intended for use by programs which define other master objects to implement their FileoutProc [see DisplayList3d]). Only writes the first 2 rows. Κ8– "cedar" style˜Iheadšœ™Iprocšœ/™/Lšœψ™ψL˜šΟk ˜ Lšœ ˜ Lšœ˜Lšœ˜Lšœ˜Lšœ ˜ Lšœ˜Lšœ˜Lšœ ˜ Lšœ ˜ Lšœ ˜ L˜ Lšœ˜—L˜šœ ˜Lšœœ ˜1Lšœ˜—L˜Lš˜˜Lšœ œ˜(Lšœœ˜Lšœœ˜"Lšœ œ˜(Lšœ œ˜Lšœ œ˜,Lšœ œ˜&Lšœ œ˜$Lšœ œ˜)Lšœ œ˜'Lšœœ˜Lšœœ˜ Lšœ œ˜!Lšœœ˜Lšœœ˜L˜š Οn œœœœœœ˜7Lšœœœ˜7L˜L˜—š ž œœœœœ˜>Lšœ!˜!šœœœ˜Lšœ ˜ —Lšœ˜Lšœ ˜ šœœœ˜Lšœ"˜"šœœœ˜Lšœ ˜ —Lšœ˜Lšœ ˜ —Lšœ˜Lšœ ˜ Lšœ˜—L˜š žœœœœœ˜BLšœ™Lšœ!˜!šœœœ˜Lšœ ˜ —Lšœ˜Lšœ ˜ Lšœ"˜"šœœœ˜Lšœ ˜ —Lšœ˜Lšœ ˜ Lšœ˜—L˜š žœœœœœ˜@LšœN˜NLšœ˜—L˜š žœœœœœ˜ILšœ8˜8Lšœ˜—L˜L˜š ž œœœœœ˜:Lšœ œ˜Lšœ,˜,Lšœ5˜5Lšœ˜—L˜šžœœœœœ œœ˜@Lšœ œœ˜#šœ˜šœ œ˜LšœAœœ˜VLšœ˜Lšœ/˜/Lšœ˜Lšœœ˜—Lšœ˜—Lšœ˜—L˜š žœœœœœ˜CLšœœ˜Lšœ-˜-Lšœ˜Lšœ˜—L˜š ž œœœœœ˜7Lšœœ˜Lšœ%˜%Lšœ˜Lšœ˜—L˜š ž œœœœœ˜7Lšœœ˜Lšœ%˜%Lšœ˜Lšœ˜—š œž œœœœœ˜FLšœ˜Lšœ˜Lšœ˜Lšœ%˜%Lšœ˜Lšœ)˜)Lšœ/˜/Lšœ œœ˜Lšœ8˜8Lšœ;˜;Lšœ œœ˜Lšœ˜Lšœ"˜"Lšœ œœ˜Lšœ˜Lšœ4˜4Lšœ œœ˜L˜L˜!Lšœ3˜3Lšœ œœ˜L˜Lšœ˜—šžœœœœœœœ ˜TLšœ˜Lšœœœœ˜$Lšœ"˜"Lšœ˜š œœœ(œœ˜LL˜Lšœ˜—Lšœ˜L˜—š žœœœœœ œ˜RLšœ ˜ š œœœ#œœ˜GLšœ˜—Lšœ˜Lšœ˜—š ž œœœœœ˜:Lš œ$œœœœ˜\L˜—š ž œœœœœ˜>Lšœœ&˜:Lšœ˜L˜—š ž œœœœœ˜=L˜Lšœ9˜9L˜Lšœ9˜9Lšœ˜Lšœ!˜!L˜L˜—š žœœœœœ˜@Lšœ:˜:L˜—šžœœœœœ œœœ˜NLšœ œœœ˜Lšœ˜š œœœœœœ˜JL˜Lšœ˜—Lšœ˜L˜—šžœœœœœœœ˜XLšœœœœ˜"Lšœ#˜#š œœœ)œœ˜ML˜Lšœ˜—Lšœ˜Lšœ˜——Lšœ˜—…—ΊT