<> <> <> <> DIRECTORY CastRays, CSG, Matrix3d, Shading, SVFancyRays, SVVector3d; SVFancyRaysImpl: PROGRAM IMPORTS CastRays, 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] RETURNS [visibleLights: LightSourceList] = { surfaceToLightRay: Ray; lightsource: LightSource; hits: BOOL; visibleLights _ NIL; FOR l: LightSourceList _ allLights, l.rest UNTIL l = NIL DO lightsource _ l.first; surfaceToLightRay _ CastRays.GetRayFromPool[]; surfaceToLightRay.basePt _ surfacePoint; surfaceToLightRay.direction _ SVVector3d.Difference[lightsource.position, surfacePoint]; hits _ CastRays.HitsTree[surfaceToLightRay, tree]; CastRays.ReturnRayToPool[surfaceToLightRay]; IF NOT hits THEN visibleLights _ CONS[lightsource, visibleLights]; ENDLOOP; }; END.