DIRECTORY CastRays, CSG, IO, Matrix3d, Shading, SVFancyRays, SVVector3d; SVFancyRaysImpl: PROGRAM IMPORTS CastRays, IO, SVVector3d EXPORTS SVFancyRays = BEGIN CSGTree: TYPE = REF CSGTreeObj; CSGTreeObj: TYPE = CSG.CSGTreeObj; LightSource: TYPE = Shading.LightSource; LightSourceList: TYPE = Shading.LightSourceList; Point3d: TYPE = Matrix3d.Point3d; Ray: TYPE = CSG.Ray; VisibleLights: PUBLIC PROC [allLights: LightSourceList, surfacePoint: Point3d, tree: CSGTree, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL, indent: NAT _ 0] RETURNS [visibleLights: LightSourceList] = { surfaceToLightRay: Ray; lightsource: LightSource; hits: BOOL; t: REAL; IF makeStream THEN f.PutF["\nFinding Visible Lights...\n\n"]; surfaceToLightRay _ CastRays.GetRayFromPool[]; surfaceToLightRay.basePt _ surfacePoint; visibleLights _ NIL; FOR l: LightSourceList _ allLights, l.rest UNTIL l = NIL DO lightsource _ l.first; surfaceToLightRay.direction _ SVVector3d.Difference[lightsource.position, surfacePoint]; [hits, t] _ CastRays.FirstHit[surfaceToLightRay, tree, makeStream, f, indent]; IF hits THEN { IF t >=1 THEN visibleLights _ CONS[lightsource, visibleLights] } ELSE visibleLights _ CONS[lightsource, visibleLights]; ENDLOOP; CastRays.ReturnRayToPool[surfaceToLightRay]; }; END. ϊFile: SVFancyRaysImpl.mesa Author: Eric Bier on July 3, 1983 12:33 pm Last edited by Bier on August 2, 1983 5:12 pm Contents: Procedures implementing shadows (reflections and transparency to come). The first hit occurs past the light source. Edited on August 2, 1983 5:12 pm, by Bier Fixed VisibleLights so that a light is considered visible even if a ray from surface to light hits an object, so long as that object is past the lightsource. changes to: VisibleLights, DIRECTORY, SVFancyRaysImpl Κτ˜Ihead™J™*J™-J™RšΟk ˜ Jšœ ˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ —šœ˜Jšœ œ ˜ Jšœ˜—Jšœ˜Jšœ œœ ˜Jšœ œœ ˜"Jšœ œ˜(Jšœœ˜0Jšœ œ˜!Jšœœœ˜šΟn œœœPœœœœœ œœ%˜ΙJ˜Jšœ˜Jšœœ˜ Jšœœ˜Jšœ œ+˜=Jšœ.˜.Jšœ(˜(Jšœœ˜šœ(œœ˜;Jšœ˜JšœX˜XJšœN˜Nšœœ˜Jšœœœ˜>J™+J˜—Jšœœ˜6—Jšœ˜Jšœ,˜,˜Jšœ˜——Jšœ˜™)Jšœ™Jšœ Οr)™5—J™J™J™—…—ψζ