Public Member Functions | Public Attributes

MapDelta Class Reference

Search for all occurrences

Detailed Description

See also:
Class Mesh, Class MeshDelta, Template Class Tab.

Description:
This class is available in release 3.0 and later only.

This is an SDK class that represents some kind of change to a mesh map. This "delta" can include changes in map vertices and/or faces. It is always a subordinate part of a MeshDelta. Most of the time, the programmer does not need to worry about this class directly, but can let the parent MeshDelta do most of the work.

Note: You must #include "MESHDLIB.H" to use this class as it's not included by default by MAX.H.
Method Groups:
See Method Groups for Class MapDelta.
Data Members:
DWORD vnum

The expected number of vertices in the input mesh

DWORD fnum;

The expected number of faces in the input mesh

Tab<UVVertSet> vSet;

This data member stores changes in the mapping vertices given as input. See class UVVertSet for more information. UVVertSets are stored in original map vertex ID order, and there is never more than one UVVertSet per original map vertex.

Tab<Point3> vCreate;

This data member stores mapping vertices newly created as part of the MapDelta. These are stored in the order created.

Tab<TVFace> fCreate;

This data member stores map faces newly created as part of the MapDelta. These are stored in the order created.

Tab<FaceRemap> fRemap;

This data member stores changes in which map vertices are used by existing map faces. See Class FaceRemap for more information. These are stored in original face order, and there is never more than one per original face.

#include <meshdelta.h>

Inheritance diagram for MapDelta:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  MapDelta ()
DllExport void  ClearAllOps ()
DllExport int  NumVSet (DWORD inVNum)
DllExport void  SetInVNum (DWORD n)
DllExport void  SetInFNum (DWORD n)
DWORD  outVNum ()
DWORD  outVNum (DWORD inVNum)
bool  IsCreate (DWORD i)
DllExport DWORD  SetID (DWORD i)
DllExport DWORD  VCreate (UVVert *v, int num=1)
DllExport void  FCreate (TVFace *f, int num=1)
DllExport void  FCreateDefault (int num=1)
DllExport void  FCreateQuad (DWORD *t)
DllExport void  FClone (TVFace &tf, DWORD remapFlags=0, DWORD *v=NULL)
DllExport void  FRemap (DWORD f, DWORD flags, DWORD *v)
void  FRemap (FaceRemap &fr)
DllExport DWORD  RemapID (DWORD ff)
DllExport DWORD  IsRemapped (DWORD ff, DWORD vid)
DllExport TVFace  OutFace (TVFace *mf, DWORD ff)
DllExport void  FDelete (int offset, BitArray &fdel)
DllExport void  Set (DWORD i, const UVVert &p)
DllExport void  Set (BitArray &sel, const UVVert &p)
MapDelta operator= (MapDelta &from)
DllExport MapDelta operator*= (MapDelta &from)
DllExport void  Apply (UVVert *tv, TVFace *tf, DWORD inVNum, DWORD inFNum)
DllExport void  MyDebugPrint ()
DllExport DWORD  ChangeFlags ()
DllExport void  CopyMDChannels (MapDelta &from, DWORD channels)
DllExport BOOL  CheckOrder ()
DllExport BOOL  CheckFaces ()

Public Attributes

DWORD  vnum
DWORD  fnum
Tab< UVVertSet vSet
Tab< Point3 vCreate
Tab< TVFace fCreate
Tab< FaceRemap fRemap

Constructor & Destructor Documentation

MapDelta ( ) [inline]
Remarks:
Constructor. Initializes the MapDelta with empty tables and 0's for input mesh map size.
{ vnum=0; fnum=0; }

Member Function Documentation

DllExport void ClearAllOps ( )
Remarks:
Clears out all existing map changes. Zeroes all the vCreate, vSet, etc tables.
DllExport int NumVSet ( DWORD  inVNum )
Remarks:
Returns the number of map vertex sets that would be applied to a map with the specified number of map vertices. (If that number equals this MapDelta's vnum, this is simply vSet.Count().)
Parameters:
DWORD inVNum

The number of vertices in the input map we're inquiring about.
DllExport void SetInVNum ( DWORD  n )
Remarks:
Sets the number of map vertices in the input map. NOTE that if n is less than the current vnum, the data relating to the extra vertices will be lost. (That is, if one of your map vertex sets is applied to map vertex 32, and you SetInVNum to 30, that vertex set will be lost, and will not be recovered if you later SetInVNum to 35.) It is NOT necessary to call this method before applying this MapDelta to a smaller than expected Map.
Parameters:
DWORD n

The number of vertices expected from the input mesh.
DllExport void SetInFNum ( DWORD  n )
Remarks:
Sets the number of map faces in the input map. NOTE that if n is less than the current fnum, the data relating to the extra faces will be lost. (That is, if one of your face remaps is applied to face 32, and you SetInFNum to 30, that face remap will be lost, and will not be recovered if you later SetInFNum to 35.) It is NOT necessary to call this method before applying this MapDelta to a smaller than expected Map.
Parameters:
DWORD n

The number of faces expected from the input mesh.
DWORD outVNum ( ) [inline]
Remarks:
Returns the number of vertices in the output map, assuming that the input map is of the expected (vnum) size.
{ return vnum + vCreate.Count(); }
DWORD outVNum ( DWORD  inVNum ) [inline]
Remarks:
Returns the number of vertices in the output map, assuming that the input map has the specified number of map vertices.
Parameters:
DWORD inVNum

The number of map vertices expected in the input map.
{ return inVNum + vCreate.Count(); }
bool IsCreate ( DWORD  i ) [inline]
Remarks:
Indicates whether the specified map vertex was created in this MapDelta.
Parameters:
DWORD i

The index in the output of the map vertex.
{ int j=i-vnum; return ((j>=0) && (j<vCreate.Count())); }
DllExport DWORD SetID ( DWORD  i )
Remarks:
Obtains the index of the vSet entry that relates to this vertex.
Parameters:
DWORD i

The map vertex index.
Returns:
The index in the vSet array of the map vertex set corresponding to this vertex, or UNDEFINED if this map vertex has not been modified.
DllExport DWORD VCreate ( UVVert v,
int  num = 1 
)
Remarks:
Creates new map vertices.
Parameters:
UVVert *v

A pointer to an array of UVVerts representing the new map vertices.

int num

The size of the UVVert array.
Returns:
The index (in the output map) of the first of these new map vertices.
DllExport void FCreate ( TVFace f,
int  num = 1 
)
Remarks:
Creates new map faces.

Note: MapDeltas must be kept up to date with the parent MeshDelta in all new face creations. See the MeshDelta method CreateDefaultMapFaces for details.
Parameters:
TVFace *f

A pointer to an array of map faces to be added to the MapDelta.

int num

The size of the map face array.
DllExport void FCreateDefault ( int  num = 1 )
Remarks:
Creates new "default" map faces, where all the corners are UNDEFINED. (These are later filled in by a call to the parent MeshDelta's FillInFaces method.)

Note: MapDeltas must be kept up to date with the parent MeshDelta in all new face creations. See the MeshDelta method CreateDefaultMapFaces for details.
Parameters:
int num

The number of default faces to create.
DllExport void FCreateQuad ( DWORD *  t )
Remarks:
Creates 2 new faces, forming a quad.

Note: MapDeltas must be kept up to date with the parent MeshDelta in all new face creations. See the MeshDelta method CreateDefaultMapFaces for details.
Parameters:
DWORD *t

A pointer to an array of 4 map vertices to be used as corners of the quad.
DllExport void FClone ( TVFace tf,
DWORD  remapFlags = 0,
DWORD *  v = NULL 
)
Remarks:
Creates a new map face by copying (and optionally remapping) the face given.

Note: MapDeltas must be kept up to date with the parent MeshDelta in all new face creations. See the MeshDelta method CreateDefaultMapFaces for details.
Parameters:
TVFace & tf

The map face we wish to clone. (This is typically generated by the OutFace method.)

DWORD remapFlags=0

DWORD *v=NULL

If we wish to remap any of the corners of this map face while cloning, the appropriate flags and vertices should be passed in these last two arguments. v should point to an array of 3 map vertex indices, although the ones not marked as used by the remapFlags need not be set to anything in particular. See class FaceRemap for more information about face remapping.
DllExport void FRemap ( DWORD  f,
DWORD  flags,
DWORD *  v 
)
Remarks:
Adds a face remap to this MapDelta. If the face specified already has a remap record, the two are combined. If the face specified is a face created by this MapDelta, the remap is applied directly to the fCreate entry instead of being stored in fRemap.
Parameters:
DWORD f

The face to remap.

DWORD flags

Face Remap flags - these indicate which vertices should be remapped. The possibilities are FR_V0 (1), FR_V1 (2), and FR_V2 (4). (See class FaceRemap for more information.)

DWORD *v

A pointer to the vertices to remap the face to use. Only the positions indicated in the remap flags need contain meaningful data.

Note that the vertices indicated here must be indexed by their positions after all of the current MeshDelta's creates and clones, but before any vertex deletes - essentially input-based indexing. Vertex index values of 0 through vnum-1 are considered to be the original mesh's vertices; values of vnum through vnum+vCreate.Count()-1 are considered to be this MeshDelta's newly created vertices; and values above this are cloned vertices.
void FRemap ( FaceRemap fr ) [inline]
Remarks:
Adds a face remap to this MapDelta. If the face specified in the FaceRemap already has a remap record, the two are combined. If the face specified is a face created by this MapDelta, the remap is applied directly to the fCreate entry instead of being stored in fRemap.
Parameters:
FaceRemap & fr

A FaceRemap that should be appended to this MapDelta.
{ FRemap (fr.f, fr.flags, fr.v); }
DllExport DWORD RemapID ( DWORD  ff )
Remarks:
Obtains the index of the fRemap entry that relates to this face.
Parameters:
DWORD ff

The map face index.
Returns:
If there is such an entry, the index is returned, so fRemap[RemapID(ff)].fid == ff. If there is no remap record for this map face, the method returns UNDEFINED.
DllExport DWORD IsRemapped ( DWORD  ff,
DWORD  vid 
)
Remarks:
Tells whether the specified corner of the specified face has been remapped in this MapDelta.
Parameters:
DWORD ff

The map face index.

DWORD vid

The corner of the face - 0, 1, or 2.
Returns:
If this corner has been remapped, it returns the vertex it's been remapped to. Otherwise, it returns UNDEFINED.
DllExport TVFace OutFace ( TVFace mf,
DWORD  ff 
)
Remarks:
Returns the specified map face as it would appear in the MapDelta output, taking into account any remaps.
Parameters:
TVFace *mf

The input map face array.

DWORD f

The index of the face you want the output version of.
DllExport void FDelete ( int  offset,
BitArray fdel 
)
Remarks:
Deletes the specified faces. This only affects the fCreate array, and should generally only be called by the parent MeshDelta's FDelete method to keep the face create arrays in sync.
Parameters:
int offset

Indicates what position in the fdel array corresponds to the first created face. (This is necessary since the BitArrays handed to MeshDelta::FDelete generally are based on the indexing after the previous MeshDelta::fDelete is applied. So this value is less than fnum if there was some previous deletion of original faces in the MeshDelta.)

BitArray & fdel

The faces to delete. The faces are indexed by their output mesh positions.
DllExport void Set ( DWORD  i,
const UVVert p 
)
Remarks:
Sets an existing map vertex to the value given. (Note that if the same map vertex is set twice, the new set simply replaces the old one - there is never more than one UVVertSet in the vSet array for a single input map vertex.)
Parameters:
int i

The index of the map vertex to set.

const UVVert & p

The value to set the map vertex to.
DllExport void Set ( BitArray sel,
const UVVert p 
)
MapDelta& operator= ( MapDelta from ) [inline]
Remarks:
Equality operator - makes this MapDelta just like the one given.
{ CopyMDChannels (from, MDELTA_ALL); return *this; }
DllExport MapDelta& operator*= ( MapDelta from )
Remarks:
Appends the given MapDelta to the current one.
Parameters:
MapDelta & td

The MapDelta to append. This MapDelta may be modified to make it suitable, ie the vnum and fnum values will be set to the expected output of the current MapDelta if they don't already match. (This may result in the loss of some data - see "SetInVNum" and "SetInFNum" for more information.)
DllExport void Apply ( UVVert tv,
TVFace tf,
DWORD  inVNum,
DWORD  inFNum 
)
Remarks:
Changes the given map by this MapDelta, in the following manner:

First, any maps that are supported by the MeshDelta but not by the mesh are assigned to the mesh in their default form. (Vertex colors are white, other maps are copies of the mesh vertices, and all have the same topology as the mesh.)

Next, any UNDEFINED mapping verts in the MeshDelta are filled in by FillInFaces.

Then the new vertices are added, creates first, followed by clones. The original vertices are then moved.

The faces are then modified, by applying all the FaceRemaps, FaceChanges, and FaceSmooths to the appropriate faces. New faces (in fCreate) are appended to the end of the face list.

Map changes are applied to all active maps, and map channels not supported by this MeshDelta are removed.

After all that is done, the vertices and faces marked in the vDelete and fDelete arrays are deleted.

Finally, the vertex data, vertex hide, and selections kept in the MeshDelta are applied to the result.
Parameters:
UVVert *tv

The map vertex array to change. This should be allocated to handle all the new map vertices in the vCreate array.

TVFace *tf

The map face array to change. This should be allocated to handle all the new map faces in the fCreate array.

DWORD inVNum

The actual number of map vertices (which doesn't have to match this MapDelta's vnum) in the input map.

DWORD inFNum

The actual number of map faces (which doesn't have to match this MapDelta's fnum) in the input map.
DllExport void MyDebugPrint ( )
Remarks:
Prints out all the changes in this MapDelta to the DebugPrint window in Developer Studio.
DllExport DWORD ChangeFlags ( )
Remarks:
Indicates what parts of a MapDelta could be changed if this MapDelta were appended to it. This is useful when backing up the MapDelta for Restore Objects. For instance, if you had a MapDelta with lots of face remaps, and you wanted to compose it with one that only added map vertices, there would be no reason to back up the remaps for an undo.
Returns:
Returns some combination of the following flags, corresponding to the data members that would be changed:

MDELTA_VMOVE: Indicates that the vSet array will be altered by this MapDelta.

MDELTA_VCREATE: Indicates that the vCreate array will be altered by this MapDelta.

MDELTA_FREMAP: Indicates that the fRemap array will be altered by this MapDelta.

MDELTA_FCREATE: Indicates that the fCreate array will be altered by this MapDelta.
DllExport void CopyMDChannels ( MapDelta from,
DWORD  channels 
)
Remarks:
Copies the specified parts of the MapDelta. (Useful in combination with ChangeFlags to create efficient Restore objects.)
Parameters:
MapDelta & from

The MapDelta to copy into this.

DWORD channels

Indicates the parts to copy - some combination of the following flags:

MDELTA_VMOVE: Copy the vSet array.

MDELTA_VCREATE: Copy the vCreate array.

MDELTA_FREMAP: Copy the fRemap array.

MDELTA_FCREATE: Copy the fCreate array.
DllExport BOOL CheckOrder ( )
DllExport BOOL CheckFaces ( )

Member Data Documentation

DWORD vnum
DWORD fnum

MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta
MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta MapDelta