Public Member Functions | Public Attributes

ViewParams Class Reference

Search for all occurrences

Detailed Description

Describes the properties of a view that is being rendered.

These are properties such as the type of view (parallel or perspective), its clipping distances, width, height, zoom factor, field-of-view, etc.

Data Members:
Matrix3 prevAffineTM;

This is the world space to camera space transformation matrix computed 2 ticks before the affineTM matrix below.

Matrix3 affineTM;

This matrix will take a point in world space and convert it to camera space (or world to view space if it's a viewport). The camera coordinates are set up looking down the -Z axis, X is to the right, and Y is up.

int projType;

One of the following values:

PROJ_PERSPECTIVE

The view is a perspective projection.

PROJ_PARALLEL

The view is a parallel projection.

float hither, yon;

The hither and yon clipping distances.

float distance;

This data member is available in release 3.0 and later only.

The distance from the view point to the image (view) plane.

float zoom;

The zoom factor of the viewport for parallel projection. The zoom factor gives the amount of magnification relative to a standard view width of 400 pixels. This is best explained via the following code fragment: ComputeViewParams() computes the projection factors for a given view, and MapToScreen() applies these factors to map a point from 3D camera coordinates to 2D screen coordinates.
#define VIEW_DEFAULT_WIDTH ((float)400.0)
void SRendParams::ComputeViewParams(const ViewParams&vp)
{
    if (vp.projType == PROJ_PERSPECTIVE) {
        float fac = -(float)(1.0 / tan(0.5*(double)vp.fov));
        xscale = fac*dw2;        // dw2 = float(devWidth)/2.0
        yscale = -devAspect*xscale;
    }
    else {
        xscale = (float)devWidth/(VIEW_DEFAULT_WIDTH*vp.zoom);
        yscale = -devAspect*xscale;
    }
}

Point2 SRendParams::MapToScreen(Point3 p)
{
    Point2 s;
    if (proj_type==PROJ_PERSPECTIVE) {
        s.x = dw2 + xscale*p.x/p.z;
        s.y = dh2 + yscale*p.y/p.z;
    }
    else {
        s.x = dw2 + xscale*p.x;
        s.y = dh2 + yscale*p.y;
    }
    return s;
}
float fov;

Field of view in radians for perspective projections.

float nearRange;

This data member is available in release 2.0 and later only.

The near environment range setting (used for fog effects).

float farRange;

This data member is available in release 2.0 and later only.

The far environment setting (used for fog effects).
See also:
Class Matrix3, Class Renderer, Class RendParams.

#include <render.h>

Inheritance diagram for ViewParams:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual INT_PTR  Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
  This is a general purpose function that allows the API to be extended in the future.

Public Attributes

Matrix3  prevAffineTM
Matrix3  affineTM
int  projType
float  hither
float  yon
float  distance
float  zoom
float  fov
float  nearRange
float  farRange

Member Function Documentation

virtual INT_PTR Execute ( int  cmd,
ULONG_PTR  arg1 = 0,
ULONG_PTR  arg2 = 0,
ULONG_PTR  arg3 = 0 
) [inline, virtual]

This is a general purpose function that allows the API to be extended in the future.

The 3ds Max development team can assign new cmd numbers and continue to add functionality to this class without having to 'break' the API.

Parameters:
int cmd

The index of the command to execute.

ULONG_PTR arg1=0

Optional argument 1. See the documentation where the cmd option is discussed for more details on these parameters.

ULONG_PTR arg2=0

Optional argument 2.

ULONG_PTR arg3=0

Optional argument 3.
Returns:
An integer return value. See the documentation where the cmd option is discussed for more details on the meaning of this value.
{ return 0; } 

Member Data Documentation

int projType
float hither
float yon
float distance
float zoom
float fov
float nearRange
float farRange

ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams
ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams ViewParams