DIRECTORY CastRays, CSG, IO, SV3d, SVFancyRays, SVModelTypes, SVRayTypes; SVFancyRaysImpl: PROGRAM IMPORTS CastRays, CSG, IO EXPORTS SVFancyRays = BEGIN CSGTree: TYPE = SVRayTypes.CSGTree; LightSource: TYPE = SVModelTypes.LightSource; LightSourceList: TYPE = SVModelTypes.LightSourceList; Point3d: TYPE = SV3d.Point3d; Ray: TYPE = SVRayTypes.Ray; Vector: TYPE = SV3d.Vector; VisibleLights: PUBLIC PROC [allLights: LightSourceList, surfacePoint: Point3d, tree: CSGTree, useBoundSpheres: BOOL, makeStream: BOOL _ FALSE, f: IO.STREAM _ NIL, indent: NAT _ 0] RETURNS [visibleLights: LightSourceList] = { surfaceToLightRay: Ray; lightsource: LightSource; ambient: LightSource; hits: BOOL; t: REAL; IF makeStream THEN f.PutF["\nFinding Visible Lights...\n\n"]; surfaceToLightRay _ CSG.GetRayFromPool[]; visibleLights _ NIL; IF allLights.first.type # ambient THEN ERROR; ambient _ allLights.first; -- CONS on last, so it will be first. FOR l: LightSourceList _ allLights.rest, l.rest UNTIL l = NIL DO lightsource _ l.first; CSG.StuffWorldRayFromPoints[surfaceToLightRay, surfacePoint, lightsource.position]; [hits, t] _ CastRays.FirstHit[surfaceToLightRay, tree, useBoundSpheres, makeStream, f, indent]; IF hits THEN { IF t >=1 THEN visibleLights _ CONS[lightsource, visibleLights] } ELSE visibleLights _ CONS[lightsource, visibleLights]; ENDLOOP; CSG.ReturnRayToPool[surfaceToLightRay]; visibleLights _ CONS[ambient, visibleLights]; }; END.  File: SVFancyRaysImpl.mesa Created July 3, 1983 12:33 pm Copyright c 1984 by Xerox Corporation. All rights reserved. Last edited by Bier on August 5, 1984 1:07:19 pm PDT Contents: Procedures implementing shadows (reflections and transparency to come). The first hit occurs past the light source. The ambient light is never blocked. 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. Κ(˜Ihead™J™Jšœ Οmœ1™J™+J˜—Jšžœžœ˜6—Jšžœ˜Jšžœ$˜'šœžœ˜-J™#—˜Jšœ˜——Jšžœ˜™)Jšœ™J™—J™J™J™—…—€ μ