Class MNChamferData

3DS Max Plug-In SDK

Class MNChamferData

See Also: Class MNTempData, Class MNMesh

class MNChamferData

Description:

This class is available in release 4.0 and later only.

This class contains all the data needed to move points (and map vertices) as the user drags a chamfer or extrude. It's created by the topological change that happens at the start of the chamfer or extrude. The strategy is this: The chamfer/extrude operation is divided into two parts, the topological change and a later geometric change. (This works well for Editable Poly, where the topology change is completed first, then apply a series of geometry changes as the user spins a spinner or drags a mouse. Each geometry change is undone before the next is applied, but the topology change only happens once.)

This class is first initialized to a mesh. Then its data is filled in by the topological change. This data is used to find "directions" for all the geometric and mapping vert changes over the course of the geometric modification.

For convenient caching, it is recommended that you use this class through the MNTempData class.

Data Members:

private:

Tab<UVVert> hmdir[NUM_HIDDENMAPS];

The direction vectors for mapping vertices in any active "hidden" mapping channels.

public:

Tab<Point3> vdir;

The related direction vectors for mapping vertices in all active mapping channels.

Tab<Point3> vmax;

The maximum amount each vector may be applied (before vertices start crossing over each other).

Tab<UVVert> *mdir;

The related direction vectors for mapping vertices in all active mapping channels.

Methods:

public:

Prototype:

MNChamferData ();

Remarks:

Constructor.

Default Implementation:

{ mdir=NULL; }

Prototype:

MNChamferData (const MNMesh & m);

Remarks:

Constructor.

This constructor Initializes to the mesh passed (allocates mapping channels, etc.)

Parameters:

const MNMesh & m

The specified mesh.

Default Implementation:

{ mdir=NULL; InitToMesh(m); }

Prototype:

~MNChamferData ();

Remarks:

Destructor.

Default Implementation:

{ if (mdir) delete [] mdir; }

Prototype:

void InitToMesh (const MNMesh & m);

Remarks:

This method sets up the MNChamferData based on a given mesh, allocating the vertex and mapping vertex tables as appropriate.

Parameters:

const MNMesh & m

The Mesh to initialize from.

Prototype:

void setNumVerts (int nv, bool keep=TRUE, int resizer=0);

Remarks:

This method simply allocates the vdir and vmax tables, and initializes the new members of vmax to 0. (Note: this method can be applied to an existing MNChamferData to reflect an increase in vertices in the MNMesh as topological changes occur.)

Parameters:

int nv

The number of vertices.

bool keep=TRUE

TRUE to keep old data if resized; FALSE to discard old data.

int resizer=0

The number of extra elements the vdir and vmax tables are resized beyond their current size. (Extra allocation space to prevent excessive reallocation.)

Prototype:

void ClearLimits ();

Remarks:

Clears all the vmax limits to -1 (no limit).

Prototype:

void GetDelta (float amount, Tab<Point3> & delta);

Remarks:

Uses vectors and limits to obtain the offsets corresponding to a certain extrude or chamfer amount.

Parameters:

float amount

The amount of the extrude or chamfer.

Tab<Point3> & delta

A table (with size set equal to the number of vertices, aka vdir.Count()) containing the geometric offset for each vertex in the mesh.

Prototype:

bool GetMapDelta (MNMesh & mm, int mapChannel, float amount, Tab<UVVert> & delta);

Remarks:

Uses map vectors and limits to obtain the mapping offsets corresponding to a certain extrude or chamfer amount.

Parameters:

MNMesh & mm

The mesh this MNChamferData is based on.

int mapChannel

The index of the map channel (from -NUM_HIDDENMAPS to mm.MNum()).

float amount

The amount of the extrude or chamfer.

Tab<UVVert> & delta

The offsets for each mapping vertex in this map in the mesh.

Prototype:

Tab<UVVert> & MDir (int mp);

Remarks:

Data accessor. This method returns the appropriate map info. If mp >= 0, it returns the member of the mdir array. If mp < 0, it returns the member of the hmdir array (in keeping with "hidden map channel" indexing conventions).

Default Implementation:

{ return (mp<0) ? hmdir[-1-mp] : mdir[mp]; }

 

 

The following are not part of the class but are useful for debugging

 Prototype:

 DllExport void MNChamferDataDebugPrint (MNChamferData & mcd, int mapNum);

 Description

This function uses calls to DebugPrint() to output all the data in the specified MNChamferData to the DebugPrint buffer during debug runs. It is available for programmers' use, providing easy access to MNChamferData during development. It ought to be removed for release builds.

 Parameters:

 MNChamferData & mcd

The MNChamferData we want to investigate.

 int mapNum

The number of map channels in the MNMesh associated with this MNChamferData . (For historical reasons, this information is not kept in the MNChamferData class.) Generally this is retrieved with a call to MNMesh::MNum().