DIRECTORY CedarProcess, G3dBasic, G3dLight, G3dMatrix, G3dView, Imager, ImagerColor, ImagerPixel, ImagerSample, IO, Rope, ViewerClasses; G3dRayTrace: CEDAR DEFINITIONS ~ BEGIN Process: TYPE ~ CedarProcess.Process; PixelMap: TYPE ~ ImagerPixel.PixelMap; SampleMap: TYPE ~ ImagerSample.SampleMap; Ray: TYPE ~ G3dBasic.Ray; IntegerPair: TYPE ~ G3dBasic.IntegerPair; Triple: TYPE ~ G3dBasic.Triple; LightSequence: TYPE ~ G3dLight.LightSequence; Matrix: TYPE ~ G3dMatrix.Matrix; Viewport: TYPE ~ G3dMatrix.Viewport; Context: TYPE ~ Imager.Context; RGB: TYPE ~ ImagerColor.RGB; ROPE: TYPE ~ Rope.ROPE; origin: Triple ~ G3dBasic.origin; yAxis: Triple ~ G3dBasic.yAxis; zAxis: Triple ~ G3dBasic.zAxis; ClientProc: TYPE ~ PROC [clientData: REF ANY]; RayProc: TYPE ~ PROC [ray: Ray, clientData: REF ANY] RETURNS [rgb: RGB]; RayData: TYPE ~ REF RayDataRep; RayDataRep: TYPE ~ RECORD [ nextPixel: IntegerPair ¬ [0, 0], -- the next pixel to ray-trace eyePoint: Triple ¬ origin, -- base of ray eyeView: Triple ¬ zAxis, -- direction of ray upDirection: Triple ¬ yAxis, -- up orientation fieldOfView: REAL ¬ 40.0, -- angle for half screen lights: LightSequence ¬ NIL, -- sequence of lights portionSpecular: REAL ¬ 0.5, -- portion of specularity x, y: NAT ¬ 0, -- origin of image (in pixels) w, h: NAT ¬ 80, -- size of image (in pixels) display: PixelMap, -- the color display redo: SampleMap ¬ NIL, -- used for adaptive sampling clientData: REF ANY ¬ NIL, -- passed to in rayProc finishProc: ClientProc ¬ NIL, -- called upon completion jitter: BOOL ¬ FALSE, -- stochastic ray from pixel center noShading: BOOL ¬ FALSE, -- iff true, show hit-testing only traceOctree: BOOL ¬ FALSE, -- iff true, show octree hit-testing nPixelSamples: NAT ¬ 1, -- sub-sampling of pixels adaptiveLimit: NAT ¬ 0 , -- # levels of adaptive refinement rgb: RGB ¬ [0, 0, 0], -- pixel value ray: Ray ¬ [origin, origin], -- the ray rayProc: RayProc ¬ NIL, -- client supplied ray-trace proc process: Process ¬ NIL -- forked process ]; RayTrace: PROC [ display: PixelMap, -- place to create the ray-traced image eyePoint: Triple ¬ origin, -- position of the eye eyeView: Triple ¬ zAxis, -- view direction upDirection: Triple ¬ yAxis, -- orientation fieldOfView: REAL ¬ 40.0, -- half horizontal view in degrees jitter: BOOL ¬ FALSE, -- stochastic ray from pixel center nPixelSamples: NAT ¬ 1, -- sub-sampling of pixels adaptiveLimit: NAT ¬ 0, -- # levels of adaptive refinement rayProc: RayProc ¬ NIL, -- client supplied ray-tracing proc clientData: REF ANY ¬ NIL] -- passed to the rayProc RETURNS [RayData]; StartRayTracing: PROC [r: RayData]; StopRayTracing: PROC [r: RayData]; ResetRayTracing: PROC [r: RayData]; SetNextPixel: PROC [r: RayData]; SetRay: PROC [r: RayData, x, y: NAT]; AspectRatio: PROC [r: RayData] RETURNS [REAL]; RayImageScreenCorners: PROC [r: RayData] RETURNS [p1, p2, p3, p4: Triple]; DrawRayTip: PROC [context: Context, r: RayData, view: Matrix, viewport: Viewport]; DrawRayImageScreen: PROC [context: Context, r: RayData, view: Matrix, viewport: Viewport]; ParametersMessage: PROC [r: RayData] RETURNS [rope: ROPE]; END. Ύ G3dRayTrace.mesa Copyright Σ 1985, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 15, 1992 10:42 pm PDT Imported Types Local Types State: Viewing: Lighting: Surface: Image: Miscellany: Ray-Tracing: Ray Tracing This forks a ray-tracing process and the sampleMaps are painted accordingly. The eyeView is mapped to the center of the sampleMaps and the fieldOfView spans the right half of the sampleMaps. rayProc is called with a unit length ray. Begin or resume the ray-tracing. Suspend the ray-tracing. Reset the next pixel to be the starting pixel of the image. Advance to the next ray-traced image pixel. Set the ray given the ray-traced image pixel location. Miscellany Return the aspect ratio of the ray-traced image. Return the four 3D corners of the image screen. Place a dot at the tip of the current ray. Draw a rectangle to represent the ray-traced image extent. Produce a rope indicating the mode of ray tracing. Κh•NewlineDelimiter –"cedarcode" style™™Jšœ Οeœ6™BJ™'J˜JšΟk œ˜ˆJ˜—šΠbl œžœž ˜J˜—Jšœž˜headšΟl™Jšœ žœ˜(Jšœ žœ˜)Jšœ žœ˜+Jšœžœ˜Jšœ žœ˜+Jšœžœ˜"Jšœžœ˜.Jšœžœ˜#Jšœ žœ˜'Jšœ žœ˜"Jšžœž œžœ˜ šžœž œžœ˜J˜—J˜$J˜"J˜#—š  ™ š œžœžœžœžœ˜0J˜—š œ žœžœžœžœžœžœ˜KJ˜—Jšœžœžœ ˜"šœ žœžœ˜™Jšœ(Οc˜F—™Jšœ#‘˜1Jšœ!‘˜4Jšœ$‘˜5Jšœžœ ‘˜:—™ Jšœžœ‘˜9—™Jšœžœ ‘˜=—™Jšœ žœ ‘˜8Jšœ žœ ‘˜6Jšœ‘˜0Jšœžœ‘˜<—™ Jšœžœžœžœ‘˜9Jšœžœ‘˜=—™ Jšœ žœžœ‘#˜BJšœžœžœ‘#˜BJšœžœžœ‘%˜FJšœžœ ‘˜9Jšœžœ ‘"˜BJšœ žœ‘˜-Jšœ$‘ ˜.Jšœžœ‘!˜AJšœžœ‘˜0—J˜——š  ™ šΟnœžœ˜Jšœ‘'˜CJšœ#‘˜9Jšœ!‘˜2Jšœ$‘˜2Jšœ ž œ ‘"˜DJšœ žœžœ‘#˜BJšœžœ ‘˜9Jšœžœ ‘"˜BJšœžœ‘#˜CJšœžœžœžœ‘˜:Jšžœ˜J˜J™LJ™OJ™LJ™—š’œžœ˜#J™ J™—š’œžœ˜"J™J™—š’œžœ˜#J™;J™—š’ œžœ˜ J™+J™—š’œžœžœ˜%J™6——š  ™ š’ œžœžœžœ˜.J™0J™—š’œžœžœ˜JJ™/J™—š’ œžœB˜RJ™*J˜—š’œžœB˜ZJ™:J˜—š’œžœžœžœ˜:J™2—J™—Jšžœ˜—…— `†