-- File: ObjectCast.mesa
-- Last edited by Bier on December 18, 1982 1:23 am
-- Author: Eric Bier on July 3, 1983 1:54 pm
-- Contents: Procedures to determine intersections of rays with primitive objects
DIRECTORY
CastRays,
CSG,
Matrix3d,
SV2d,
SVVector3d;
ObjectCast: DEFINITIONS =
BEGIN
Composite: TYPE = REF CompositeObj;
CompositeObj: TYPE = CSG.CompositeObj;
CSGTree: TYPE = REF CSGTreeObj;
CSGTreeObj: TYPE = CSG.CSGTreeObj;
Point2d: TYPE = SV2d.Point2d;
Point3d: TYPE = Matrix3d.Point3d;
Primitive: TYPE = REF PrimitiveObj;
PrimitiveObj: TYPE = CSG.PrimitiveObj;
Surface: TYPE = REF ANY;
Vector: TYPE = SVVector3d.Vector;
RectSurface: TYPE = REF RectSurfaceObj;
RectSurfaceObj: TYPE = RECORD [rectType: RectType];
RectType: TYPE = {up, down, left, right, front, back};
TubeSurface: TYPE = REF TubeSurfaceObj;
TubeSurfaceObj: TYPE = RECORD [];
DiskSurface: TYPE = REF DiskSurfaceObj;
DiskSurfaceObj: TYPE = RECORD [diskType: DiskType];
DiskType: TYPE = {top, bottom};
ShellSurface: TYPE = REF ShellSurfaceObj;
ShellSurfaceObj: TYPE = RECORD [];
ConeSurface: TYPE = REF ConeSurfaceObj;
ConeSurfaceObj: TYPE = RECORD [];
ToroidalSurface: TYPE = REF ToroidalSurfaceObj;
ToroidalSurfaceObj: TYPE = RECORD [];
-- maxSceneDepth: NAT = 10.;
ParameterArray: TYPE = CastRays.ParameterArray; -- ARRAY [1..maxSceneDepth] OF REAL;
SurfaceArray: TYPE = REF SurfaceArrayObj;
SurfaceArrayObj: TYPE = CSG.SurfaceArrayObj;
-- ARRAY [1..maxSurfacesPerObject] OF Surface;
InOutArray: TYPE = CastRays.InOutArray; -- ARRAY [1..maxSceneDepth] OF BOOL;
NormalArray: TYPE = CastRays.NormalArray; -- ARRAY [1..maxSceneDepth] OF Vector;
Classification: TYPE = REF ClassificationObj;
ClassificationObj: TYPE = CastRays.ClassificationObj;
-- RECORD [
-- count: NAT,
-- params: ParameterArray,
-- surfaces: SurfaceArray,
-- primitives: PrimitiveArray,
-- classifs: InOutArray,
-- normals: NormalArray];
Ray: TYPE = REF RayObj;
RayObj: TYPE = CastRays.RayObj;
-- RECORD [
-- basePt: Point3d,
-- direction: Vector];
HitRec: TYPE = REF HitRecObj;
HitRecObj: TYPE = RECORD [t: REAL, surf: Surface, normal: Vector];
HitArray: TYPE = REF HitArrayObj;
HitArrayObj: TYPE = ARRAY[1..globalObjDepth] OF HitRec;
globalObjDepth: NAT = 6;
-- Each primitive shape must have a procedure here which can classify a ray with respect to it.
BlockCast: PROC [localRay: Ray, surfs: SurfaceArray, prim: Primitive] RETURNS [class: Classification];
SphereCast: PROC [localRay: Ray, thisShell: Surface, prim: Primitive] RETURNS [class: Classification];
CylinderCast: PROC [localRay: Ray, surfaces: SurfaceArray, prim: Primitive]
RETURNS [class: Classification];
ConeCast: PROC [localRay: Ray, surfaces: SurfaceArray, prim: Primitive] RETURNS [class: Classification];
ToroidCast: PROC [localRay: Ray, prim: Primitive, torusRec: REF ANY, surface: Surface]
RETURNS [class: Classification];
-- torusRec is a BasicObject3d.TorusRec. It is a REF ANY to avoid compilation dependencies
END.