Class View

3DS Max Plug-In SDK

Class View

See Also: Class GeomObject, Class Interface, Class Control, Class Matrix3, Class Point3.

class View : public InterfaceServer

Description:

This class is passed in to GeomObject::GetRenderMesh() to allow objects to do view dependent rendering. It is also passed to Control::EvalVisibility().

For example particle systems use this to have the particles exactly face the camera (if this option is enabled). If GetRenderMesh() is called by the renderer, the methods of this class are implemented by the system. If a plug-in is calling this method, they must implement these methods. The sample code below shown a null implementation that may be used if a viewport is not involved:

class NullView : public View {

public:

Point2 ViewToScreen(Point3 p)

{ return Point2(p.x,p.y); }

NullView() {

worldToView.IdentityMatrix();

screenW=640.0f; screenH = 480.0f;

}

};

Data Members:

public:

float screenW, screenH;

These hold the screen dimensions in pixels for width and height.

Matrix3 worldToView;

A transformation matrix from world into view space. This is into the camera's space.

int projType;

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

The view projection type: 0 is perspective, 1 is parallel.

float fov;

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

The field of view in radians.

float pixelSize;

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

The pixel size setting.

Matrix3 affineTM;

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

This is the world to camera transformation matrix.

DWORD flags;

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

The following flag is defined.

RENDER_MESH_DISPLACEMENT_MAP

Indicates that Displacement Mapping is enabled. Note that this flag should be tested, and not Interface::GetRendDisplacement(), because the values may not be the same (for instance when rendering in the Materials Editor).

Methods:

Prototype:

virtual Point2 ViewToScreen(Point3 p)=0;

Remarks:

This method is used to convert a point in view space to screen space. This includes any perspective projection.

Parameters:

Point3 p

The point in view space.

Return Value:

The point in screen space (in pixel coordinates).

Prototype:

virtual BOOL CheckForRenderAbort();

Remarks:

This method is available in release 3.0 and later only.

This method should be used by GetRenderMesh() implementations that require a lot of processing time. This allows these processes to be interupted by the user. An example of this in use is the extensive computations done for displacement mapping. These may be interrupted by the user during a render.

So, any implementation of GetRenderMesh() which takes a long time should periodically call this method to see if the user has canceled the render

Return Value:

Returns TRUE iff user has cancelled; otherwise FALSE.

Default Implementation:

{ return FALSE; }