Viewport Info
Availability LightWave® 7.5
Component Layout
Header lwrender.h
The viewport info global returns information about the state of Layout's OpenGL
viewports. The data is read-only, but you can set the parameters using
navigation and display
commands.
Global Call
LWViewportInfo *vpinfo;
vpinfo = global( LWVIEWPORTINFO_GLOBAL, GFUSE_TRANSIENT );
The global function returns a pointer to an LWViewportInfo.
typedef struct st_LWViewportInfo {
int numViewports;
int (*type) (int);
unsigned int (*flags) (int);
void (*pos) (int, LWDVector);
void (*xfrm) (int, double mat[9]);
void (*clip) (int, double *hither, double *yon);
void (*rect) (int, int *left, int *top, int *width, int *height);
int (*viewLevel) (int);
int (*projection) (int, LWDMatrix4 projection, LWDMatrix4 inverse_projection);
int (*modelview) (int, LWDMatrix4 modelview, LWDMatrix4 inverse_modelview);
int (*project) (int, LWDVector world, double *winx, double *winy, double *winz);
int (*unproject) (int, double winx, double winy, double winz, LWDVector world);
double (*pixelSize) (int, double pixels, LWDVector refpos);
int (*handleSize) (int);
double (*gridSize) (int);
LWItemID (*viewItem) (int);
} LWViewportInfo;
- numViewports
-
The number of viewports visible in the Layout interface.
view = type( i )
-
The type of view in the ith viewport. It will be one of the
following:
-
LVVIEWT_NONE
-
LVVIEWT_TOP
-
LVVIEWT_BOTTOM
-
LVVIEWT_BACK
-
LVVIEWT_FRONT
-
LVVIEWT_RIGHT
-
LVVIEWT_LEFT
-
LVVIEWT_PERSPECTIVE
-
LVVIEWT_LIGHT
-
LVVIEWT_CAMERA
-
LVVIEWT_SCHEMATIC
flags = flags( i )
-
Returns a set of bit flags for the ith viewport. These can be
any combination of the following.
LWVIEWF_CENTER
LWVIEWF_WEIGHTSHADE
LWVIEWF_XRAY
- pos(i, spot)
-
Fills the spot vector with the viewing position of the ith
viewport.
-
- xfrm( i, mat[9] )
-
Fills mat with a 3x3 transformation from viewport coordinates to world
coordinates for the ith viewport. Note that from LW9.0, the
vpinfo->projection() and vpinfo->modelview() functions should be preferred,
as the vpinfo->xfrm() function may not produce correct results for non-perspective
camera views.
-
clip( i, &hither, &yon )
-
Fills hither and yon with the near and far Z clipping
distances for the ith viewport.
rect( i, &left, &top, &width, &height )
-
Fills left, top, width and height with pixel coordinates of
the ith viewport.
-
level = viewLevel( i )
-
Returns the view level for the ith viewport. The returned
value is one of the LWOVIS_* values.
-
result = projection( i, projection, inverse_projection )
-
Fills the matrices with the projection matrix and the inverse of
the projection matrix for the ith viewport. It is safe to
pass in NULL for either of the matrices. The matrices follow the
OpenGL convention of m[column][row] with column vectors. Returns 1
if the asked for matrices were retrieved, 0 on failure which usually means that an inverse
matrix was asked for for a matrix that could not be inverted.
-
result = modelview( i, modelview, inverse_modelview )
-
Fills the matrices with the modelview matrix and the inverse of
the modelview matrix for the ith viewport. It is safe to
pass in NULL for either of the matrices. The matrices follow the
OpenGL convention of m[column][row] with column vectors. Returns 1
if the asked for matrices were retrieved, 0 on failure which usually means that an inverse
matrix was asked for for a matrix that could not be inverted.
-
result = project( i, world, &winx, &winy, &winz )
-
Computes the projected position of the given world coordinates for the ith
viewport. The computed winx and winy position is in pixels, relative to
the upper-left corner of the viewport.
Returns 1 if the projection was successful, 0 otherwise. Note that the resulting
coordinates may fall outside of the viewport.
-
result = unproject( i, winx, winy, winz, world )
-
Computes the world coordinates of a given pixel position of the ith
viewport. The winz value ranges from 0 for a spot on the near clipping plane,
to 1 for a spot on the far clipping plane. Note that drawing on the near or far clipping
plane may cause flickering due to floating point imprecision causing random clipping.
Returns 1 if the projection was successful, 0 otherwise. Failure is typically caused by
the viewport having a non-invertible modelview or projection matrix.
-
size = pixelSize( i, pixels, refpos )
-
Returns the world size of the given number of pixels at the reference position in world for
the ith viewport.
A sphere with a diameter of the returned size, placed at the reference position, will have
a diameter of approximately the given number of pixels when projected.
-
size = handleSize( i )
-
Returns the standard handle size for the ith viewport, in pixels.
This is the size used for example for drawing the translation and rotation tool handles.
size = gridSize( i )
-
Returns the size of the grid spacing for the ith viewport, in metres.
-
item = viewItem( i )
-
For viewports which have a view through a scene item (LWVIEWT_LIGHT and LWVIEWT_CAMERA)
the ID of the item is returned. Otherwise LWITEM_NULL is returned.
|