File: SVFancyRaysImpl.mesa
Author: Eric Bier on July 3, 1983 12:33 pm
Last edited by Bier on July 3, 1983 4:04 pm
Contents: Procedures implementing shadows (reflections and transparency to come).
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.