DIRECTORY CoordSys, CSG, DisplayList3d, Graphics, GraphicsColor, IO, Matrix3d, Rope, Shading, SV2d, SVBoundBox, SVVector3d; CastRays: DEFINITIONS = BEGIN BoundBox: TYPE = REF BoundBoxObj; BoundBoxObj: TYPE = SVBoundBox.BoundBoxObj; Camera: TYPE = DisplayList3d.Camera; Color: TYPE = GraphicsColor.Color; CoordSystem: TYPE = REF CoordSysObj; CoordSysObj: TYPE = CoordSys.CoordSysObj; Point2d: TYPE = SV2d.Point2d; Point3d: TYPE = Matrix3d.Point3d; Vector: TYPE = SVVector3d.Vector; Surface: TYPE = CSG.Surface; -- REF ANY; CSGTree: TYPE = REF CSGTreeObj; CSGTreeObj: TYPE = CSG.CSGTreeObj; PointSetOp: TYPE = CSG.PointSetOp; ParameterArray: TYPE = CSG.ParameterArray; -- ARRAY [1..maxSceneDepth] OF REAL; SurfaceArray: TYPE = REF SurfaceArrayObj; SurfaceArrayObj: TYPE = CSG.SurfaceArrayObj; InOutArray: TYPE = CSG.InOutArray; -- ARRAY [1..maxSceneDepth] OF BOOL; NormalArray: TYPE = CSG.NormalArray; -- ARRAY [1..maxSceneDepth] OF Vector; PrimitiveArray: TYPE = CSG.PrimitiveArray; -- ARRAY [1..maxSurfacesPerObject] OF Primitive; Ray: TYPE = REF RayObj; RayObj: TYPE = CSG.RayObj; Classification: TYPE = REF ClassificationObj; ClassificationObj: TYPE = CSG.ClassificationObj; LightSourceList: TYPE = Shading.LightSourceList; RayCast: PROC [cameraPoint: Point2d, sceneRay: Ray, node: REF ANY, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL, indent: NAT _ 0] RETURNS [class: Classification]; RayCastNoBBoxes: PROC [sceneRay: Ray, node: REF ANY, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL, indent: NAT _ 0] RETURNS [class: Classification]; HitsTree: PROC [worldRay: Ray, tree: CSGTree] RETURNS [BOOL]; FirstHit: PROC [worldRay: Ray, tree: CSGTree, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL, indent: NAT _ 0] RETURNS [hits: BOOL, t: REAL]; Combine: PROC [leftClass, rightClass: Classification, op: PointSetOp] RETURNS [combinedClass: Classification]; SingleRay: PROC [x, y: INTEGER, tree: CSGTree, lightSources: LightSourceList, camera: Camera, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL] RETURNS [color: Color]; SingleRay2: PROC [cameraPoint: Point2d, tree: CSGTree, lightSources: LightSourceList, camera: Camera, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL] RETURNS [class: Classification]; SetScanSize: PROC [height, width: NAT]; DrawTree: PROC [dc: Graphics.Context, tree: CSGTree, lightSources: LightSourceList, camera: Camera, aisRope: Rope.ROPE, bAndWOnly: BOOL, notify: NotifyOfProgressProc _ NoOpNotifyOfProgress, clientData: REF ANY _ NIL, outStream: IO.STREAM] RETURNS [success: BOOL]; NotifyOfProgressProc: TYPE = PROC [currentY, minX, minY, maxX, maxY: REAL, clientData: REF ANY _ NIL]; NoOpNotifyOfProgress: NotifyOfProgressProc; Text: TYPE = REF READONLY TEXT; GetClassFromPool: PROC RETURNS [class: Classification]; ReturnClassToPool: PROC [class: Classification]; MakeClassAMiss: PROC [class: Classification]; GetRayFromPool: PROC RETURNS [ray: Ray]; ReturnRayToPool: PROC [ray: Ray]; END. RFile: CastRays.mesa Last edited by Bier on August 19, 1983 11:40 am Author: Eric Bier in the summer of 1982 Contents: The ray casting (as opposed to tree building) part of the CSG package. CSG.mesa builds the trees maxSceneDepth: NAT = 20; {union, intersection, difference} ARRAY [1..maxSurfacesPerObject] OF Surface; The main ray casting procedure. Scene Ray must be in WORLD coordinates before this procedure is called. Like RayCast but ignore any bounding boxes which were computed. This is useful if the ray does not originate from the screen (as for computing shadows). Of course, bounding spheres would be useful in this case. The client must be sure to call ReturnClassToPool[class] when he is done with it. DrawTree calls notify once before starting each line (row) of pixels. Rearranges class to correspond to a complete miss. Κ]– "cedar" style˜Iheadšœ™Iprocšœ/™/Lšœ'™'Lšœl™lL˜šΟk ˜ Lšœ ˜ Lšœ˜Lšœ˜Lšœ ˜ Lšœ˜Lšœ˜Lšœ ˜ Lšœ˜Lšœ˜Lšœ˜Lšœ ˜ Lšœ ˜ —L˜Lšœ  œ˜L˜Lš˜˜Lšœ œœ ˜!Lšœ œ˜+Lšœœ˜%Lšœœ˜"Lšœ œœ ˜$Lšœ œ˜)Lšœ œ˜Lšœ œ˜!Lšœœ˜!Lšœ œœ˜(L˜Lšœ œœ ˜Lšœ œœ ˜"L˜Lšœ™L˜šœ œœ ˜"Lšœ!™!—L˜Lšœœœ5˜OLšœœœ˜)Lšœœœ˜,Lšœ+™+Lšœ œœ1˜GLšœ œœ4˜KLšœœœA˜[L˜Lšœœœ˜Lšœœœ˜L˜Lšœœœ˜-Lšœœœ˜0L˜Lšœœ˜0L˜L˜šΟnœœ-œœœœœœœ œœ˜’Lšœh™h—L˜šžœœœœœœœœœ œœ˜”L™Τ—L˜Lšžœœ œœ˜>Lšžœœ,œœœœœ œœœœ˜ŒLšžœœ9œ"˜oLšž œœœLœœœœœœ˜€šž œœbœœœœœœ˜΄LšœQ™Q—L™Lšž œœœ˜(šžœœdœ œCœœœ œœœ œ˜‡LšœF™F—Lšžœœœ$œœœœ˜fLšœ,˜,Lš œœœœœ˜Lšžœœœ˜8Lšžœœ˜1šžœœ˜-Lšœ3™3—Lšžœœœ ˜)Lšžœœ ˜!—L˜Lšœ˜L˜—…— z)