Class MNFaceClusters

3DS Max Plug-In SDK

Class MNFaceClusters

See Also: Class MNTempData, Class MNMesh

class MNFaceClusters

Description:

This class is available in release 4.0 and later only.

This class may be used for grouping faces in an MNMesh into clusters for applying transformations. Depending on the constructor used, it may group faces into clusters based on minimal angles between faces, on face selections, or on both. The class contains a list of face "clusters" for a given mesh. A typical application would be in Editable Poly, where the user has selected two separate groups of faces on different parts of the mesh and wants to extrude them both, or rotate both around their local centers. Each "cluster" is a contiguous group of selected faces. This class is only defined in relation to some MNMesh.

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

All methods of this class are implemented by the system.

Data Members:

public:

Tab<int> clust;

The cluster number, one for each face. Note that non-selected faces have UNDEFINED for their id.

int count;

The total number of clusters in the MNMesh.

Methods:

public:

Prototype:

MNFaceClusters (MNMesh &mesh, DWORD clusterFlags);

Remarks:

Constructor.

This method will create face cluster lists based on the specified MNMesh. Each contiguous group of selected faces is grouped into a cluster.

Parameters:

MNMesh &mesh

The mesh these clusters are based on.

DWORD clusterFlags

The face flags to cluster the faces by.

For instance, if this value was set to MN_SEL, then faces would be clustered by their selection.

Prototype:

MNFaceClusters (MNMesh & mesh, float angle, DWORD clusterFlags);

Remarks:

This method is available in release 4.0 and later only.

This method will create face cluster lists based on the specified MNMesh. Cluster boundaries will be determined by the angle between faces and optionally by the face flags.

Parameters:

MNMesh &mesh

The mesh these clusters are based on.

float angle

The minimum edge angle (in radians) used to define a separation between clusters.

DWORD clusterFlags

The face flags to cluster the faces by.

For instance, if this value was set to MN_SEL, then faces would be clustered by their selection. If this value is set to 0, then the clusters are based only on edge angles.

Prototype:

int operator[](int i);

Remarks:

Index operator for accessing cluster data.

Default Implementation:

{ return clust[i]; }

Prototype:

void MakeVertCluster(MNMesh &mesh, Tab<int> & vclust);

Remarks:

This method will create a table indicating which face cluster each vertex in the mesh is in.

Parameters:

MNMesh &mesh

The mesh this face cluster is based on.

Tab<int> & vclust

The table of vertex clusters. This is set to size mesh.VNum(). Values of UNDEFINED (0xffffffff) in the table indicate that a vertex is not in any cluster. If a vertex is in two clusters (because it's a point where corners of two clusters touch), the higher-indexed face's cluster is dominant.

Prototype:

void GetNormalsCenters (MNMesh &mesh, Tab<Point3> & norm, Tab<Point3> & ctr);

Remarks:

Computes average normals and centers for each of the face clusters.

Parameters:

MNMesh &mesh

The mesh this face cluster is based on.

Tab<Point3> & norm

The tables where the normals should be put. Each of these tables has its size set to the number of clusters, and is indexed by cluster.

Tab<Point3> & ctr

The tables where the centers should be put. Each of these tables has its size set to the number of clusters, and is indexed by cluster.

Prototype:

void GetBorder (MNMesh &mesh, int clustID, Tab<int> & cbord);

Remarks:

This method will finds the edge list that borders this cluster. This edge list is a set of closed loops of edges, which may be empty. For instance, if the mesh is a sphere, and all the faces are in the cluster, there are no border edges for the cluster. But if one horizontal row of faces, such as the faces just above the equator, are in the cluster, then the edges above those faces form one loop, while the edges below form another.

Parameters:

MNMesh &mesh

The mesh this face cluster is based on.

int clustID

The ID of the cluster we want to get the border of.

Tab<int> & cbord

The table for putting the border output. This table is set up as follows: each border loop is represented by a series of edge indices, followed by a -1 to indicate a separation between loops. So a result of size 10 with data 1, 4, 6, 9, -1, 2, 10, 15, 14, -1, would indicate two border loops consisting of four edges each. The order of the edges in the loops is chosen so that as you look from outside the mesh and follow the path of the edges, the face cluster will always be on the left.

Prototype:

void GetOutlineVectors (MNMesh & m, Tab<Point3> & cnorms, Tab<Point3> & odir);

Remarks:

This method will retrieve the "outline" direction for the border of the cluster. This is the direction used in the "Outline" feature in Editable Poly face level, as well as in the Bevel command mode.

Parameters:

MNMesh &m

The mesh this face cluster is based on.

Tab<Point3> & cnorms

The cluster normals, as computed in the GetNormalsCenters method. (This data is input, not output.)

Tab<Point3> & odir

This is where the outline vectors are stored. This table is set to size mesh.VNum(), and stores one direction vector for each vertex. Most direction vectors are usually zero, since most vertices are not on the cluster's border. All vectors are scaled so that moving along them moves the cluster's border edges by one unit. (For instance, the length of a vector at a right angle between two border edges would be sqrt(2), so that each edge can move by 1 unit "out" from the cluster.)