DIRECTORY Controls, Imager, Matrix3d, ThreeDBasics, Vector3d; Controls3d: CEDAR DEFINITIONS ~ BEGIN CameraMode: TYPE ~ {local, global}; CameraProc: TYPE ~ PROC [control: Control, data: REF ANY]; Camera: TYPE ~ REF CameraRep; CameraRep: TYPE ~ RECORD [ data: REF ANY _ NIL, -- client data proc: CameraProc _ NIL, -- client proc called when camera changed view: Matrix _ NIL, -- tranformed matrix by viewport matrix: Matrix _ NIL, -- camera matrix fieldOfView: Control _ NIL, -- field of view zDistance: Control _ NIL, -- distance of eye along negative z-axis x: Control _ NIL, -- x coordinate of origin y: Control _ NIL, -- y coordinate of origin z: Control _ NIL, -- z coordinate of origin xGlobal: Control _ NIL, -- rotation about global x-axis yGlobal: Control _ NIL, -- rotation about global y-axis zGlobal: Control _ NIL, -- rotation about global z-axis xLocal: Control _ NIL, -- rotation about local x-axis yLocal: Control _ NIL, -- rotation about local y-axis zLocal: Control _ NIL, -- rotation about local z-axis xMove: Control _ NIL, -- x-translation yMove: Control _ NIL, -- y-translation zMove: Control _ NIL, -- z-translation scale: Control _ NIL, -- scale about local origin hScreen: Control _ NIL, -- horizontal screen translation vScreen: Control _ NIL, -- vertical screen translation lastMoused: Control _ NIL -- last control moused ]; ViewPort: TYPE ~ RECORD [xo, yo: INTEGER, xs, ys: REAL]; Hold: TYPE ~ REF HoldRep; HoldRep: TYPE ~ RECORD [lng, lat, mag, x, y, z: Control _ NIL]; Triple: TYPE ~ Vector3d.Triple; TripleSequence: TYPE ~ Vector3d.TripleSequence; Pair: TYPE ~ Vector3d.Pair; PairSequence: TYPE ~ Vector3d.PairSequence; Matrix: TYPE ~ Matrix3d.Matrix; Context: TYPE ~ Imager.Context; Viewer: TYPE ~ Controls.Viewer; Mouse: TYPE ~ Controls.Mouse; Control: TYPE ~ Controls.Control; ControlProc: TYPE ~ Controls.ControlProc; ControlType: TYPE ~ Controls.ControlType; ControlList: TYPE ~ Controls.ControlList; Context3d: TYPE ~ REF ThreeDBasics.Context; xAxis: Triple ~ Vector3d.xAxis; yAxis: Triple ~ Vector3d.yAxis; zAxis: Triple ~ Vector3d.zAxis; InitCamera: PROC [ origin: Triple _ [0.0, 0.0, 0.0], globalRotate: Triple _ [0.0, 0.0, 0.0], localRotate: Triple _ [0.0, 0.0, 0.0], move: Triple _ [0.0, 0.0, 0.0], scale: REAL _ 1.0, fieldOfView: REAL _ 0.0, zDistance: REAL _ 10.0, screenMove: Pair _ [0.0, 0.0], proc: CameraProc _ NIL, data: REF ANY _ NIL] RETURNS [Camera]; ComputeNewMatrix: PUBLIC PROC [ origin: Triple _ [0.0, 0.0, 0.0], rotate: Triple _ [0.0, 0.0, 0.0], move: Triple _ [0.0, 0.0, 0.0], scale: REAL _ 0.0, fieldOfView: REAL _ 0.0, zDistance: REAL _ 0.0, m: Matrix _ NIL] RETURNS [Matrix]; InitContext: PROC [context: Context, camera: Camera, in: Matrix _ NIL] RETURNS [Matrix]; UpdateCamera: PROC [camera: Camera]; UpdateGlobalRotates: PROC [camera: Camera, rotates: Triple]; UpdateLocalRotates: PROC [camera: Camera, rotates: Triple]; UpdateOrigin: PROC [camera: Camera, origin: Triple]; UpdateMove: PROC [camera: Camera, move: Triple]; UpdateFieldOfView: PROC [camera: Camera, fieldOfView: REAL]; UpdateScale: PROC [camera: Camera, scale: REAL]; UpdateScreen: PROC [camera: Camera, screen: Pair]; UpdateZDistance: PROC [camera: Camera, zDistance: REAL]; GetCameraMatrix: PROC [camera: Camera] RETURNS [Matrix]; GetViewMatrix: PROC [camera: Camera, context: Context] RETURNS [Matrix]; GetViewPort: PROC [context: Context] RETURNS [ViewPort]; TransformByViewPort: PROC [in: Matrix, context: Context, out: Matrix _ NIL] RETURNS [Matrix]; SetContext3dView: PROC [context3d: Context3d, camera: Camera]; LastAdjustedCamera: PROC RETURNS [Camera]; InitHold: PROC [proc: ControlProc _ NIL, data: REF ANY _ NIL] RETURNS [Hold]; FocusHold: PROC [vector: Triple, hold: Hold]; PaintControls: PROC [c1, c2, c3, c4, c5, c6: Control _ NIL]; ScreenPick: PROC [points: TripleSequence, pairs: PairSequence, view: Matrix, mouse: Mouse] RETURNS [pointPicked: INTEGER]; END. ΄Controls3d.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, February 26, 1987 7:27:22 pm PST Notes The viewer is considered a screen, dimensioned [-1..1] in x and y. Rotations are performed with respect to the specified origin (defaulted to [0, 0, 0]). If the camera is in global mode the three rotations (y, x, z) are applied sequentially about the vertical, horizontal, and screen axes; these rotations are independent, each not influencing the others. If the camera is in local mode, updating the rotations causes only the most recently adjusted rotation control to be applied to the local (current) coordinate system. Thus, the final orientation of the coordinate system is accumulated over time and can not be replicated directly from the control settings. Type Declarations Imported Types Camera Procedures Return the set of camera controls and intialize the camera matrix. Compute a camera matrix, using m if non-nil. Clear context and return viewport concatenated with camera matrix; use in if non-nil. Set the camera matrix based upon its control settings. If the camera is in global mode, the entire camera matrix is recomputed from the camera control settings; if the camera is in local mode, then only the most recently changed control is used to modify the current transformation. Set the camera matrix incorporating new rotation settings; the rot controls are repainted. Set the camera matrix incorporating new rotation settings; the rot controls are repainted. Set the camera matrix incorporating new origin setting; the x, y, z controls are repainted. Set the camera matrix incorporating new translation setting; the Mov controls are repainted. Set the camera matrix incorporating a new fov setting; the fov control is repainted. Set the camera matrix incorporating a new scale setting; the scale control is repainted. Set the camera matrix incorporating new screen settings; the screen controls are repainted. Set the camera matrix incorporating new eye position; the z-distance control is repainted. Return the camera matrix translated by hScreen and vScreen. Return viewport concatenated with camera matrix translated by hScreen and vScreen. Return viewport necessary to fit [-1..1] (in x and y) image to Imager context. Transform in by the viewport; use out if non-nil. Set the context3d view parameters. This will not result in a view which is completely consistent with the views obtained with camera.matrix. Stay tuned. Return the camera most recently adjusted. Hold Procedures Return set of six controls for position and orientation. Set hold.lng, hold.lat and hold.mag controls to be vector; set hold.dx, hold.dy, hold.dz to 0.0. Miscellaneous Procedures Repaint non-nil arguments. Pairs is the projection of points onto the screen and is recomputed if mouse.state = down. Return the index of the pair nearest the mouse coordinates. -1 is returned if the length of pairs is less than the length of points. Κζ˜šœ™Jšœ Οmœ1™Jšœžœ‘˜J™KJ™NJ™—š’œž œ ˜*J™)——š ™š’œžœžœžœžœžœžœ˜MJ™8J™—š’ œžœ˜-J™`——š ™š’ œžœ$žœ˜