MNMesh Note on Edge Characteristics.

3DS Max Plug-In SDK

MNMesh Note on Edge Characteristics.

See Also: Class MNMesh, Class Mesh.

Regular 3ds max Meshes consist of faces and vertices; they have no real edges as such. Edge characteristics such as visibility and selection are referenced by face. For example, the edgeSel data member of a Class Mesh has 3*numFaces members. Each set of three values edgeSel[i*3], edgeSel[i*3+1], and edgeSel[i*3+2] represent the selection of the three edges (going from vertex 0 to vertex 1, vertex 1 to vertex 2, and vertex 2 to vertex 0, respectively) of face i.

There are similar issues in MNMesh for a number of reasons. Edge selection and visibility data must initially be stored in the MNFace members, since until we call FillInMesh there are no MNEdges to store them in. There are a number of methods in the library (and many more the developer could design) which would invalidate the topological data, rendering the MNEdge list invalid. Also, eventually, we’re going to want to convert each MNMesh back into a regular Mesh using OutToTri, so it’s convenient to store edge selection and visibility information in the faces for this purpose.

Thus, although the MNEdges contain MN_SEL and MN_EDGE_INVIS flags, the more fundamental location for this data is in the MNFaces using that edge. When altering an MNMesh to make edges visible or invisible, or to change their selection status, be sure to make the changes in the MNFaces using the edge, otherwise the information can be easily overwritten, and generally won’t get passed to the output Mesh.

With 3.0, there are simple new methods to do this:

void MNMesh::SetEdgeVis (int ee, BOOL vis=TRUE);

void MNMesh::SetEdgeSel (int ee, BOOL sel=TRUE);

Otherwise, here’s an example of how to set all the information yourself. I want to make edge ee visible and selected in the following code:

void MakeEdgeVisAndSel(MNMesh & mm, int ee) {

 assert(mm.GetFlag(MN_MESH_FILLED_IN));

 MNEdge *me = mm.E(ee);

 MNFace *mf1 = mm.F(me->f1);

 MNFace *mf2 =(me->f2>-1) ? mm.F(me->f2) : NULL;

 

 // Change the edge as desired

 me->ClearFlag(MN_EDGE_INVIS | MN_EDGE_HALF_INVIS);

 me->SetFlag(MN_SEL);

 

 // Make the corresponding changes in face 1

 int i;

i = mf1->EdgeIndex(ee);

mf1->visedg.Set(i);

mf1->edgsel.Set(i);

 

// Make the corresponding changes in face 2

if(mf2) {

 i = mf2->EdgeIndex(ee);

 mf2->visedg.Set(i);

 mf2->edgsel.Set(i);

}

}