Brief Index      Full Index      Events Index      I.M. Reference

Show_Selection_Position


Functions

void Show_Selection_Position (float *window_x, float *window_y, float *window_z, float *camera_x, float *camera_y, float *camera_z)
void DShow_Selection_Position (float *window_x, float *window_y, float *window_z, double *camera_x, double *camera_y, double *camera_z)

Function Documentation

void Show_Selection_Position ( float *  window_x,
float *  window_y,
float *  window_z,
float *  camera_x,
float *  camera_y,
float *  camera_z 
)

Shows the position that has just been used to select something. The position is returned in terms of both window coordinates and world coordinates.

Parameters:
window_x - The x screen position in terms of the innermost and front most containing window. Values are in the range of -1 to 1 within that window. Passed by reference always. Returned to user.
window_y - The y screen position, as above. Passed by reference. Returned to user.
window_z - The z screen position, as above. Passed by reference. Returned to user.
camera_x - The screen position in terms of the view of the world seen by the camera. Please see below for details. Passed by reference always. Returned to user.
camera_y - The y screen position, as above. Passed by reference. Returned to user.
camera_z - The z screen position, as above. Passed by reference. Returned to user.

DETAILS

Once a "selection" event has reached the front of the event queue and become the current event, your program can ask for details about it. One of the details available is the exact screen position that the user was pointing at.

Show_Selection_Position returns this position in two different forms. The window coordinates are in terms of the immediate containing HOOPS window---if the user were pointing at the upper-left corner of a window on the screen, for example, window_x would be -1 and window_y would be +1. (See below for a discussion on window_z.)

The "camera-relative" coordinates are given in terms of what that screen position means with respect to your virtual camera's view of the system's world coordinates. This coordinate system is the one you're using when you specify and insert 3-D lines, polygons, and so forth into your scene. It's the coordinate system of the scene itself.

The conversion from screen coordinates to world coordinates is made by assuming that the Camera Position corresponds to your viewing position and that the Camera Target corresponds to the center front of the physical screen window. The actual screen positions then defines a "line of sight" passing through your 3-D scene.

If a piece of geometry was selected (see Show_Selection_Element() ), then (camera_x, camera_y, camera_z) represents the point at which this virtual line of sight passes closest to or through the selected geometry, in world coordinates. If only a window was selected, then (camera_x, camera_y, camera_z) is the point where the line of sight intersects the "camera reference plane"---i.e., the plane that contains the current Camera Target and is perpendicular to the camera axis.

window_z requires some explanation. In an orthographic world, the "window Z" is defined in HOOPS to be zero at the camera target and -1 at the camera position. Other values are linear extrapolations or interpolations. In a perspective-camera world, there is an "intermediate" inter_z and inter_w which give window_z as

perspect.gif

inter_z is defined as above to be zero at the camera target and -1 at the camera position. inter_w is defined to be +1 at the camera target and zero at the camera position. Thus window_z at the target will be zero; window_z halfway between the target and the position will be -1.0. window_z right at the camera will be - infinity, and the window_z of a far distant object will approach +1.0.

NOTES

World space selection operations, such as Compute_Selection_By_Ray() , and Compute_Selection_By_Shell() do not have associated cameras and windows. For such operations, world space coordinates will be filled into the place of window_x, window_y, and window_z. In the case of Compute_Selection_By_Ray() , the camera_z will be replaced by the parametric value along the ray of the intersection point -- in other words the distance from ray start to intersection divided by the ray's length. At the time of this writing, however, position information for Compute_Selection_By_Shell has not yet been implemented.

The camera used for computations is that in effect for the segment named by Show_Selection() and Show_Selection_Pathname() .

A "line of sight" vector can be defined by (camera_x, camera_y, camera_z) minus the Camera Position.

If you've been using subwindows, you can gain whole-screen coordinates by calling QShow_Net_Window() on the segment named by Show_Selection_Pathname() . Then convert the local window coordinates. If you've been using modelling matrices, you can gain "object space" coordinates by calling QShow_Net_Modelling_Matrix() on the segment named by Show_Selection_Pathname() . Then convert the world coordinates. Or you can just call Compute_Coordinates() to do the work.

Show_Selection_Position() is not equivalent to Show_Location() . Show Location goes with "location" events, not selection events. Also, location events differ in that they represent the locater device's "raw" coordinates, and have no knowledge of segments, cameras, windows, or even display screens.

RESTRICTIONS

See also:
Await_Event, Compute_Selection_By_Ray, Compute_Selection_By_Shell, Get_Selection, Enable_Selection_Events, Show_Selection, Show_Selection_Element, Show_Selection_Pathname, Show_Selection_Keys, Show_Selection_Source, Show_Location, Show_Net_Window, Show_Net_Camera_Position, Compute_Coordinates, Compute_Transform.

void DShow_Selection_Position ( float *  window_x,
float *  window_y,
float *  window_z,
double *  camera_x,
double *  camera_y,
double *  camera_z 
)

Similar to Show_Selection_Position(), but operates on double-precision data.

Parameters:
window_x - The x screen position in terms of the innermost and front most containing window. Values are in the range of -1 to 1 within that window. Passed by reference always. Returned to user.
window_y - The y screen position, as above. Passed by reference. Returned to user.
window_z - The z screen position, as above. Passed by reference. Returned to user.
camera_x - The screen position in terms of the view of the world seen by the camera. Please see below for details. Passed by reference always. Returned to user.
camera_y - The y screen position, as above. Passed by reference. Returned to user.
camera_z - The z screen position, as above. Passed by reference. Returned to user.

Brief Index      Full Index      Events Index      I.M. Reference