Class MeshDeltaUserData

3DS Max Plug-In SDK

Class MeshDeltaUserData

See Also: Class Mesh, Class MeshDelta, Class MeshDeltaUser, Class LocalModData, Class Matrix3, Class Point3, Class Quat, Class BitArray.

class MeshDeltaUserData

Description:

This class is available in release 3.0 and later only.

This class provides a standard interface for modifiers and objects that use mesh deltas -- specifically Edit Mesh and Editable Mesh.

Both Edit Mesh and Editable Mesh have a current "state", which can be modified by MeshDeltas. In Editable Mesh, this "state" is an actual mesh, while in Edit Mesh, this is one MeshDelta per LocalModData. This class provides a standard interface to these: "MeshDeltaUser" and "MeshDeltaUserData".

Methods:

public:

Prototype:

virtual void ApplyMeshDelta(MeshDelta &md, MeshDeltaUser *mdu, TimeValue t)=0;

Remarks:

This method applies the MeshDelta. Everything that happens in Edit Mesh and Editable Mesh goes through this method. Note that in Edit Mesh, the MeshDeltaUserData (EditMeshData) is separate from the MeshDeltaUser (EditMeshMod), though in Editable Mesh, EditTriObject subclasses from both of them.

There's essentially one mesh that can be edited per MeshDeltaUserData, so ApplyMeshDelta is the way to edit that mesh. ApplyMeshDelta typically handles adding Restore objects (if theHold.Holding()), clearing out any temporary local caches that are invalidated, and notifying the pipeline that the mesh has changed.

Parameters:

MeshDelta &md

The mesh delta to apply.

MeshDeltaUser *mdu

Points to the mesh delta user.

TimeValue t

The time to apply the mesh delta.

Prototype:

virtual MeshDelta *GetCurrentMDState();

Remarks:

Returns a pointer to the MeshDelta object for this application of the Edit Mesh modifier. This is only non-NULL in Edit Mesh.

Default Implementation:

{ return NULL; }

The following global functionis not part of this class but is available for use:

Function:

void FindTriangulation(Mesh & m, int deg, int *vv, int *tri);

Remarks:

This global function is available in release 3.0 and later only.

Finds a triangulation of an n-sided polygon using vertices in the specified mesh. As long as the vertices are coplanar, this algorithm will find a proper triangulation, even for nonconvex polygons.

Parameters:

Mesh &m

The mesh containing the vertices used in the polygon.

int deg

The size of the polygon.

int *vv

The vertex indices of the polygon, in order around the perimeter. For instance, if deg is 5 and w points to an array containing (3, 6, 8, 0, 7), the polygon is presumed to have the outline described by m.verts[3], m.verts[6], m.verts[8], m.verts[0], and m.verts[7].

int *tri

This is where the output is placed. Note that this should point to an array of size at least (deg-2)*3, to hold all the triangles. The values placed in this array are indices into the w array -- that is, given a 5-sided polygon, one triangle in this list might be (0,2,3), indicating you should use the 0th, 2nd, and 3rd elements of w to form the triangle. Put another way, to make a face from the n'th triangle given by this array, you would set:

f.v[0] = w[tri[n*3+0]];

f.v[1] = w[tri[n*3+1]];

f.v[2] = w[tri[n*3+2]];