DIRECTORY Controls, Draw2d, G3dBasic, G3dMatrix, G3dPlane, G3dQuaternion, G3dShape, G3dView, Imager, Rope; G3dControl: CEDAR DEFINITIONS ~ BEGIN Control: TYPE ~ Controls.Control; ControlProc: TYPE ~ Controls.ControlProc; ControlList: TYPE ~ Controls.ControlList; Mouse: TYPE ~ Controls.Mouse; Viewer: TYPE ~ Controls.Viewer; DrawType: TYPE ~ Draw2d.DrawType; IntegerPair: TYPE ~ G3dBasic.IntegerPair; Pair: TYPE ~ G3dBasic.Pair; PairSequence: TYPE ~ G3dBasic.PairSequence; Triple: TYPE ~ G3dBasic.Triple; TripleSequence: TYPE ~ G3dBasic.TripleSequence; Matrix: TYPE ~ G3dMatrix.Matrix; Viewport: TYPE ~ G3dMatrix.Viewport; Plane: TYPE ~ G3dPlane.Plane; Quaternion: TYPE ~ G3dQuaternion.Quaternion; ScreenSequence: TYPE ~ G3dShape.ScreenSequence; Context: TYPE ~ Imager.Context; ROPE: TYPE ~ Rope.ROPE; Method: TYPE ~ {controls, geometry}; ProxyMode: TYPE ~ {par, wor, eye}; MovRot: TYPE ~ RECORD [ xMov: Control _ NIL, -- x translation yMov: Control _ NIL, -- y translation zMov: Control _ NIL, -- z translation xRot: Control _ NIL, -- rotation about x axis yRot: Control _ NIL, -- rotation about y axis zRot: Control _ NIL -- rotation about z axis ]; ArcBall: TYPE ~ REF ArcBallRep; ArcBallRep: TYPE ~ RECORD [ originBody: BOOL _ TRUE, -- rotate wrt body, else wrt world rotate: ArcControl _ NIL, -- data structure for the rotator translate: ArcControl _ NIL -- data structure for the translator ]; ArcControl: TYPE ~ REF ArcControlRep; ArcControlRep: TYPE ~ RECORD [ control: Control _ NIL, inCorner: BOOL _ FALSE, firstPlace, lastPlace: Triple _ [0,0,1], firstPrev, lastPrev: Triple _ [0,0,1], qAbs: Quaternion _ [0,0,0,1], -- rotation at mouse down tAbs: Triple _ [0,0,0], -- translation at mouse down qInc: Quaternion _ [0,0,0,1], -- incremented rotate tInc: Triple _ [0,0,0], -- incremented translate qTan: Quaternion _ [0,0,0,1], qBasis: Triple _ [0,0,0], ropeBasis: Triple _ [0,0,0], rope: ROPE _ NIL, inhibitPrint: BOOL _ FALSE, frame: Matrix _ NIL, camera: CameraControl _ NIL, clientProc: ControlProc _ NIL, clientData: REF ANY _ NIL ]; Camera: TYPE ~ G3dView.Camera; CameraControl: TYPE ~ REF CameraControlRep; CameraControlRep: TYPE ~ RECORD [ clientData: REF ANY _ NIL, -- client data proc: ControlProc _ NIL, -- client proc called if camera changes graphics: Viewer _ NIL, -- if non-nil, automate the redraw method: Method _ controls, -- interactive controls or geometric specs? use: {view, shape, light}, -- what is being controlled? matrix: Matrix _ NIL, -- camera matrix inverse: Matrix _ NIL, -- inverse of camera matrix view: Matrix _ NIL, -- matrix times viewport miscMatrix: Matrix _ NIL, -- for miscellaneous applications miscVector: Triple _ [], -- for miscellaneous applications miscPosition: Triple _ [], -- for miscellaneous applications save: Camera _ NIL, -- for undo mouse: Mouse _ [], -- current state of the user's mouse arcBall: ArcBall _ NIL, -- alternate to par/wor/eye proxyMode: ProxyMode _ par, -- meaning of proxy controls proxySelect: Control _ NIL, -- set camera.proxyMode proxy: MovRot _ [], -- use defined by camera.proxyMode par: MovRot _ [], -- actual tran & rotate parameter controls wor: MovRot _ [], -- incremental world space xform controls eye: MovRot _ [], -- incremental eye space xform controls scale: Control _ NIL, -- scale about origin fieldOfView: Control _ NIL, -- field of view hScreen: Control _ NIL, -- horizontal screen translation vScreen: Control _ NIL, -- vertical screen translation current: Control _ NIL, -- current control moused prev: Control _ NIL, -- previous control moused initval: REAL _ 0.0, -- init val for current incremental control incr: Matrix _ NIL, -- incremental xform (wor or eye space) eyePoint: Triple _ [], -- location of the camera lookAt: Triple _ [], -- camera's view direction up: Triple _ [], -- camera's notion of "up" roll: REAL _ 0.0 -- rotation about the camera's axis ]; InitArcBall: PROC [camera: CameraControl, clientProc: ControlProc, clientData: REF ANY] RETURNS [ArcBall]; SetArcBall: PROC [arcBall: ArcBall, rotate, translate: Triple _ []]; SetArcBallSize: PROC [arcBall: ArcBall, size: INTEGER]; SetCameraControlMethod: PROC [camera: CameraControl, method: Method]; CameraControlOrientation: PROC [camera: CameraControl, eyePoint, lookAt, up: Triple, roll: REAL]; InitCameraControl: PROC [ proc: ControlProc _ NIL, clientData: REF ANY _ NIL, proxyMode: ProxyMode _ wor, fieldOfView: REAL _ 60.0, scale: REAL _ 1.0, move: Triple _ [0.0, 2.0, 0.0], rotate: Triple _ [0.0, 0.0, 0.0], moveRange: REAL _ 10.0] RETURNS [CameraControl]; AddCameraControl: PROC [controls: ControlList, camera: CameraControl, useArcBalls: BOOL] RETURNS [ControlList]; SetCameraControlGraphics: PROC [camera: CameraControl, graphics: Viewer]; InitContext: PROC [ context: Context, camera: CameraControl, viewer: Viewer _ NIL, clear: BOOL _ TRUE, out: Matrix _ NIL] RETURNS [Matrix]; UpdateCameraControl: PROC [camera: CameraControl]; UpdateControl: PROC [camera: CameraControl, control: Control, value: REAL]; GetCameraControlMatrix: PROC [camera: CameraControl] RETURNS [Matrix]; GetViewMatrix: PROC [camera: CameraControl, out: Matrix] RETURNS [Matrix]; EyeViewFromCameraControl: PROC [camera: CameraControl] RETURNS [Triple]; SaveState: PROC [camera: CameraControl, state: Camera]; RestoreState: PROC [camera: CameraControl, state: Camera]; LastAdjustedCameraControl: PROC RETURNS [CameraControl]; CameraControlMessage: PROC [camera: CameraControl] RETURNS [ROPE]; Slice: TYPE ~ REF SliceRep; -- controls for a planar slice SliceRep: TYPE ~ RECORD [ x, y, z: Control _ NIL, -- center of plane phi, theta, size: Control _ NIL, -- direction and size of plane plane: Plane _ [], -- the plane equation matrix: Matrix _ NIL -- matrix to transform to plane ]; InitSlice: PROC [data: REF ANY _ NIL, proc: Controls.ControlProc _ NIL] RETURNS [slice: Slice]; SetSlice: PROC [slice: Slice, plane: Plane, size: REAL _ 1.0]; UpdateSlice: PROC [slice: Slice]; DrawSlice: PROC [ context: Context, slice: Slice, view: Matrix, viewport: Viewport _ [], drawType: DrawType _ solid]; MoveSliceInY: PROC [slice: Slice, amount: REAL]; MoveSliceInZ: PROC [slice: Slice, amount: REAL]; Hold: TYPE ~ REF HoldRep; HoldRep: TYPE ~ RECORD [ pitch: Control _ NIL, -- declination about the horizontal yaw: Control _ NIL, -- rotation about the absolute vertical roll: Control _ NIL, -- rotation about the relative vertical mag: Control _ NIL, -- magnitude of the pitch-yaw vector x: Control _ NIL, -- x coordinate of position y: Control _ NIL, -- y coordinate of position z: Control _ NIL -- z coordinate of position ]; InitHold: PROC [proc: ControlProc _ NIL, data: REF ANY _ NIL] RETURNS [Hold]; SetHold: PROC [hold: Hold, position, tangent: Triple _ [0.0, 0.0, 0.0]]; PositionFromHold: PROC [hold: Hold] RETURNS [Triple]; VectorFromHold: PROC [hold: Hold] RETURNS [t: Triple]; Pick: TYPE ~ RECORD [offset: Pair, selected: INTEGER]; ScreenPick: PROC [screens: ScreenSequence, screen: IntegerPair] RETURNS [INTEGER]; PointPick: PROC [points: TripleSequence, pairs: PairSequence, view: Matrix, mouse: Mouse] RETURNS [INTEGER]; MovePointPick: PROC [ points: TripleSequence, pairs: PairSequence _ NIL, view: Matrix, viewport: Viewport, mouse: Mouse, pick: Pick] RETURNS [Pick]; PaintControls: PROC [c1, c2, c3, c4, c5, c6: Control _ NIL]; SetTripleControls: PROC [x, y, z: Control _ NIL, triple: Triple, repaint: BOOL _ TRUE]; END. Ά G3dControl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, April 11, 1992 12:27 pm PDT Heckbert, June 17, 1988 10:39:40 pm PDT Imported Types Local Types General information: State: Interactive control: Geometric specification: ArcBall: Quaternion Control of a CameraControl Return controls for rotation and translation. camera is the non-arcBall camera defined in G3dControl. Call proc, if non-nil, whenever a control is modified, passing data. Set the arc ball to the given state. Set the size of the controls. CameraControl Procedures The following procedures provide a standard set of controls for manipulating a "camera" for three dimensional graphics. The camera parameters are field-of-view, scale (non-differential), translate (x, y, and z), and rotate (x, y, and z). These parameters may be directly manipulated using a subset of the controls (camera.par, camera.fieldOfView, and camera.scale) created by InitCameraControl. For more intuitive interaction, incremental controls are provided that insert simple translation or rotation transformations into the camera transformation. The six controls in camera.wor provide incremental world space manipulation. The six controls in camera.eye provide incremental eye space manipulation. See WorldToViewMatrix for additional comments. To conserve screen real estate "proxy" controls may be used; the meaning of these controls may be changed with camera.proxySelect. Most applications will use InitCameraControl and InitContext. InitCameraControl is used when creating a viewer for graphics display; InitContext is used inside the applications PaintProc. A graphics viewer is considered a screen, dimensioned [-1..1] in x and y. Rotations are in degrees. Set the method for the camera. Set camera's geometric specifications; up is relative to the camera's view direction. This call forces camera.method to be geometric. Return the set of camera controls and intialize the camera matrix. Call proc, if non-NIL, whenever a camera control is modified. If graphics non-NIL, cause repaint whenever a camera control is modified. The value of move controls B [-moveRange..moveRange]. fieldOfView, scale, move, and rotate are initial camera settings. fieldOfView is the full field of view. Add the camera controls to controls. Cause graphics to be redrawn whenever a camera control is modified. Optionally clear context and return camera matrix; use out if non-nil. If viewer is non-nil, concatenate the camera matrix with the viewport. If the last control modified is a normal parameter (camera.par, .fieldOfView, .scale), recompute camera matrix. If the last control modified is an incremental parameter (camera.wor, .eye), it is reset to zero, the parameter controls are updated, and the matrix is recomputed. This provides client-base control of the camera, rather than user interaction. The specified control is modified and the camera updated; see above. Return the camera matrix. Return camera.view (camera matrix translated by hScreen and vScreen). Use out if non-NIL. Return the eye view direction given the camera. Save the current, germane camera variables in state. Restore the state variables to the camera. Return the camera most recently adjusted. Return a rope describing the settings of those camera controls that have non-NIL viewers and non-zero settings. Slice Types and Procedures Return a Slice. data is stored in the slice Controls Set the slicer controls and matrix such that slice is in the given plane with the given size. Compute slice.matrix. Draw slice as a three-dimensional rectangle. Move the slice plane in its y-direction by amount. Move the slice plane in its z-direction by amount. Hold Types and Procedures Return set of seven controls for position and orientation. Set hold.dx, hold.dy, hold.dz to position; hold.pitch, hold.yaw and hold.mag to be tangent. Return the current hold position. Return the current hold direction as determined by hold.pitch, hold.yaw, and hold.mag. Interaction with the Display Return index such that screens[index] is nearest screen; screen in pixels. Return -1 if screens = NIL. 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. If mouse.state = down, then select point that is closest on screen to mouse. If pairs is non-NIL, assume it represents points transformed by view. If mouse.state = held, then update the position of the selected point (and pair). No action if mouse.state = up. Miscellaneous Procedures Repaint non-nil controls. Set the controls to the values of the triple and optionally repaint the controls. Κ K•NewlineDelimiter ™™Jšœ Οmœ1™Jšœžœ‘˜9Jšœ ‘˜Jšœžœ‘˜žœžœ˜WJšžœ ˜J™-J™7JšœD™DJ™—š’ œžœ4˜DJ™$J™—š’œžœžœ˜7J™——š ™Iblock™‘ J˜š’œžœ)˜EJ™J˜—š’œžœ=žœ˜aJ™UJ™/J˜—š’œžœ˜Jšœžœ˜Jšœ žœžœžœ˜Jšœ˜Jšœ žœ˜Jšœžœ˜JšœΟbœ˜J˜!Jšœ žœ˜Jšžœ˜J™BJšœΟsœ(™=Jšœ€œ6™IJšœœ™5J™AJ™&J™—š’œžœ=žœ˜XJšžœ˜J™$J˜—š’œžœ+˜IJ™CJ™—š’ œžœ˜J˜J˜Jšœžœ˜Jšœžœžœ˜Jšœžœ˜Jšžœ ˜J™FJ™FJ™—š’œžœ˜2J™VJ™J™aJ™AJ™—š’ œžœ2žœ˜KJ™NJ™DJ˜—š’œžœžœ ˜FJ™J™—š’ œžœ&žœ ˜JJšœU€œ™ZJ™—š’œžœžœ ˜HJ™/J™—š’ œžœ(˜7J™4J™—š’ œžœ(˜:J™*J™—š’œž œ˜8J™)J™—š’œžœžœžœ˜BJ™CJšœ €œ™+——š ™Jšœ žœžœ‘˜Ašœ žœžœ˜Jšœžœ‘˜1Jšœžœ‘˜DJšœ‘˜1Jšœžœ‘˜<˜J˜——š’ œžœžœžœžœžœžœ˜_J™5J™—š’œžœ$žœ˜>J™]J™—š’ œžœ˜!J™J™—š’ œžœ˜J˜J˜ J˜ J˜Jšœ˜J™,J™—š’ œžœžœ˜0J™2J™—š’ œžœžœ˜0J™2——š ™Jšœž œžœ ˜šœžœžœ˜Jšœžœ‘#˜AJšœžœ‘'˜CJšœžœ‘'˜DJšœžœ‘$˜@Jšœžœ‘˜6Jšœžœ‘˜6Jšœžœ‘˜5J˜J˜—š’œžœžœžœžœžœžœ˜MJ™:J™—š’œžœ;˜HJ™[J™—š’œžœžœ ˜5J™!J™—š’œžœžœ ˜6J™V——š ™šœžœžœžœ˜6J˜—š’ œžœ0žœžœ˜RJšœJ™JJšœ€œ™J™—š’ œžœJ˜YJšžœžœ˜J™ZJ™;J™HJ™—š’ œžœ˜J˜Jšœžœ˜J˜ J˜J˜ J˜ Jšžœ˜J™LJšœ€œ2™EJ™QJ™——š ™š’ œžœ$žœ˜