File: SVPrimitiveImpl.mesa
Last edited by Bier on August 18, 1983 11:42 am
Contents: A simple function for copying most of the properties of an assembly to its corresponding csg primitive so the implementor of a master object doesn't have to do it all in his PrimitiveFromAssembly proc.
DIRECTORY
CSG,
DisplayList3d,
Matrix3d,
SVBoundBox,
SVPrimitive;
SVPrimitiveImpl: PROGRAM
IMPORTS Matrix3d
EXPORTS SVPrimitive =
BEGIN
Assembly: TYPE = DisplayList3d.Assembly;
BoundHedron: TYPE = SVBoundBox.BoundHedron;
MasterObject: TYPE = DisplayList3d.MasterObject;
Primitive: TYPE = REF PrimitiveObj;
PrimitiveObj: TYPE = CSG.PrimitiveObj;
RayCastProc: TYPE = CSG.RayCastProc;
FromAssembly: PUBLIC PROC [assem: Assembly, inverted: BOOL] RETURNS [prim: Primitive] = {
mo: MasterObject;
prim ← NEW[PrimitiveObj];
IF NOT ISTYPE[assem.object, MasterObject] THEN ERROR PrimitiveAssemblyWithoutMO;
mo ← NARROW[assem.object];
prim.name ← assem.name;
prim.artwork ← assem.artwork;
prim.assembly ← assem;
prim.mo ← mo;
prim.rayCast ← mo.class.rayCast;
prim.rayCastNoBBoxes ← mo.class.rayCastNoBBoxes;
prim.primWRTAssembly ← assem.coordSys;
prim.scalars ← assem.scalars;
prim.primWRTWorld ← assem.coordSys.wrtWorld;
prim.worldWRTPrim ← Matrix3d.Inverse[prim.primWRTWorld];
prim.hints will be filled in at preprocess time
prim.boundBox ← NIL; -- will be filled in at tree preprocess time
prim.boundHedron ← mo.class.getHedron[mo];
prim.inverted ← inverted;
prim.currentRay ← NIL;
prim.rayStepX ← NIL;
};
PrimitiveAssemblyWithoutMO: PUBLIC ERROR = CODE;
END.