Class MeshMap

3DS Max Plug-In SDK

Class MeshMap

See Also: Class Mesh.

class MeshMap

Description:

This class is available in release 3.0 and later only.

In 3ds max 3.0 and later the user may work with more than 2 mapping channels. When the mapping channel is set to a value greater than 1 (by using a UVWMap Modifier for example) then an instance of this class is allocated for each channel up to the value specified. It maintains the mapping information for a single channel.

An array of instances of this class is carried by the Mesh class in the public data member:

MeshMap *maps;

All methods of this class are implemented by the system.

Data Members:

public:

DWORD flags;

The mapping flags. One or more of the following values:

MESHMAP_USED

Indicates this mapping channel is actually used (carries mapping information).

MESHMAP_TEXTURE

Indicates this is a texture mapping channel.

MESHMAP_VERTCOLOR

Indicates this is a vertex color channel.

MESHMAP_USER

Indicates the channel is used for a developer purpose.

UVVert *tv;

Array of texture vertices. This stores the UVW coordinates for the mapping channel. Note: typedef Point3 UVVert;

TVFace *tf;

The texture vertex faces. There needs to be one TVFace for every face in the Mesh, but there can be three indices into the UVVert array that are any UV's.

int vnum;

The number of elements in the UVVert array.

int fnum;

The number of elements in the TVFace array.

The following global functions are not part of the class but are available for use

Prototype:

DWORD MapChannelID (int mp);

Remarks:

This method is available in release 4.0 and later only.

Returns the Channel ID of the map channel. if mp>=1, this always returns TEXMAP_CHANNEL. For mp<1, including the hidden map channels, this is currently always VERTCOLOR_CHANNEL. In the future it may include map channels that are actually part of GEOM_CHANNEL or something.

Parameters:

int mp

The map channel.

Prototype:

int MapChannelNum (int mp);

Remarks:

This method is available in release 4.0 and later only.

Similar to MapChannelID, but this returns the CHAN_NUM version:TEXMAP_CHAN_NUM, VERTCOLOR_CHAN_NUM, etc.

Parameters:

int mp

The map channel.

Methods:

public:

Prototype:

MeshMap();

Remarks:

Constructor. The flags are cleared, the vertex and face numbers are set to 0, and the tv and tf pointers are set to NULL.

Prototype:

~MeshMap();

Remarks:

Destructor. If the tv and tf arrays are allocated they are deleted.

Prototype:

int getNumVerts();

Remarks:

Returns the number of UVVerts.

Prototype:

void setNumVerts(int vn, BOOL keep=FALSE);

Remarks:

Sets the number of UVVerts allocated to the specified value.

Parameters:

int vn

The new number of UVVerts to allocate.

BOOL keep=FALSE

If TRUE any previously allocated UVVerts are maintained (up to the maximum set by vn). If FALSE they are discarded.

Prototype:

int getNumFaces();

Remarks:

Returns the number of TVFaces.

Prototype:

void setNumFaces(int fn, BOOL keep=FALSE);

Remarks:

Set the number of TVFaces allocated to the specified value.

Parameters:

int fn

The new number of TVFaces to allocate.

BOOL keep=FALSE

If TRUE any previously allocated TVFaces are maintained (up to the maximum set by fn). If FALSE they are discarded.

Prototype:

void Clear();

Remarks:

Clears (deletes) the tv and tf arrays and sets the counts to zero.

Prototype:

BitArray GetIsoVerts();

Remarks:

This method returns a BitArray with size vnum, where isolated (unused) vertices are selected.

Prototype:

void DeleteVertSet(BitArray set, BitArray *delFace=NULL);

Remarks:

This method is used to delete vertices from a mesh map.

Parameters:

BitArray set

The array of bits where mapping vertices you want to delete are set.

BitArray *delFace=NULL

This is an optional parameter. If non-NULL, it's filled with a record of which faces, if any, were using the specified map verts and should therefore be deleted or considered invalid. (Note: in normal usage, it's preferable to remove any compromised faces _before_ deleting vertices, so this parameter would rarely be used.)

Prototype:

void DeleteFaceSet(BitArray set, BitArray *isoVert=NULL);

Remarks:

This method is used to delete faces from a mesh map.

Parameters:

BitArray set

This is a list of mapping faces to delete.

BitArray *isoVert=NULL

If non-NULL, this BitArray is filled with a list of map vertices that were used by the deleted faces but not by any remaining faces. (This is a list of "newly isolated" map vertices.)

NOTE: The number and arrangement of faces in a MeshMap should always agree with the "parent" mesh. It's safest in most cases to just let this be handled by Mesh::DeleteFaceSet().

Prototype:

void SetFlag(DWORD fl);

Remarks:

Sets the specified flag(s).

Parameters:

DWORD fl

The flags to set. See the public data member flags above.

Prototype:

void ClearFlag(DWORD fl);

Remarks:

Clears the specified flag(s).

Parameters:

DWORD fl

The flags to clear. See the public data member flags above.

Prototype:

BOOL GetFlag(DWORD fl);

Remarks:

Returns TRUE if the specified flag(s) are set; otherwise FALSE.

Parameters:

DWORD fl

The flags to check. See the public data member flags above.

Prototype:

BOOL IsUsed();

Remarks:

Returns TRUE if this mapping channel is being used; otherwise FALSE.

Prototype:

void SwapContents(MeshMap &from);

Remarks:

Exchanges the data between this MeshMap object and the specified one. The flags, vnum and fnum values are exchanged. The UVVert and TVFace pointers are swapped.

Parameters:

MeshMap &from

The MeshMap instance to swap with.

Prototype:

MeshMap & operator=(MeshMap & from);

Remarks:

Assignment operator.

Parameters:

MeshMap &from

The MeshMap to assign.