<> <> <> <> DIRECTORY BasicObject3d, CoordSys, Imager, IO, Matrix3d, ObjectCast, PredefSweeps, Rope, SV2d, SV3d, SVBasicTypes, SVBoundBox, SVBoundSphere, SVDraw3d, SVFaces, SVModelTypes, SVPolygon2d, SVPolygon3d, SVRayTypes, SVScene, SVSceneTypes, SweepCast, SweepGeometry, TFI3d, TFO3d; BasicObject3dImpl: CEDAR PROGRAM IMPORTS CoordSys, SVScene, IO, Matrix3d, ObjectCast, PredefSweeps, SVBoundBox, SVBoundSphere, SVDraw3d, SVPolygon2d, SVPolygon3d, SweepCast, SweepGeometry, TFI3d, TFO3d EXPORTS BasicObject3d = BEGIN <> BoundHedron: TYPE = SVBasicTypes.BoundHedron; Camera: TYPE = SVModelTypes.Camera; Cone: TYPE = SVFaces.Cone; Cylinder: TYPE = SVFaces.Cylinder; DiskRing: TYPE = SVFaces.DiskRing; LinearMesh: TYPE = REF LinearMeshRecord; LinearMeshArray: TYPE = SweepGeometry.LinearMeshArray; LinearMeshRecord: TYPE = SweepGeometry.LinearMeshRecord; Matrix4by4: TYPE = SV3d.Matrix4by4; Path: TYPE = SV2d.Path; Point2d: TYPE = SV2d.Point2d; Poly3d: TYPE = SV3d.Poly3d; Polygon: TYPE = SV2d.Polygon; RevoFace: TYPE = SweepCast.RevoFace; RevoluteMesh: TYPE = REF RevoluteMeshRecord; RevoluteMeshArray: TYPE = SweepGeometry.RevoluteMeshArray; RevoluteMeshRecord: TYPE = SweepGeometry.RevoluteMeshRecord; Shape: TYPE = SVSceneTypes.Shape; SubBoxesBody: TYPE = REF SubBoxesBodyObj; SubBoxesBodyObj: TYPE = SweepCast.SubBoxesBodyObj; SubSpheresBody: TYPE = REF SubSpheresBodyObj; SubSpheresBodyObj: TYPE = SweepCast.SubSpheresBodyObj; ToroidalMesh: TYPE = REF ToroidalMeshRecord; ToroidalMeshRecord: TYPE = SweepGeometry.ToroidalMeshRecord; <> BoundBox: TYPE = SVBasicTypes.BoundBox; CoordSystem: TYPE = SVModelTypes.CoordSystem; LightSourceList: TYPE = SVModelTypes.LightSourceList; PlanarSurface: TYPE = SVSceneTypes.PlanarSurface; PlanarSurfaceList: TYPE = SVSceneTypes.PlanarSurfaceList; <> Assembly: TYPE = SVSceneTypes.Assembly; Classification: TYPE = SVRayTypes.Classification; Composite: TYPE = SVRayTypes.Composite; MasterObject: TYPE = SVSceneTypes.MasterObject; MasterObjectClass: TYPE = SVSceneTypes.MasterObjectClass; MasterObjectClassList: TYPE = SVSceneTypes.MasterObjectClassList; -- LIST OF MasterObjectClass Primitive: TYPE = SVRayTypes.Primitive; Ray: TYPE = SVRayTypes.Ray; RayCastProc: TYPE = SVRayTypes.RayCastProc; PreprocessProc: TYPE = SVSceneTypes.PreprocessProc; LineDrawProc: TYPE = SVSceneTypes.LineDrawProc; NormalsDrawProc: TYPE = SVSceneTypes.NormalsDrawProc; CountPlanarSurfacesProc: TYPE = SVSceneTypes.CountPlanarSurfacesProc; GetPlanarSurfacesProc: TYPE = SVSceneTypes.GetPlanarSurfacesProc; DrawPlanarSurfaceProc: TYPE = SVSceneTypes.DrawPlanarSurfaceProc; DrawSubBoxesProc: TYPE = SVSceneTypes.DrawSubBoxesProc; SurfaceArray: TYPE = REF SurfaceArrayObj; SurfaceArrayObj: TYPE = SVRayTypes.SurfaceArrayObj; RectSurface: TYPE = REF RectSurfaceObj; RectSurfaceObj: TYPE = ObjectCast.RectSurfaceObj; TubeSurface: TYPE = REF TubeSurfaceObj; TubeSurfaceObj: TYPE = ObjectCast.TubeSurfaceObj; DiskSurface: TYPE = REF DiskSurfaceObj; DiskSurfaceObj: TYPE = ObjectCast.DiskSurfaceObj; ShellSurface: TYPE = REF ShellSurfaceObj; ShellSurfaceObj: TYPE = ObjectCast.ShellSurfaceObj; ConeSurface: TYPE = REF ConeSurfaceObj; ConeSurfaceObj: TYPE = ObjectCast.ConeSurfaceObj; ToroidalSurface: TYPE = REF ToroidalSurfaceObj; ToroidalSurfaceObj: TYPE = ObjectCast.ToroidalSurfaceObj; <> SphereRec: TYPE = REF SphereRecObj; SphereRecObj: TYPE = BasicObject3d.SphereRecObj; BlockRec: TYPE = REF BlockRecObj; BlockRecObj: TYPE = BasicObject3d.BlockRecObj; CylinderRec: TYPE = REF CylinderRecObj; CylinderRecObj: TYPE = BasicObject3d.CylinderRecObj; ConeRec: TYPE = REF ConeRecObj; ConeRecObj: TYPE = BasicObject3d.ConeRecObj; TorusRec: TYPE = REF TorusRecObj; TorusRecObj: TYPE = BasicObject3d.TorusRecObj; RevoSweepRec: TYPE = REF RevoSweepRecObj; RevoSweepRecObj: TYPE = RECORD [ path: Path ]; <> <<>> sphereClass, blockClass, cylinderClass, coneClass, torusClass, linClass, revoClass: MasterObjectClass; WrongTypeOfData: PUBLIC SIGNAL = CODE; SphereBody: PROC RETURNS [sphereRec: SphereRec] = { sphereRec _ NEW[SphereRecObj]; sphereRec.radius _ 1; }; SphereMakeMasterObject: PUBLIC PROC [name: Rope.ROPE] RETURNS [mo: MasterObject] = { mainBody: SphereRec _ SphereBody[]; lineBody: REF ANY _ PredefSweeps.GetUnitSphere[]; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ SphereGetRayCastBody[]; mo _ SVScene.CreateMasterObject[name, sphereClass, mainBody, lineBody, shadeBody, rayCastBody]; }; SphereUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { mo.lineBody _ PredefSweeps.GetUnitSphere[]; mo.shadeBody _ mo.lineBody; mo.rayCastBody _ SphereGetRayCastBody[]; }; SphereBoundHedron: PUBLIC PROC [mo: MasterObject] RETURNS [hedron: BoundHedron] = { hedron _ SVBoundBox.HexagonalBoundHedron[1, 1]; }; SphereGetRayCastBody: PROC [] RETURNS [shellS: ShellSurface] = { shellS _ NEW[ShellSurfaceObj]; }; SphereRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.SphereCast[localRay, NARROW[mo.rayCastBody], prim]]; }; SphereRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.SphereCast[localRay, NARROW[mo.rayCastBody], prim]]; }; SphereRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.SphereCast[localRay, NARROW[mo.rayCastBody], prim]]; }; SphereLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawRevoluteSweep[dc, revMesh, camera, localCS]; }; <> <> <> <> <> <> <<};>> SphereDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { CirclePath: Imager.PathProc = { moveTo[[-1.0, 0.0]]; arcTo[[1.0, 0.0], [-1.0, 0.0]]; }; revMesh: RevoluteMesh; linesOfLatitude, linesOfLongitude: NAT; deltaTheta: REAL; transform, csCamera: Matrix4by4; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; linesOfLatitude _ revMesh.linesOfLatitude; linesOfLongitude _ revMesh.linesOfLongitude; transform _ csCamera _ CoordSys.FindInTermsOfCamera[localCS, camera.coordSys]; SVDraw3d.DrawTransformedShape[dc: dc, csCAMERA: transform, camera: camera, path: CirclePath]; deltaTheta _ 360.0/linesOfLongitude; FOR i: NAT IN [1..linesOfLongitude-1] DO transform _ Matrix3d.LocalRotateAboutYAxis[transform, deltaTheta]; SVDraw3d.DrawTransformedShape[dc: dc, csCAMERA: transform, camera: camera, path: CirclePath]; ENDLOOP; transform _ csCamera; transform _ Matrix3d.LocalRotateAboutXAxis[transform, 90]; SVDraw3d.DrawTransformedShape[dc: dc, csCAMERA: transform, camera: camera, path: CirclePath]; <> <<>> <> }; SphereCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh]; }; SphereCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesRevoluteSweep[revMesh]; }; SphereGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, assembly, camera]; }; SphereDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera]; }; SphereFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { TFI3d.ReadRope[f, "data: procedural"]; TFI3d.ReadBlank[f]; mo _ SphereMakeMasterObject[name]; }; SphereFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { <> f.PutChar[IO.TAB]; f.PutF["data: procedural\n"]; }; SphereFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { revMesh: RevoluteMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListRevolute[f, revMesh]; }; BlockBody: PROC RETURNS [blockRec: BlockRec] = { blockRec _ NEW[BlockRecObj]; blockRec.x _ 2; blockRec.y _ 2; blockRec.z _ 2; }; BlockMakeMasterObject: PUBLIC PROC [name: Rope.ROPE] RETURNS [mo: MasterObject] = { mainBody: BlockRec _ BlockBody[]; lineBody: REF ANY _ PredefSweeps.GetUnitCube[]; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ BlockGetRayCastBody[]; mo _ SVScene.CreateMasterObject[name, blockClass, mainBody, lineBody, shadeBody, rayCastBody]; }; BlockUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = {}; BlockBoundHedron: PUBLIC PROC [mo: MasterObject] RETURNS [hedron: BoundHedron] = { hedron _ SVBoundBox.RectangularBoundHedron[2, 2, 2]; }; BlockGetRayCastBody: PROC [] RETURNS [surfaceArray: SurfaceArray] = { upS, downS, frontS, backS, rightS, leftS: RectSurface; surfaceArray _ NEW[SurfaceArrayObj]; upS _ NEW[RectSurfaceObj _ [up]]; downS _ NEW[RectSurfaceObj _ [down]]; frontS _ NEW[RectSurfaceObj _ [front]]; backS _ NEW[RectSurfaceObj _ [back]]; rightS _ NEW[RectSurfaceObj _ [right]]; leftS _ NEW[RectSurfaceObj _ [left]]; surfaceArray[1] _ upS; surfaceArray[2] _ downS; surfaceArray[3] _ frontS; surfaceArray[4] _ backS; surfaceArray[5] _ rightS; surfaceArray[6] _ leftS; }; -- end of BlockGetRayCastBody BlockRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.BlockCast[localRay, NARROW[mo.rayCastBody], prim]]; }; BlockRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.BlockCast[localRay, NARROW[mo.rayCastBody], prim]]; }; BlockRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.BlockCast[localRay, NARROW[mo.rayCastBody], prim]]; }; BlockLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { linMesh: LinearMesh; IF ISTYPE[data, LinearMesh] THEN linMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawLinearSweep[dc, linMesh, camera, localCS]; }; BlockDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { linMesh: LinearMesh; IF ISTYPE[data, LinearMesh] THEN linMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsLinearSweep[dc, linMesh, camera, localCS]; }; BlockCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesLinearSweep[linMesh]; }; BlockCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesLinearSweep[linMesh]; }; BlockGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesLinearSweep[linMesh, assembly, camera]; }; BlockDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceLinearSweep[dc, ps, lightSources, camera]; }; BlockFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { TFI3d.ReadRope[f, "data: procedural"]; TFI3d.ReadBlank[f]; mo _ BlockMakeMasterObject[name]; }; BlockFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { <> f.PutF["data: procedural\n"]; }; BlockFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { linMesh: LinearMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListLinear[f, linMesh]; }; CylinderBody: PROC RETURNS [cylinderRec: CylinderRec] = { cylinderRec _ NEW[CylinderRecObj]; cylinderRec.radius _ 1; cylinderRec.height _ 2; }; CylinderMakeMasterObject: PUBLIC PROC [name: Rope.ROPE] RETURNS [mo: MasterObject] = { mainBody: CylinderRec _ CylinderBody[]; lineBody: REF ANY _ PredefSweeps.GetUnitCylinder[]; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ CylinderGetRayCastBody[]; mo _ SVScene.CreateMasterObject[name, cylinderClass, mainBody, lineBody, shadeBody, rayCastBody]; }; CylinderUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { mo.lineBody _ PredefSweeps.GetUnitCylinder[]; mo.shadeBody _ mo.lineBody; mo.rayCastBody _ CylinderGetRayCastBody[]; }; CylinderBoundHedron: PUBLIC PROC [mo: MasterObject] RETURNS [hedron: BoundHedron] = { hedron _ SVBoundBox.HexagonalBoundHedron[1,1]; }; CylinderGetRayCastBody: PROC [] RETURNS [surfaceArray: SurfaceArray] = { topS, bottomS: DiskSurface; tubeS: TubeSurface; surfaceArray _ NEW[SurfaceArrayObj]; topS _ NEW[DiskSurfaceObj _ [top]]; bottomS _ NEW[DiskSurfaceObj _ [bottom]]; tubeS _ NEW[TubeSurfaceObj]; surfaceArray[1] _ topS; surfaceArray[2] _ bottomS; surfaceArray[3] _ tubeS; }; -- end of CylinderGetRayCastBody CylinderRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.CylinderCast[localRay, NARROW[mo.rayCastBody], prim]]; }; CylinderRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.CylinderCast[localRay, NARROW[mo.rayCastBody], prim]]; }; CylinderRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.CylinderCast[localRay, NARROW[mo.rayCastBody], prim]]; }; CylinderLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawRevoluteSweep[dc, revMesh, camera, localCS]; }; CylinderDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsRevoluteSweep[dc, revMesh, camera, localCS]; }; CylinderCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh]; }; CylinderCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesRevoluteSweep[revMesh]; }; CylinderGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, assembly, camera]; }; CylinderDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera]; }; CylinderFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { TFI3d.ReadRope[f, "data: procedural"]; TFI3d.ReadBlank[f]; mo _ CylinderMakeMasterObject[name]; }; CylinderFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { <> f.PutF["data: procedural\n"]; }; CylinderFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { revMesh: RevoluteMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListRevolute[f, revMesh]; }; ConeBody: PROC RETURNS [coneRec: ConeRec] = { coneRec _ NEW[ConeRecObj]; coneRec.radius _ 1; coneRec.height _ 1; }; ConeMakeMasterObject: PUBLIC PROC [name: Rope.ROPE] RETURNS [mo: MasterObject] = { mainBody: ConeRec _ ConeBody[]; lineBody: REF ANY _ PredefSweeps.GetUnitCone[]; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ ConeGetRayCastBody[]; mo _ SVScene.CreateMasterObject[name, coneClass, mainBody, lineBody, shadeBody, rayCastBody]; }; ConeUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { mo.lineBody _ PredefSweeps.GetUnitCone[]; mo.shadeBody _ mo.lineBody; mo.rayCastBody _ ConeGetRayCastBody[]; }; ConeBoundHedron: PUBLIC PROC [mo: MasterObject] RETURNS [hedron: BoundHedron] = { hedron _ SVBoundBox.HexPyramidBoundHedron[1,1]; }; ConeGetRayCastBody: PROC [] RETURNS [surfaceArray: SurfaceArray] = { coneS: ConeSurface; diskS: DiskSurface; surfaceArray _ NEW[SurfaceArrayObj]; coneS _ NEW[ConeSurfaceObj]; diskS _ NEW[DiskSurfaceObj]; surfaceArray[1] _ coneS; surfaceArray[2] _ diskS; }; -- end of ConeGetRayCastBody ConeRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.ConeCast[localRay, NARROW[mo.rayCastBody], prim]];}; ConeRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.ConeCast[localRay, NARROW[mo.rayCastBody], prim]];}; ConeRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; RETURN[ObjectCast.ConeCast[localRay, NARROW[mo.rayCastBody], prim]];}; ConeLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawRevoluteSweep[dc, revMesh, camera, localCS]; }; ConeDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsRevoluteSweep[dc, revMesh, camera, localCS]; }; ConeCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh]; }; ConeCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesRevoluteSweep[revMesh]; }; ConeGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, assembly, camera]; }; ConeDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera]; }; ConeFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { TFI3d.ReadRope[f, "data: procedural"]; TFI3d.ReadBlank[f]; mo _ ConeMakeMasterObject[name]; }; ConeFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { <> f.PutF["data: procedural\n"]; }; ConeFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { revMesh: RevoluteMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListRevolute[f, revMesh]; }; TorusBody: PROC [bigRadius: REAL, sectionRadius: REAL] RETURNS [torusRec: TorusRec] = { torusRec _ NEW[TorusRecObj]; torusRec.bigRadius _ bigRadius; torusRec.sectionRadius _ sectionRadius; }; TorusMakeMasterObject: PUBLIC PROC [name: Rope.ROPE, bigRadius: REAL, sectionRadius: REAL] RETURNS [mo: MasterObject] = { mainBody: TorusRec _ TorusBody[bigRadius, sectionRadius]; lineBody: REF ANY _ PredefSweeps.CreateTorus[mainBody.bigRadius, mainBody.sectionRadius]; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ TorusGetRayCastBody[]; mo _ SVScene.CreateMasterObject[name, torusClass, mainBody, lineBody, shadeBody, rayCastBody]; }; TorusUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { mainBody: TorusRec _ NARROW[mo.mainBody]; mo.lineBody _ PredefSweeps.CreateTorus[mainBody.bigRadius, mainBody.sectionRadius]; mo.shadeBody _ mo.lineBody; mo.rayCastBody _ TorusGetRayCastBody[]; }; TorusBoundHedron: PUBLIC PROC [mo: MasterObject] RETURNS [hedron: BoundHedron] = { torusRec: TorusRec _ NARROW[mo.mainBody]; hedron _ SVBoundBox.HexagonalBoundHedron[torusRec.bigRadius + torusRec.sectionRadius, torusRec.sectionRadius]; }; TorusGetRayCastBody: PROC [] RETURNS [surfaceArray: SurfaceArray] = { torusS: ToroidalSurface; surfaceArray _ NEW[SurfaceArrayObj]; torusS _ NEW[ToroidalSurfaceObj]; surfaceArray[1] _ torusS; }; -- end of TorusGetRayCastBody TorusRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; surfaceArray: SurfaceArray _ NARROW[mo.rayCastBody]; RETURN[ObjectCast.ToroidCast[localRay, prim, mo.mainBody, surfaceArray[1]]]; }; TorusRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; surfaceArray: SurfaceArray _ NARROW[mo.rayCastBody]; RETURN[ObjectCast.ToroidCast[localRay, prim, mo.mainBody, surfaceArray[1]]]; }; TorusRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; surfaceArray: SurfaceArray _ NARROW[mo.rayCastBody]; RETURN[ObjectCast.ToroidCast[localRay, prim, mo.mainBody, surfaceArray[1]]]; }; TorusLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { torMesh: ToroidalMesh; IF ISTYPE[data, ToroidalMesh] THEN torMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawToroidalSweep[dc, torMesh, camera, localCS]; }; TorusDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { torMesh: ToroidalMesh; IF ISTYPE[data, ToroidalMesh] THEN torMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsToroidalSweep[dc, torMesh, camera, localCS]; }; TorusCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { torMesh: ToroidalMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesToroidalSweep[torMesh]; }; TorusCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { torMesh: ToroidalMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesToroidalSweep[torMesh]; }; TorusGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; torMesh: ToroidalMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesToroidalSweep[torMesh, assembly, camera]; }; TorusDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceToroidalSweep[dc, ps, lightSources, camera]; }; TorusFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { bigRadius, sectionRadius: REAL; TFI3d.ReadBlankAndRope[f, "bigRadius:"]; bigRadius _ TFI3d.ReadBlankAndReal[f]; TFI3d.ReadBlankAndRope[f, ","]; TFI3d.ReadBlankAndRope[f, "sectionRadius:"]; sectionRadius _ TFI3d.ReadBlankAndReal[f]; mo _ TorusMakeMasterObject[name, bigRadius, sectionRadius]; }; TorusFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { <> torusRec: TorusRec _ NARROW[mo.mainBody]; f.PutF["bigRadius: %g, sectionRadius: %g\n", [real[torusRec.bigRadius]], [real[torusRec.sectionRadius]] ]; };-- end of TorusFileout TorusFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { torMesh: ToroidalMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListToroidal[f, torMesh]; }; LinSweepMakeMasterObject: PUBLIC PROC [name: Rope.ROPE, linMesh: LinearMesh] RETURNS [mo: MasterObject] = { mainBody: REF ANY _ NIL; lineBody: REF ANY _ linMesh; shadeBody: REF ANY _ lineBody; rayCastBody: REF ANY _ LinSweepGetRayCastBody[linMesh]; mo _ SVScene.CreateMasterObject[name, linClass, mainBody, lineBody, shadeBody, rayCastBody]; }; LinSweepUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { }; LinSweepBoundHedron: PUBLIC PROC [masterObject: MasterObject] RETURNS [hedron: BoundHedron] = { linMesh: LinearMesh _ NARROW[masterObject.lineBody]; vertCount: NAT _ 2*linMesh.len; hedron _ SVBoundBox.CreateBoundHedron[vertCount]; FOR i: NAT IN[1..linMesh.len] DO FOR j: NAT IN[1..2] DO SVBoundBox.AddBoundHedronPoint[hedron, linMesh.array[i][j]]; ENDLOOP; ENDLOOP; }; LinSweepFaces: TYPE = SweepCast.LinSweepFaces; LinSweepHint: TYPE = REF LinSweepHintObj; LinSweepHintObj: TYPE = RECORD [linMesh: LinearMesh, faces: LinSweepFaces]; LinSweepGetRayCastBody: PROC [linMesh: LinearMesh] RETURNS [hint: LinSweepHint] = { hint _ NEW[LinSweepHintObj]; hint.linMesh _ linMesh; hint.faces _ SweepCast.MakeLinSweepFaces[linMesh]; }; GetLinSweepData: PUBLIC PROC RETURNS [linMesh: LinearMesh] = { linMesh _ PredefSweeps.GetUnitCube[];-- for now. }; LinSweepRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: LinSweepHint _ NARROW[mo.rayCastBody]; class _ SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces]; }; LinSweepRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: LinSweepHint _ NARROW[mo.rayCastBody]; class _ SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces]; }; LinSweepRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: LinSweepHint _ NARROW[mo.rayCastBody]; class _ SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces]; }; LinSweepLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { linMesh: LinearMesh; IF ISTYPE[data, LinearMesh] THEN linMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawLinearSweep[dc, linMesh, camera, localCS]; }; LinSweepDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { linMesh: LinearMesh; IF ISTYPE[data, LinearMesh] THEN linMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsLinearSweep[dc, linMesh, camera, localCS]; }; LinSweepCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesLinearSweep[linMesh]; }; LinSweepCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesLinearSweep[linMesh]; }; LinSweepGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; linMesh: LinearMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesLinearSweep[linMesh, assembly, camera]; }; LinSweepDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceLinearSweep[dc, ps, lightSources, camera]; }; LinearFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { linMesh: LinearMesh _ NARROW[mo.lineBody]; lma: LinearMeshArray _ linMesh.array; len: NAT _ linMesh.len; f.PutF["name: %g\n",[rope[mo.name]]]; <> f.PutF["frontDepth: %g, backDepth: %g\n",[real[lma[1][1][3]]],[real[lma[1][2][3]]]]; f.PutF["DataPoints [%g]: ",[integer[len]]]; FOR i: NAT IN[1..len-1] DO TFO3d.FileoutPoint3dAsPoint2d[f, lma[i][1]]; f.PutF[","]; ENDLOOP; TFO3d.FileoutPoint3dAsPoint2d[f, lma[len][1]]; f.PutChar[IO.CR]; }; LinearFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { count: NAT; frontDepth, backDepth: REAL; poly: Polygon; instanceName: Rope.ROPE; linMesh: LinearMesh; TFI3d.ReadRope[f, "name:"]; instanceName _ TFI3d.ReadBlankAndWord[f]; TFI3d.ReadBlankAndRope[f, "frontDepth:"]; frontDepth _ TFI3d.ReadBlankAndReal[f]; TFI3d.ReadBlankAndRope[f, ","]; TFI3d.ReadBlankAndRope[f, "backDepth:"]; backDepth _ TFI3d.ReadBlankAndReal[f]; TFI3d.ReadBlankAndRope[f, "DataPoints ["]; count _ TFI3d.ReadNAT[f]; TFI3d.ReadBlankAndRope[f, "]:"]; TFI3d.ReadBlank[f]; poly _ SVPolygon2d.CreatePoly[count]; FOR i: NAT IN[1..count-1] DO poly _ SVPolygon2d.PutPolyPoint[poly, i-1, TFI3d.ReadPoint2d[f]]; TFI3d.ReadBlankAndRope[f, ","]; TFI3d.ReadBlank[f]; ENDLOOP; poly _ SVPolygon2d.PutPolyPoint[poly, count-1, TFI3d.ReadPoint2d[f]]; TFI3d.ReadBlank[f]; linMesh _ SweepGeometry.LinearSweep[poly, frontDepth, backDepth]; mo _ LinSweepMakeMasterObject[name, linMesh]; }; LinearFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { linMesh: LinearMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListLinear[f, linMesh]; }; RevoSweepMakeMasterObject: PUBLIC PROC [name: Rope.ROPE, path: Path, long: NAT] RETURNS [mo: MasterObject] = { mainBody: RevoSweepRec _ NEW[RevoSweepRecObj _ [path: path]]; lineBody: REF ANY; shadeBody: REF ANY; rayCastBody: REF ANY; revMesh: RevoluteMesh; revMesh _ SweepGeometry.RevoluteSweep[path, long]; lineBody _ revMesh; shadeBody _ lineBody; rayCastBody _ RevoSweepGetRayCastBody[revMesh]; mo _ SVScene.CreateMasterObject[name, revoClass, mainBody, lineBody, shadeBody, rayCastBody]; }; RevoSweepUpdate: PUBLIC PROC [mo: MasterObject, updateData: REF ANY] = { revMesh: RevoluteMesh; mainBody: RevoSweepRec _ NARROW[mo.mainBody]; path: Path _ mainBody.path; revMesh _ SweepGeometry.RevoluteSweep[path, PredefSweeps.GetLinesOfLongitude[]]; mo.lineBody _ revMesh; mo.shadeBody _ mo.lineBody; mo.rayCastBody _ RevoSweepGetRayCastBody[revMesh]; }; RevoSweepBoundHedron: PUBLIC PROC [masterObject: MasterObject] RETURNS [hedron: BoundHedron] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; vertCount: NAT _ revMesh.linesOfLatitude*6;-- hexagons*6 hex: Poly3d; hedron _ SVBoundBox.CreateBoundHedron[vertCount]; FOR i: NAT IN[1..revMesh.linesOfLatitude] DO <> hex _ SVPolygon3d.CircumHexagon[revMesh.array[i][1][2], revMesh.array[i][revMesh.linesOfLongitude][1]]; SVBoundBox.AddBoundHedronPoly[hedron, hex]; ENDLOOP; }; RevoSweepHint: TYPE = REF RevoSweepHintObj; RevoSweepHintObj: TYPE = RECORD [ boxes: SubBoxesBody, spheres: SubSpheresBody]; RevoSweepFaces: TYPE = SweepCast.RevoSweepFaces; RevoSweepRayCastBody: TYPE = REF RevoSweepRayCastBodyObj; RevoSweepRayCastBodyObj: TYPE = RECORD [faces: RevoSweepFaces]; RevoSweepGetRayCastBody: PROC [revMesh: RevoluteMesh] RETURNS [rayCastBody: RevoSweepRayCastBody] = { rayCastBody _ NEW[RevoSweepRayCastBodyObj]; rayCastBody.faces _ SweepCast.MakeRevoSweepFaces[revMesh]; }; RevoSweepRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: RevoSweepRayCastBody _ NARROW[mo.rayCastBody]; revoHint: RevoSweepHint _ NARROW[prim.hints]; RETURN[SweepCast.RevoCast[cameraPoint, localRay, prim, rayCastBody.faces, revoHint.boxes]]; <> }; RevoSweepRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: RevoSweepRayCastBody _ NARROW[mo.rayCastBody]; RETURN[SweepCast.RevoCastNoBBoxes[localRay, prim, rayCastBody.faces]]; }; RevoSweepRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, masterObject: REF ANY, prim: Primitive] RETURNS [class: Classification] = { mo: MasterObject _ NARROW[masterObject]; rayCastBody: RevoSweepRayCastBody _ NARROW[mo.rayCastBody]; revoHint: RevoSweepHint _ NARROW[prim.hints]; RETURN[SweepCast.RevoCastBoundSpheres[localRay, prim, rayCastBody.faces, revoHint.spheres]]; }; RevoSweepPreprocess: PUBLIC PROC [prim: Primitive, camera: Camera] = { revoSweepHint: RevoSweepHint _ NEW[RevoSweepHintObj]; mo: MasterObject _ NARROW[prim.mo]; rayCastBody: RevoSweepRayCastBody _ NARROW[mo.rayCastBody]; faces: RevoSweepFaces _ rayCastBody.faces; boxes: SubBoxesBody; spheres: SubSpheresBody; worldCS: CoordSystem _ camera.coordSys.parent; revoSweepHint.boxes _ NEW[SubBoxesBodyObj[faces.len]]; revoSweepHint.spheres _ NEW[SubSpheresBodyObj[faces.len]]; boxes _ revoSweepHint.boxes; spheres _ revoSweepHint.spheres; FOR i: NAT IN[0..faces.len) DO WITH faces[i] SELECT FROM cone: Cone => { boxes[i] _ SVBoundBox.BoundBoxFromBoundHedron[cone.boundHedron, camera, prim.primWRTAssembly]; spheres[i] _ SVBoundSphere.BoundSphereFromBoundHedron[cone.boundHedron, worldCS, prim.primWRTAssembly]; }; ring: DiskRing=> { boxes[i] _ SVBoundBox.BoundBoxFromBoundHedron[ring.boundHedron, camera, prim.primWRTAssembly]; spheres[i] _ SVBoundSphere.BoundSphereFromBoundHedron[ring.boundHedron, worldCS, prim.primWRTAssembly]; }; cyl: Cylinder=> { boxes[i] _ SVBoundBox.BoundBoxFromBoundHedron[cyl.boundHedron, camera, prim.primWRTAssembly]; spheres[i] _ SVBoundSphere.BoundSphereFromBoundHedron[cyl.boundHedron, worldCS, prim.primWRTAssembly]; }; ENDCASE => ERROR; ENDLOOP; spheres.len _ faces.len; boxes.len _ faces.len; prim.hints _ revoSweepHint; }; RevoSweepLineDraw: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.LineDrawRevoluteSweep[dc, revMesh, camera, localCS]; }; RevoSweepDrawNormals: PUBLIC PROC[dc: Imager.Context, data: REF ANY, camera: Camera, localCS: CoordSystem] = { revMesh: RevoluteMesh; IF ISTYPE[data, RevoluteMesh] THEN revMesh _ NARROW[data] ELSE SIGNAL WrongTypeOfData; SweepGeometry.DrawNormalsRevoluteSweep[dc, revMesh, camera, localCS]; }; RevoSweepCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh]; }; RevoSweepCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = { revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; len _ SweepGeometry.CountVerticesRevoluteSweep[revMesh]; }; RevoSweepGetSurf: PUBLIC PROC [assembly: Assembly, camera: CoordSystem] RETURNS [psl: PlanarSurfaceList] = { shape: Shape _ NARROW[assembly.shape]; masterObject: MasterObject _ shape.mo; revMesh: RevoluteMesh _ NARROW[masterObject.shadeBody]; psl _ SweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, assembly, camera]; }; RevoSweepDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = { SweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera]; }; RevoSweepDrawSubBoxes: PUBLIC PROC [dc: Imager.Context, prim: Primitive, screenCS: CoordSystem] = { revoHint: RevoSweepHint _ NARROW[prim.hints]; boxes: SubBoxesBody _ revoHint.boxes; FOR i: NAT IN [0..boxes.len) DO SVBoundBox.DrawBoundBox[dc, boxes[i], screenCS]; ENDLOOP; }; RevoSweepDrawSubSpheres: PUBLIC PROC [dc: Imager.Context, prim: Primitive, camera: Camera] = { revoHint: RevoSweepHint _ NARROW[prim.hints]; spheres: SubSpheresBody _ revoHint.spheres; FOR i: NAT IN [0..spheres.len) DO SVBoundSphere.DrawBoundSphere[dc, spheres[i], camera]; ENDLOOP; }; RevoluteFileout: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { rma: RevoluteMeshArray; revMesh: RevoluteMesh _ NARROW[mo.lineBody]; lat, long: NAT; rma _ revMesh.array; lat _ revMesh.linesOfLatitude; long _ revMesh.linesOfLongitude; <> f.PutF["lat: %g, long: %g\npoints [%g]:\n", -- TAB [integer[lat]],[integer[long]],[integer[lat]]]; FOR i: NAT IN[1..lat-1] DO TFO3d.FileoutPoint3dAsPoint2d[f, rma[i][long]]; f.PutF[","]; IF (i/3)*3 = i THEN f.PutF["\n"]; -- CR TAB ENDLOOP; TFO3d.FileoutPoint3dAsPoint2d[f, rma[lat][long]]; f.PutChar[IO.CR]; }; RevoluteFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE] RETURNS [mo: MasterObject] = { lat, long, count: NAT; path: Path; TFI3d.ReadBlankAndRope[f, "lat:"]; lat _ TFI3d.ReadBlankAndNAT[f]; TFI3d.ReadBlankAndRope[f, ","]; TFI3d.ReadBlankAndRope[f, "long:"]; long _ TFI3d.ReadBlankAndNAT[f]; TFI3d.ReadBlankAndRope[f, "points"]; TFI3d.ReadBlankAndRope[f, "["]; count _ TFI3d.ReadBlankAndNAT[f]; TFI3d.ReadBlankAndRope[f, "]:"]; TFI3d.ReadBlank[f]; path _ SVPolygon2d.CreatePath[count]; FOR i: NAT IN[1..count-1] DO SVPolygon2d.PutPathPoint[path, i-1, TFI3d.ReadPoint2d[f]]; TFI3d.ReadBlankAndRope[f, ","]; TFI3d.ReadBlank[f]; ENDLOOP; SVPolygon2d.PutPathPoint[path, lat-1, TFI3d.ReadPoint2d[f]]; TFI3d.ReadBlank[f]; mo _ RevoSweepMakeMasterObject[name, path, long]; }; RevoluteFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = { revMesh: RevoluteMesh _ NARROW[mo.shadeBody]; SweepGeometry.PolyListRevolute[f, revMesh]; }; Init: PROC = { sphere, block, cylinder, cone: MasterObject; sphereClass _ SVScene.RegisterMasterObjectClass[ "sphere", SphereUpdate, SphereFilein, SphereFileout, SphereFileoutPoly, SphereRayCast, SphereRayCastNoBBoxes, SphereRayCastBoundingSpheres, SphereBoundHedron, SVScene.NoOpPreprocess, SphereLineDraw, SphereDrawNormals, SphereCountSurf, SphereGetSurf, SphereDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; blockClass _ SVScene.RegisterMasterObjectClass[ "block", BlockUpdate, BlockFilein, BlockFileout, BlockFileoutPoly, BlockRayCast, BlockRayCastNoBBoxes, BlockRayCastBoundingSpheres, BlockBoundHedron, SVScene.NoOpPreprocess, BlockLineDraw, BlockDrawNormals, BlockCountSurf, BlockGetSurf, BlockDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; cylinderClass _ SVScene.RegisterMasterObjectClass[ "cylinder", CylinderUpdate, CylinderFilein, CylinderFileout, CylinderFileoutPoly, CylinderRayCast, CylinderRayCastNoBBoxes, CylinderRayCastBoundingSpheres, CylinderBoundHedron, SVScene.NoOpPreprocess, CylinderLineDraw, CylinderDrawNormals, CylinderCountSurf, CylinderGetSurf, CylinderDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; coneClass _ SVScene.RegisterMasterObjectClass[ "cone", ConeUpdate, ConeFilein, ConeFileout, ConeFileoutPoly, ConeRayCast, ConeRayCastNoBBoxes, ConeRayCastBoundingSpheres, ConeBoundHedron, SVScene.NoOpPreprocess, ConeLineDraw, ConeDrawNormals, ConeCountSurf, ConeGetSurf, ConeDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; torusClass _ SVScene.RegisterMasterObjectClass[ "torus", TorusUpdate, TorusFilein, TorusFileout, TorusFileoutPoly, TorusRayCast, TorusRayCastNoBBoxes, TorusRayCastBoundingSpheres, TorusBoundHedron, SVScene.NoOpPreprocess, TorusLineDraw, TorusDrawNormals, TorusCountSurf, TorusGetSurf, TorusDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; linClass _ SVScene.RegisterMasterObjectClass[ "linearSweep", LinSweepUpdate, LinearFilein, LinearFileout, LinearFileoutPoly, LinSweepRayCast, LinSweepRayCastNoBBoxes, LinSweepRayCastBoundingSpheres, LinSweepBoundHedron, SVScene.NoOpPreprocess, LinSweepLineDraw, LinSweepDrawNormals, LinSweepCountSurf, LinSweepGetSurf, LinSweepDrawSurf, SVScene.NoOpDrawSubBoxes, SVScene.NoOpDrawSubSpheres]; revoClass _ SVScene.RegisterMasterObjectClass[ "revoluteSweep", RevoSweepUpdate, RevoluteFilein, RevoluteFileout, RevoluteFileoutPoly, RevoSweepRayCast, RevoSweepRayCastNoBBoxes, RevoSweepRayCastBoundingSpheres, RevoSweepBoundHedron, RevoSweepPreprocess, RevoSweepLineDraw, RevoSweepDrawNormals, RevoSweepCountSurf, RevoSweepGetSurf, RevoSweepDrawSurf, RevoSweepDrawSubBoxes, RevoSweepDrawSubSpheres]; sphere _ SphereMakeMasterObject["sphere"]; block _ BlockMakeMasterObject["block"]; cylinder _ CylinderMakeMasterObject["cylinder"]; cone _ ConeMakeMasterObject["cone"]; SVScene.RegisterMasterObject[sphere]; SVScene.RegisterMasterObject[block]; SVScene.RegisterMasterObject[cylinder]; SVScene.RegisterMasterObject[cone]; }; Init[]; END.