G3dRayTraceTool.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, October 20, 1992 5:24 pm PDT
Glassner, March 15, 1989 6:46:10 am PST
DIRECTORY Controls, Draw2d, G3dBasic, G3dControl, G3dLight, G3dMatrix, G3dModel, G3dRayTrace, G3dShape, G3dTool, Imager, IO, Rope, ViewerClasses;
G3dRayTraceTool: CEDAR DEFINITIONS
~ BEGIN
Imported Types
ROPE:    TYPE ~ Rope.ROPE;
ButtonList:  TYPE ~ Controls.ButtonList;
ControlList:  TYPE ~ Controls.ControlList;
OuterData:  TYPE ~ Controls.OuterData;
Typescript:  TYPE ~ Controls.Typescript;
Viewer:   TYPE ~ Controls.Viewer;
DrawProc:  TYPE ~ G3dTool.DrawProc;
Ray:    TYPE ~ G3dBasic.Ray;
Triple:   TYPE ~ G3dBasic.Triple;
CameraControl: TYPE ~ G3dControl.CameraControl;
Matrix:   TYPE ~ G3dMatrix.Matrix;
RayData:   TYPE ~ G3dRayTrace.RayData;
RayProc:   TYPE ~ G3dRayTrace.RayProc;
Client:   TYPE ~ G3dTool.Client;
Context:   TYPE ~ Imager.Context;
Local Types
Tool:   TYPE ~ REF ToolRep;
ToolRep:  TYPE ~ RECORD [
3d Tool:
tool3d:   G3dTool.Tool ¬ NIL,
Ray-Tracing:
rayData:   RayData ¬ NIL,    -- ray tracing mechanism
Diagnostics:
showRays:  BOOL ¬ TRUE    -- show rays on the line-drawing
];
RayTool Creation
MakeTool: PROC [
toolName:    ROPE ¬ NIL,     -- name of the tool
rayProc:    RayProc ¬ NIL,    -- position of the eye
client:     Client ¬ [],
extraControls:  ControlList ¬ NIL,   -- in addition to the standard set
extraButtons:   ButtonList ¬ NIL]   -- in addition to the standard set
RETURNS    [Tool];
The ray-traced image is shown on the color display.
rayProc is called with a unit length ray.
The standard set of controls includes:
X     x-position of the camera
Y     y-position of the camera
Z     z-position of the camera
Scale    scale of the camera
XRot    x-rotation of the camera
YRot    y-rotation of the camera
ZRot    z-rotation of the camera
Fov    field-of-view of the camera

The camera provides a view of the ray tracing world, including the object being ray-traced, the image plane, the eye-point and eye-direction, and, optionally, individual rays.
The standard set of buttons includes:
Start    Begin or resume ray-tracing
Stop    Suspend ray-tracing
Reset    Reset the pixel index to the beginning of the frame
Display Options Select from various display/diagnostic options
Parameters  Set such parameters as image width and height and ray-mode
Eye    Set the position of the eye
View    Set the view direction of the eye
Up    Set the up direction relative to the view direction
Fov    Set the image field-of-view
Tool Options
RayTraceOptions: PROC [
r: RayData,
ts: Typescript,
rayTraceProc: PROC [clientData: REF ANY] ¬ NIL,
clientData: REF ANY ¬ NIL];
Choose from a pop-up menu to alter any of the following:
ray mode, image width, image height, eye point, eye view, up direction, field of view
as well as reset the ray-tracing pixel or set the line-drawing to be the ray trace view.
ts is used to query the user.
If the Ray-Trace option is selected, rayTraceProc is called with clientData.
Tool Display
Repaint: PROC [tool: Tool, whatChanged: REF ANY ¬ NIL];
Repaint the graphics viewer associated with the tool.
END.