Class Renderer

3DS Max Plug-In SDK

Class Renderer

See Also: Class ReferenceTarget, Class FrameRendParams, Class RendProgressCallback, Class IRendParams, Class INode, Class ViewParams, Class RendParamDlg, Class RendParams, Class DefaultLight.

class Renderer : public ReferenceTarget

Description:

This is the base class for the creation of plug-in renderers. There are five methods that need to be implemented: Open(), Render(), Close(), CreateParamDialog() and ResetParams().

In 3ds max 2.0 and later developers must also implement ReferenceTarget::Clone() to support the new Production/Draft renderer capability.

Methods:

Prototype:

virtual int Open(INode *scene, INode *vnode,ViewParams *viewPar,RendParams &rp, HWND hwnd, DefaultLight* defaultLights=NULL,int numDefLights=0)=0;

Remarks:

Implemented by the Plug-In.

This method is called once per render. It gives the renderer a chance to build up any data structures which it will use over the course of the render.

Parameters:

INode *scene

The root node of the scene to render. Note: If you are rendering in the Materials Editor, you'll instead get a pointer to the INode that is in the sample slot -- not the root node.

INode *vnode

The view node. This may be a camera, a light, or NULL.

ViewParams *viewPar

View parameters for rendering orthographic or user viewports. This is used if *vnode is NULL.

RendParams &rp

This class contains a set of common renderer parameters.

HWND hwnd

The owner window for messages.

DefaultLight* defaultLights=NULL

An array of default lights if there are no user created lights in the scene.

int numDefLights=0

Number of lights in defaultLights array.

Return Value:

Nonzero for success, zero for failure.

Prototype:

virtual int Render(TimeValue t, Bitmap *tobm, FrameRendParams &frp, HWND hwnd, RendProgressCallback *prog=NULL, ViewParams *viewPar=NULL)=0;

Remarks:

Implemented by the Plug-In.

This method is called to render a frame. It should use the camera or view passed to the Open() method. This is called once per frame, and the resulting rendered image is written to tobm.

Parameters:

TimeValue t

The frame to render.

Bitmap *tobm

This is the target bitmap. The properties of the bitmap define the render width, height and aspect. See Class Bitmap.

FrameRendParams &frp

A set of time dependent parameters.

HWND hwnd;

The owner window handle.

RendProgressCallback *prog=NULL

A callback used to allow the renderer to update the rendering dialog. The renderer may call methods of this class.

ViewParams *viewPar=NULL

This parameter is available in release 2.0 and later only.

This parameter allows you to specify a different view transformation on each render call. For example, you can render a given scene at a given time from many different viewpoints, without calling Render::Open() for each one.

Return Value:

Nonzero for success, zero for failure.

Prototype:

virtual void Close (HWND hwnd)=0;

Remarks:

Implemented by the Plug-In.

This method is called once when rendering is done. This is where the renderer frees any data structures being held on to. This includes things such as shadow buffers, render-ready meshes, lists of materials, etc.

Parameters:

HWND hwnd

The owner window handle.

Prototype:

virtual bool ApplyRenderEffects(TimeValue t, Bitmap *pBitmap, bool updateDisplay=true);

Remarks:

This method is available in release 4.0 and later only.

This method is called to apply the render effects at the specified time value. It should be called between the Open() and Close() methods.

This can be used during a multi-pass rendering, in order to apply the render effects to the final, blended bitmap.

Parameters:

TimeValue t

The time to apply the render effects.

Bitmap *pBitmap

Points to the bitmap.

bool updateDisplay=true

Passing true indicates that Bitmap's display should be refreshed by the renderer; false indicates it should not be.

Return Value:

Returns true if the effects were successfully applied; otherwise false.

Default Implementation:

{ return false; }

Prototype:

virtual RendParamDlg *CreateParamDialog(IRendParams *ir,BOOL prog=FALSE)=0;

Remarks:

Implemented by the Plug-In.

This method is called to create and return a pointer to an instance of the RendParamDlg class. The renderer can add rollup page(s) to the renderer configuration dialog using the IRendParams interface passed into this method.

Parameters:

IRendParams *ir

An interface that provides methods for use in displaying parameters, for example this class has methods for adding rollup pages.

BOOL prog=FALSE

If TRUE then the rollup page should just display the parameters so the user has them for reference while rendering, they should not be editable.

Return Value:

A pointer to an instance of the RendParamDlg class. This class will be deleted using RendParamDlg::DeleteThis().

Prototype:

virtual void ResetParams()=0;

Remarks:

Implemented by the Plug-In.

This method simply sets all the parameters to their default values.