Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

clip_depth(3G)

depth_cue_range(3G)

flush_matrices(3G)

gopen(3G)

inquire_sizes(3G)

view_window(3G)

view_volume(3G)

view_camera(3G)

viewpoint(3G)

view_port(3G)

vdc_extent(3G)

view_matrix(3G)

NAME

intview_matrix2d, view_matrix2d, view_matrix3d − define a viewing transformation matrix

SYNOPSIS

C Syntax:

void intview_matrix2d(fildes,xform2,radix,usage,raw);
int fildes,usage,xform2[3][2],radix,usage,raw;

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 intview_matrix2d(fildes,xform2,radix,usage,raw)
integer*4 fildes,xform2(2,3),radix,usage,raw

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
int2d_xform=array[1..3][1..2] of integer;
two_d_xform=array[1..3][1..2] of real;
three_d_xform=array[1..4][1..4] of real;

procedure intview_matrix2d(fildes:integer; var xform2:int2d_xform;radix,usage,raw:integer);

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. 

radix is the radix factor for the 3x2 integer 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. 

raw If set to TRUE(1), integer matrices will be in internal (raw) format (i.e. translation values are not scaled). 
If set to FALSE(0), all integer matrix values are scaled.

Discussion

View_matrix explicitly define a new viewing transformation matrix.  The functions intview_window, intview_port, 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 or intview_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.  Modelling transformations that affect objects but not the view (such as object translations, rotations, uniform scaling, etc.)  should appear in modelling matrices pushed on the matrix stack. 

When view_matrix is called, 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 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 and intvdc_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_sizes.

Starbase maintains all internal floating point  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 modelling coordinates.  These points are transformed into world coordinates using a matrix called the modelling transformation matrix (if any matrices have been pushed on the stack).  World coordinates are used to perform any rendering calculations needed. 

• 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.  View_window, view_port, view_matrix, view_volume, view_camera, intview_window, intview_port, and intview_matrix2d can be used to define further viewing transformations. 

Use matrix stack manipulation functions to place modelling 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 modelling transformation cannot be combined with the viewing transformation because special rendering calculations such as shading may be needed after the modelling-to-world-coordinate transformation.  Therefore, matrices pushed on the stack are left undisturbed and all transformations from modelling coordinates to device coordinates are processed in two steps:  modelling to world coordinates, followed by world to device coordinates. 

• If a graphics device is not in MODEL_XFORM mode, the modelling and viewing transformations can be combined.  Thus, the current viewing transformation matrix is post-concatenated to modelling 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.  In addition, clip_depth should be called to determine front and back clip planes, and depth_cue_range should be called to set the range of the depth cue. 

Integer transformation matrices are scaled to allow a fractional portion for rotating objects.  The radix factor indicates the number of bits to the right of the decimal point.  Legal limits are 0 to 30.  Once a coordinate has been transformed, it is divided by 2**radix to return to an integer value. 

When using raw mode with an integer matrix positions (3,1) and (3,2) have an implied radix factor of 0 (no scaling).  This allows large translation ranges along with accurate rotations. 

Integer operations are only available when using the INT_XFORM gopen mode.  When in INT_XFORM mode Floating point operations are not available for that fildes.  Floating point operations are the default, or can be specified with FLOAT_XFORM mode.  For a list of Integer operations, Floating point operations and common operations see the starbase.3g manual page. 

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

clip_depth(3G), depth_cue_range(3G), flush_matrices(3G), gopen(3G), inquire_sizes(3G), view_window(3G), view_volume(3G), view_camera(3G), viewpoint(3G), view_port(3G), vdc_extent(3G), Starbase Graphics Techniques. 

Hewlett-Packard Company  —  HP-UX Release 9.03: April 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026