VIEW_MATRIX(3G)
NAME
view_matrix − define a viewing transformation matrix
SYNOPSIS
C Syntax:
void view_matrix2d(fildes,xform2,usage);
int fildes,usage;
float xform2[3][2];
void view_matrix3d(fildes,xform3,usage);
int fildes,usage;
float xform3[4][4];
FORTRAN77 Syntax:
(See Language Dependencies below)
subroutine view_matrix2d(fildes,xform2,usage)
integer*4 fildes,usage
real xform2(2,3)
subroutine view_matrix3d(fildes,xform3,usage)
integer*4 fildes,usage
real xform3(4,4)
Pascal Syntax:
type
two_d_xform = array [1..3][1..2] of real;
three_d_xform = array [1..4][1..4] of real;
procedure view_matrix2d(fildes:integer;
var xform2:two_d_xform;usage:integer);
procedure view_matrix3d(fildes:integer;
var xform2:three_d_xform;usage:integer);
DESCRIPTION
Input Parameters
fildes Integer file descriptor returned by gopen when an I/O path to a graphics device is opened.
xform2 A 3x2 (2-Dimensional) matrix.
xform3 A 4x4 (3-Dimensional) matrix.
usage If set to REPLACE_VW, the old viewing transformation is discarded and the new viewing transformation is the user-supplied matrix concatenated with the vdc-to-device units transformation matrix.
If set to PRE_CONCAT_VW, the user-supplied matrix is pre-concatenated with the current viewing transformation matrix. This result becomes the new viewing transformation matrix.
If set to POST_CONCAT_VW, the user-supplied matrix is post-concatenated with the current viewing transformation matrix. This result becomes the new viewing transformation matrix.
Discussion
view_matrix explicitly defines a new viewing transformation matrix. The functions view_window, view_volume, view_camera, and view_port can also be used to set this matrix using simple 2d window/viewport, 3d volume/viewport, and 3d camera models. If this function is called when one of the above viewing models is in effect, subsequent calls to view_port will not result in a change to the viewing transformation matrix. The viewing transformation matrix is the world-to-device-coordinate transformation, and should include all user-defined non-linear transformations such as perspective. Modeling transformations that affect objects but not the view (such as object translations, rotations, uniform scaling, etc.) should appear in modeling matrices pushed on the matrix stack.
If this function is called when the device is not in MODEL_XFORM mode, the matrix stack is flushed because old transformations based on the viewing transformation are no longer valid. If this function is called when the device is in MODEL_XFORM mode, the viewing matrix (at the bottom of the matrix stack) is changed without changing any of the matrices in the rest of the stack.
The new viewing transformation matrix is formed according to the usage parameter:
• If usage is set to REPLACE_VW, the user-supplied matrix xform2 or xform3 is concatenated with the current vdc-to-device units transformation matrix, resulting in a new viewing transformation matrix (the old matrix is discarded). This concatenation step can be avoided by setting vdc equal to device coordinates (see vdc_extent.)
• If usage is PRE_CONCAT_VW, the specified matrix is pre-concatenated with the current viewing transformation matrix and the result is the new viewing transformation matrix.
• If usage is POST_CONCAT_VW, the new viewing transformation matrix is formed from the post-concatenation of the user supplied matrix with the current viewing transformation matrix.
Post-concatenation should be used very carefully. It is not device-independent because the post concatenation occurs after the vdc-to-device coordinate transformation. The user of this feature should determine the range of device coordinates by using inquire_size.
Starbase maintains all internal matrices in 3-dimensional (4x4) form, so view_matrix2d must expand the 2d matrix xform2.
Since the vdc-to-device units transformation matrix is usually post-concatenated to the end of this matrix, care should be taken when performing perspective transformations. A perspective model where the eye is at origin of perspective space is recommended. Any other model can easily be modified to this perspective model by a single translation step.
The coordinate systems used by Starbase can be conceptually defined as follows:
• User points are assumed to be defined in modeling coordinates. These points are transformed into world coordinates using a matrix called the modeling transformation matrix (if any matrices have been pushed on the stack). World coordinates are used to perform any rendering calculations needed.
• Next, the world coordinates are transformed to device coordinates by the viewing transformation matrix, which is usually the concatenation of user-defined viewing transformations and the vdc-to-device transformation matrix. When a device is opened, the viewing transformation matrix is simply the vdc-to-device coordinate transformation matrix.
Use matrix stack manipulation functions to place modeling transformation matrices on the matrix stack. Use view_matrix to set viewing transformations.
• If a graphics device has been opened in MODEL_XFORM mode, the modeling transformation cannot be combined with the viewing transformation because special rendering calculations such as shading may be needed after the modeling-to-world-coordinate transformation. Therefore, matrices pushed on the stack are left undisturbed and all transformations from modeling coordinates to device coordinates are processed in two steps: modeling to world coordinates, followed by world to device coordinates.
• If a graphics device is not in MODEL_XFORM mode, the modeling and viewing transformations can be combined. Thus, the current viewing transformation matrix is post-concatenated to modeling matrices placed on the matrix stack, and subsequent output primitives are transformed, using only the top matrix on the matrix stack.
When using view_matrix to generate a 3-dimensional perspective view, the viewpoint function should be called to establish the observer’s eye position so that back-cull calculations will be correct.
LANGUAGE DEPENDENCIES
FORTRAN77:
FORTRAN requires a transposition of array rows and columns due to the manner in which FORTRAN77 stores arrays.
DEFAULTS
After gopen or a call to flush_matrices, the current viewing transformation matrix is the vdc-to-device units transformation matrix.
SEE ALSO
view_window(3G), view_volume(3G), view_camera(3G), viewpoint(3G), view_port(3G), vdc_extent(3G), inquire_sizes(3G), gopen(3G), flush_matrices(3G),
Starbase Graphics Techniques.
Hewlett-Packard Company — May 11, 2021