Class RenderMapsContext

3DS Max Plug-In SDK

Class RenderMapsContext

See Also: Class INode, Class ViewParams, Structure SubRendParams, Class Matrix3, Class Box3, Class Point4, Class Bitmap, Class RenderGlobalContext.

class RenderMapsContext

Description:

An instance of this class is passed into the MtlBase::BuildMaps() method. This is used for the Mirror and Automatic Cubic maps. These maps callback to methods of this class to perform a rendering from a particular view. Sample code using these methods is available in \MAXSDK\SAMPLES\MATERIALS\MIRROR.CPP and ACUBIC.CPP. All methods of this class are implemented by the system.

Methods:

Prototype:

virtual INode *GetNode()=0;

Remarks:

Returns the INode pointer of the node being rendered. This pointer allows a developer to access the properties of the node. See Class INode.

Prototype:

virtual int NodeRenderID()=0;

Remarks:

Returns the node ID for the item being rendered or -1 if not set. This ID is assigned when the scene is being rendered - each node is simply given an ID: 0, 1, 2, 3, etc. The NodeRenderID() is simply a number automatically assigned to every node being rendered so that they can be differentiated in texture maps such as the Auto-cubic, which needs to store a cubic map for each node it is applied to.

Prototype:

virtual void GetCurrentViewParams(ViewParams &vp)=0;

Remarks:

Retrieves the current view dependent parameters.

Parameters:

ViewParams &vp

The ViewParams instance to update.

Prototype:

virtual void GetSubRendParams(SubRendParams &srp)=0;

Remarks:

Retrieves the sub-render parameters.

Parameters:

SubRendParams &srp

The SubRendParams instance to update.

Prototype:

virtual int SubMtlIndex()=0;

Remarks:

Returns the current sub material index or -1 if at node material level.

Prototype:

virtual void FindMtlPlane(float pl[4])=0;

Remarks:

Computes the plane containing the current material or sub material. This is used by the Flat Mirror material.

Parameters:

float pl[4]

The plane containing the current material or sub material. The four float values in pl[4] represent the plane equation. If you call the four values A,B,C and D, then the plane equation of the plane is Ax + By + cZ + D = 0.

Prototype:

virtual void FindMtlScreenBox(Rect &sbox, Matrix3* viewTM=NULL, int mtlIndex=-1)=0;

Remarks:

This method computes the rectangle in screen space of the specified material. This uses the viewTM, but assumes the remaining view params (devWidth, devHeight, devAspect, fov) are the same as the main render. This method is specific to the Flat Mirror material.

Parameters:

Rect &sbox

The resulting 2D box.

Matrix3* viewTM=NULL

The view matrix.

int mtlIndex=-1

The material index, or -1 if a node level material.

Prototype:

virtual Box3 CameraSpaceBoundingBox()=0;

Remarks:

This method is available in release 2.0 and later only.

This method computes the bounding box in camera space of the object associated with the reflection or refraction map being built in a call to a map's BuildMaps() method.

Prototype:

virtual Box3 ObjectSpaceBoundingBox()=0;

Remarks:

This method is available in release 2.0 and later only.

This method computes the bounding box in object space of the object associated with the reflection or refraction map being built in a call to a map's BuildMaps() method.

Prototype:

virtual Matrix3 ObjectToWorldTM()=0;

Remarks:

This method is available in release 2.0 and later only.

This method returns the object to world transformation.

Prototype:

virtual RenderGlobalContext *GetGlobalContext();

Remarks:

This method is available in release 2.0 and later only.

Returns a pointer to a class that describes properties of the rendering environment.

Prototype:

virtual int Render(Bitmap *bm, ViewParams &vp, SubRendParams &srp, Point4 *clipPlanes=NULL, int nClipPlanes=0)=0;

Remarks:

Renders the scene and stores in the result into bm.

Parameters:

Bitmap *bm

The Bitmap to render the result to. The properties of this bitmap define the properties of the render (such as the width and height).

ViewParams &vp

The ViewParams.

SubRendParams &srp

The SubRendParams.

Point4 *clipPlanes=NULL

This revised parameter is available in release 2.0 and later only.

This is a pointer to an array of Point4s, each of which represents a clip plane. If it is non-null, the renderer will clip all objects against these planes in addition to the normal left/right/top/bottom clipping. This is used by the Mirror material to clip away stuff that is behind the mirror. If not needed this may default to NULL.

int nClipPlanes=0

This parameter is available in release 2.0 and later only.

The number of clipping planes above. A maximum of 6 is possible.

Return Value:

Nonzero on success; otherwise zero.

Prototype:

virtual INT_PTR Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0);

Remarks:

This method is available in release 2.0 and later only.

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 arg1=0

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

ULONG arg2=0

Optional argument 2.

ULONG arg3=0

Optional argument 3.

Return Value:

An integer return value. See the documentation where the cmd option is discussed for more details on the meaning of this value.