Class TexHandleMaker

3DS Max Plug-In SDK

Class TexHandleMaker

See Also: Class TexHandle, Class Bitmap, Class BitmapInfo.

class TexHandleMaker

Description:

This class provides several ways to create a texture handle. The handle may be created from a 3ds max bitmap or a Windows Device Independent Bitmap. This class also provides methods to determine the desired size of the bitmap.

Methods:

Prototype:

virtual TexHandle* CreateHandle(Bitmap *bm, int symflags=0, int extraFlags=0)=0;

Remarks:

Implemented by the System

This method is called to create a texture handle from a 3ds max bitmap.

Parameters:

Bitmap *bm

The bitmap to create a handle to.

int symflags=0

See List of Texture Symmetry Flags.

int extraFlags=0;

One of the following values:

EX_MULT_ALPHA

Set this flag if alpha is not premultiplied in the Bitmap.

EX_RGB_FROM_ALPHA

Set this flag to make the map using the alpha channel of the bitmap to define the gray level.

EX_OPAQUE_ALPHA

Specifies to make the map using opaque alpha.

EX_ALPHA_FROM_RGB

Specifies to make alpha from the intensity of the map.

Return Value:

A pointer to the texture handle.

Prototype:

virtual TexHandle* CreateHandle(BITMAPINFO *bminf, int symflags=0, int extraFlags=0)=0;

Remarks:

Implemented by the System

This method is called to create a texture handle from a 32 bit Windows Device Independent Bitmap.

Parameters:

BITMAPINFO *bminf

The bitmap to create a handle to.

int symflags=0

See List of Texture Symmetry Flags.

int extraFlags=0;

One of the following values:

EX_MULT_ALPHA

Set this flag if alpha is not premultiplied in the Bitmap.

EX_RGB_FROM_ALPHA

Set this flag to make the map using the alpha channel of the bitmap to define the gray level.

EX_OPAQUE_ALPHA

Specifies to make the map using opaque alpha.

EX_ALPHA_FROM_RGB

Specifies to make alpha from the intensity of the map.

Return Value:

A pointer to the texture handle.

Prototype:

virtual BITMAPINFO *BitmapToDIB(Bitmap *bm, int symflags, int extraFlags, BOOL forceW=0, BOOL forceH=0)=0;

Remarks:

This method is available in release 4.0 and later only.

This method creates a 32 bit Windows Device Independent Bitmap with the specified symflags and extraflags already incorporated and returns a pointer to the associated BitmapInfo.

Parameters:

Bitmap *bm

Points to the bitmap to create the handle to.

int symflags

See List of Texture Symmetry Flags.

int extraFlags

One of the following values:

EX_MULT_ALPHA

Set this flag if alpha is not premultiplied in the Bitmap.

EX_RGB_FROM_ALPHA

Set this flag to make the map using the alpha channel of the bitmap to define the gray level.

EX_OPAQUE_ALPHA

Specifies to make the map using opaque alpha.

EX_ALPHA_FROM_RGB

Specifies to make alpha from the intensity of the map.

BOOL forceW=0

If this parameter is non-zero it is used as the width of the final DIB.

BOOL forceH=0

If this parameter is non-zero it is used as the height of the final DIB

Prototype:

virtual TexHandle* MakeHandle(BITMAPINFO* bminf)=0;

Remarks:

This method is available in release 4.0 and later only.

Returns a texture handle made from a 32 bit DIB that has the symflags, and extraflags already incorporated. This takes ownership of the BITMAPINFO*.

Parameters:

BITMAPINFO* bminf

Points to the BitmapInfo for the DIB.

Prototype:

virtual BOOL UseClosestPowerOf2()=0;

Remarks:

This method is available in release 4.0 and later only.

Returns TRUE if the bitmap does not need to be square and FALSE if it does need to be square.

Prototype:

virtual int Size()=0;

Remarks:

Implemented by the System.

This method may be called to determine the desired size for the bitmap. The system ultimately needs a square bitmap that is a power of 2 in width and height. If you already have a bitmap around, just pass it in to CreateHandle() and it will be converted. If you are creating a bitmap from scratch (i.e. a procedural texture), then you should make it Size() in width in height, and save the system an extra step. In either case you own your bitmap, and are responsible for ultimately freeing it.

Return Value:

The size of the desired bitmap.