Controls3d.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, May 21, 1986 11:26:04 pm PDT
DIRECTORY Controls, Imager, Matrix3d, Rope, Vector3d;
Controls3d: CEDAR DEFINITIONS
~ BEGIN
ROPE:   TYPE ~ Rope.ROPE;
Triple:  TYPE ~ Vector3d.Triple;
Matrix:  TYPE ~ Matrix3d.Matrix;
Context:  TYPE ~ Imager.Context;
ControlData: TYPE ~ Controls.ControlData;
ControlProc: TYPE ~ Controls.ControlProc;
CoordType: TYPE ~ {lng, lat, mag, x, y, z};
ViewPort:  TYPE ~ RECORD [xo, yo: INTEGER, xs, ys: REAL];
Camera:  TYPE ~ REF CameraRec;
CameraRec: TYPE ~ RECORD [pan, tilt, roll, dx, dy, dz, zoom, fov: ControlData ← NIL];
Hold:   TYPE ~ REF HoldRec;
HoldRec:  TYPE ~ RECORD [lng, lat, mag, dx, dy, dz: ControlData ← NIL];
VecData:  TYPE ~ REF VecDataRec;
VecDataRec: TYPE ~ RECORD [
      name: ROPENIL,
      lng, lat, mag: REAL ← 0.0,
      v: Triple ← [0.0, 0.0, 0.0],
      viewer: Controls.Viewer ← NIL,
      lngC, latC, magC, xC, yC, zC: ControlData ← NIL
      ];
VecList:  TYPE ~ LIST OF VecData;
ScalData:  TYPE ~ REF ScalDataRec;
ScalDataRec: TYPE ~ RECORD[
      name: ROPENIL,
      val: REAL ← 0.0,
      viewer: Controls.Viewer ← NIL,
      C: ControlData ← NIL
      ];
ScalList:  TYPE ~ LIST OF ScalData;
InitCamera: PROC [pan, tilt, roll: REAL ← 0.0, zoom: REAL ← 1.0, dx, dy, dz: REAL ← 0.0, fov: REAL ← 40.0, proc: ControlProc ← NIL, data: REF ANYNIL, cam: Camera ← NIL]
RETURNS [Camera];
Return a set of camera controls and intialize the camera matrix; return cam if non-nil.
GetCamera: PUBLIC PROC RETURNS [Matrix];
Return the current object camera matrix.
GetCameraNoFOV: PUBLIC PROC [pan, tilt, roll, dx, dy, dz: REAL ← 0.0, zoom: REAL ← 1.0]
RETURNS [m: Matrix];
Return a viewing transformation without perspective.
SetCamera: PROC [c: Camera];
Set view matrix.
SetCameraVals: PROC [pan, tilt, roll: REAL ← 0., zoom: REAL ← 1., dx, dy, dz, fov: REAL ← 0.];
Set view matrix.
InitHold: PROC [proc: ControlProc ← NIL, data: REF ANYNIL, hold: Hold ← NIL]
RETURNS [Hold];
Return set of six controls for position and tangency; return hold if non-nil.
FocusHold: PROC [tan: Triple, hold: Controls3d.Hold];
Set lng, lat and mag controls to be tan vector; set ptx, pty, ptz to zero.
GetView: PROC [w, h: INTEGER, in: Matrix ← NIL] RETURNS [Matrix];
Return viewport concatenated with camera matrix; use in if non-nil.
InitPix: PROC [context: Context, w, h: INTEGER, in: Matrix ← NIL] RETURNS [Matrix];
Clear context and return viewport concatenated with camera matrix.
GetViewPort: PROC [w, h: INTEGER] RETURNS [ViewPort];
Return viewport origin and scale; use in if non-nil.
ShowVec: PROC [vec: VecData, context: Context, view: Matrix];
Draw and label vector using given viewport.
InitScal: PROC [name: ROPENIL, type: Controls.ControlType, trunc: BOOLFALSE, min, max, init: REAL] RETURNS [ScalData];
Allocate a ScalData and set its .name, .val and .C.
ComputeVec: PROC [vec: VecData, x, y, z: REAL, polar: BOOLFALSE];
Compute vec.v if polar values, else compute vec.lng, vec.lat, and vec.mag.
InitVec: PROC [name: ROPENIL, v: Triple ← [0.0, 0.0, 0.0], polar, cartesian: BOOL TRUE, min: REAL ← -5.0, max: REAL ← 5.0] RETURNS [VecData];
Allocate VecData, set name and lng, lat, mag and set polar and/or cartesian controls.
SetVec: PROC [vec: VecData, x, y, z: REAL, polar: BOOLFALSE, c: ControlData ← NIL, val: REAL];
Compute vec and update control; repaint c if non-nil.
PaintControls: PROC [c1, c2, c3, c4, c5, c6: ControlData ← NIL];
Repaint arguments if non-nil.
ReviseVec: PROC [vec: VecData, val: REAL, type: CoordType];
Updates vec and repaints its controls.
ResetVec: PROC [vec: Controls3d.VecData, p: Triple, polar: BOOLFALSE];
Reset vec to x, y, z.
END.