Interaction Modes

Remarks

The COpenGL class interaction mode specifies the way the COpenGL object interacts with the user’s mouse and keyboard actions in the object window. The result of such interaction are COpenGL object’s view projection changes.

The COpenGL class implementation offers the following interaction modes:

IM_NONE User mouse and keyboard actions have no effect on object’s projection in this interaction mode
IM_SELECT_OBJECT Allows object selection. Object will be selected when clicking on it in the object window by the left mouse button. Two callbacks functions must be provide by calling SetSelectProcedure and SetSelectObjectCallback in order to support this mode. If CTRL key is pressed while selecting an object, then also reference point is moved to object’s center point.
IM_ZOOM_WINDOW Allows to specify a rectangular area in the object window for zoom in or zoom out.

The way to specify the rectangular area depends on the current COpenGL projection type.

Orthographic projection

To specify the rectangle press, the left mouse button in the object window to specify one of the rectangle corners, drag the mouse pointer to the opposite rectangle corner and release the left mouse button.

Perspective projection

With perspective projection it is possible to specify only such rectangles that have the same center point as the object window center point. To specify the rectangle, press the left mouse button in the object window to specify one of the rectangle edges. Drag the rectangle edge to the desired location. To confirm the rectangle shape, release the left mouse button.

The COpenGL object itself provides a display of a current rectangle shape while dragging the mouse pointer. When zoom out is required, then the COpenGL object indicates it by displaying lines from object window corners to the rectangle corners. It “intuitively” indicates that the zoom out action will be performed.

According to the state of the key specified by the ZoomOutModifierKey item of ControlInfo structure, the projection is set to zoom the specified area to the whole window (zoom in, ZoomOutModifierKey key not pressed) or to zoom the current window extent to the specified area (zoom out, ZoomOutModifierKey key pressed)

If zoom in is required, then the view projection will be changed to fit the graphic data visible in the specified rectangle into the whole object window. If zoom out is required, then the object’s view projection will be changed to fit graphic data visible in the whole object window into the specified rectangle.

The zoom window projection change moves reference point to the center of the specified rectangular area. The eye point is moved by the same translation as the reference point is moved. Then the eye point is moved toward or from the reference point depending whether zoom in or zoom out is required. The looking direction and up direction vectors remain unchanged.

IM_PAN

Allows to move the graphic data displayed in the object window .

Click with the left mouse button in the object window and drag your ‘click point’ inside of the window. The COpenGL object generates the view projection changes according to the mouse drag action. The reference point is moved inside the virtual plane parallel with the computer screen exactly by the same way as the ‘click point’ is dragged in the object window. The eye point is moved by the same translation as the reference point is moved. The looking direction and up direction vectors remain unchanged.

IM_VIEW ROTATE

Allows the rotation of the eye point around the reference point. This mode is sometimes called a ‘space ball mode’.

To specify the eye point rotation, first imagine the 3D ball in the center of the object window. The ball has a diameter to entirely fit into the object window . With the left mouse click, dragging the ‘click point’ to the new location, you can specify the same rotation action as you would when touching the virtual ball in the ‘click point’ and rotating it around its center by moving the touched point.

The rotate projection change keeps the reference point coordinates. The eye point is rotated around the reference point. The distance from the eye point to the reference point is kept. The looking direction and up direction vectors are changed according to the specified rotation.

IM_FLY

In this interaction mode the mouse cursor is hidden, mouse left and right movements are translated to look left and right view changes, mouse forward and back movements are translated to look up and down view changes. If ControlInfo’s MouseBankModifier key is pressed, the left mouse movement is translated to bank view to left, right mouse movement to bank view to right. In contrast with IM_ROTATE mode, during the view rotation in IM_FLY mode, the eye point remain fixed, and reference point is changing. This mode can be used to simulate plane or space ship like navigation through the scene.

IM_FREE_LOOK

This interaction mode is about the same as Free Look mode in Quake (and some other) games. This mode is similar to IM_FLY mode, except that in IM_FREE_LOOK mode it is not possible to look up/down beyond a fixed “gravity vector”, and that axis used to look left and right is always parallel with the “gravity vector”. This simulates human perception of space in “environments with ground and gravity”. The “gravity vector” is fixed opposite to up direction , which was current when IM_FREE_LOOK mode started. You can alter the “gravity vector” while in IM_FREE_LOOK mode by setting up the up direction by SetUpDirection method.

With each COpenGL object’s view projection change the object invalidates the whole object window client area by using Win32 API InvalidateRect function.

See Also

SetInteractionMode, GetInteractionMode