If you want to write a plug-in object in Max, probably you are starting with the Widget example offered by Max SDK. It is a class derived from SimpleObject2, so it can only have triangular Mesh. Inside BuildMesh() method, this is howto create a simple mesh with only one quad face:
mesh.setNumVerts(4); mesh.setNumFaces(2); mesh.verts = Point3(0.0,0.0,0.0); mesh.verts = Point3(10.0,0.0,-0.5); mesh.verts = Point3(10.0,10.0,0.0); mesh.verts = Point3(0.0,10.0,1.5); mesh.faces.v = 0; mesh.faces.v = 1; mesh.faces.v = 2; mesh.faces.v = 0; mesh.faces.v = 2; mesh.faces.v = 3; mesh.setMapSupport(1, TRUE); MeshMap& map = mesh.Map(1); map.setNumVerts(4); map.setNumFaces(2); map.tv=UVVert(0,0,0); map.tv=UVVert(1,0,0); map.tv=UVVert(1,1,0); map.tv=UVVert(0,1,0); map.tf.setTVerts(0, 1, 2); map.tf.setTVerts(0, 2, 3); mesh.InvalidateGeomCache();
Actually there are 2 triangles. But as long as there is:
It will appear to be a single quad face. Now turn off the object display of “Edge Only”, the hidden edges will show up as a dotted line, two overlapped dotted lines indeed.
So how to convert Mesh to MNMesh? In fact you don’t have to, Max will do that for you. If you attached an EditPoly modifier to the Mesh object, it will be converted to Poly (MNMesh), unless you bother to override the ConvertToType() method, in which you can explicitly create an MNMesh and send to the pipeline. Don’t think that is necessary if you want the mesh unchanged.
Then how Max converts Mesh to MNMesh? I suggest Max traverses through all those triangles, looking for hidden edges, and remove those hidden edges to merger triangles into polygons. So the mesh we built above will be converted to a single quad face. The catch is Max will merger any triangles happened to be meeting at the same hidden edge, regardless whether those triangles are from the same “face”. That could lead to unexpected conversion. So set hidden edges carefully.