Class MaxBakeElement

3DS Max Plug-In SDK

Class MaxBakeElement

See Also: Class IRenderElement , Class MaxRenderElement

class MaxBakeElement : public MaxRenderElement

Description:

This class is only available in release 5 or later.

The class provides the interfaces for creating a Texture Baking plugins in 3ds max. The texture baking plugins are controlled through the Maxscript “Render To Texture”. There are methods available in this class that provide the ability to produce a dynamic UI in Maxscript.

This class provides the basic infrastructure for the UI and Maxscript interaction, to fully understand the workings of these plugins please look at the RenderElement samples

 

For an example of this class in use by Texture Baking plug-ins see \MAXSDK\SAMPLES\RENDER\RENDERELEMENTS\INCLUDE\STDBAKEELEM.CPP

 

All methods of this class are implemented by the plug-in.

 

Methods:

Prototype:

virtual void SetOutputSz( int xSz, int ySz ) = 0

 

Remarks:

Set the size of the bitmap to be created

 

Parameters:

int xSz

Specifies the width of the output.

int ySz

Specifies the height of the output.

 

 

Prototype:

virtual void GetOutputSz( int& xSz, int &ySz ) = 0

 

Remarks:

Get the size of the bitmap to be created

 

Parameters:

int& xSz

The new width

int& ySz

the new height

 

Prototype:

virtual void SetFileName( TCHAR* newName) = 0

Remarks:

This is the name used in the UI, so it does not consist of the path – just the actual file name

 

Parameters:

TCHAR* newName

The name to set for the UI

 

Prototype:

virtual TCHAR * GetFileName()const = 0

 

Remarks:

Returns the actual filename. See remark above

 

Prototype:

virtual void SetFileType( TCHAR* newType) = 0

 

Remarks:

This is full name of the file including path, that is used by the renderer to actually create the bitmap to store the baked element. This should not really be set as it is created dynamically for sole use by the renderer.

 

Parameters:

TCHAR* newType

The name for the full file name

 

Prototype:

virtual const TCHAR* GetFileType() const = 0

 

Remarks:

Returns the filename used for this baked element – See comment above

 

Prototype:

virtual void SetFileNameUnique(BOOL on) = 0

Remarks:

 

 

Prototype:

virtual BOOL IsFileNameUnique() const = 0

Remarks:

 

Prototype:

virtual void SetRenderBitmap( Bitmap* pBitmap ) = 0

 

Remarks:

The render will create a bitmap from the data available and will pass the Bitmap to the plugin. This will be the Bitmap the max actually uses to render to.

 

Parameters:

Bitmap* pBitmap

The bitmap used for the output

 

Prototype:

virtual Bitmap* GetRenderBitmap() const = 0

 

Remarks:

Returns the bitmap containing the final output

 

Prototype:

virtual void SetLightApplied(BOOL on) = 0

 

Remarks:

This defines whether the baker uses lighting or not. For example a diffuse texture baker can specify whether the result uses lighting or not.

 

Parameters:

BOOL on

The state for the lighting parameter

 

Prototype:

virtual BOOL IsLightApplied() const = 0

Remarks:

Returns whether lighting is used in the calculation

 

 

Prototype:

virtual void SetShadowApplied(BOOL on) = 0

 

 

Remarks:

This defines whether the baker uses shadows or not. For example a diffuse texture bake can specify whether the result uses shadows or not.

 

Parameters:

BOOL on

The state for the shadow parameter

 

Prototype:

virtual BOOL IsShadowApplied() const = 0

 

 

Remarks:

Returns whether shadows are used in the calculation

 

Prototype:

virtual void SetAtmosphereApplied(BOOL on) = 0

 

 

Remarks:

Defines whether the texture baking uses Atmosphere in the final result.

 

Parameters:

BOOL on

Specifies whether Atmospheres are used or not.

 

Prototype:

virtual BOOL IsAtmosphereApplied() const = 0

 

Remarks:

Returns whether Atmospheres are used. Most texture baking plugins would return false.

 

The following methods are used for the creation of the Maxscript UI in the Render To Texture tool

 

Prototype:

virtual int GetNParams() const = 0

 

Remarks:

Return the number of parameters to be exposed to the UI

 

 

Prototype:

virtual const TCHAR* GetParamName( int nParam ) = 0

 

Remarks:

Returns the name used by maxscript for the parameter value passed in. This is a 1 based access, so if GetNParams returned 8 the valid range for GetParamName will be 1 to 8.

 

Parameters:

int nParam

The value for the parameter whose name is to be returned.

 

 

Prototype:

virtual const int FindParamByName( TCHAR* name ) = 0

 

Remarks:

Returns the index of the parameter based on the name

 

 const int FindParamByName1( TCHAR* name ) {

  for( int i = 0; i < 8; ++i ){

   if( strcmp( name, GetString( paramNames[i] )) == 0 )

    return i+1;

  }

  return 0;

 }

 

Prototype:

virtual int GetParamType( int nParam ) = 0

 

Remarks:

Currently only 1 = Boolean, 0 = Undefined are supported. In release 5 this means that any parameter you have is defined and used as a Boolean in maxscript

 

Parameters:

int nParam

The value for the parameter whose type is to be returned.

 

Prototype:

virtual int GetParamValue( int nParam ) = 0

 

Remarks:

The value to set when the Render to Texture tool is loaded

 

Parameters:

int nParam

The value for the parameter whose value is to be returned.

 

 

Prototype:

virtual void SetParamValue( int nParam, int newVal ) = 0

 

Remarks:

The Render to Texture Tool will save out the data

Parameters:

int nParam

The value for the parameter whose value is to be set

int newVal

The value to set