MNMap Class Reference

#include <mnmesh.h>

Class Description

Holds the mapping information for a particular map channel of the MNMesh.

As with regular Mesh maps, the MNMap holds an array of map vertices and an array of map faces that define how those mapping vertices are applied to the MNMesh. The number (numf) of mapping faces should always match the number of faces in the parent MNMesh, and each MNMapFace gives the map vertices for the related MNFace. The number of map vertices may be different from the number of MNVerts in the parent MNMesh.

+ Inheritance diagram for MNMap:

Public Member Functions

 MNMap ()
 Constructor. More...
 
 ~MNMap ()
 Destructor. More...
 
DllExport int NewTri (int a, int b, int c)
 Like MNMesh::NewTri, this creates a new mapping face, of degree 3, with the specified map vertices. More...
 
DllExport int NewTri (int *vv)
 Like MNMesh::NewTri, this creates a new mapping face, of degree 3, with the specified map vertices. More...
 
DllExport int NewQuad (int a, int b, int c, int d)
 Like MNMesh::NewQuad, this creates a quad, with the specified map vertices. More...
 
DllExport int NewQuad (int *vv)
 Like MNMesh::NewQuad, this creates a quad, with the specified map vertices. More...
 
DllExport int NewFace (int degg=0, int *vv=NULL)
 Like MNMesh::NewFace, this creates a new mapping face with the specified degree and map vertices. More...
 
DllExport void setNumFaces (int nfnum)
 Sets the number of map faces keeping any previously allocated faces. More...
 
DllExport int NewVert (UVVert p, int uoff=0, int voff=0)
 Allocates storage for a new specified UVVert. More...
 
DllExport void setNumVerts (int nvnum)
 Sets the number of UVVerts keeping any previously allocated UVVerts. More...
 
DllExport void CollapseDeadVerts (MNFace *faces)
 Eliminates the mapping vertices not used by any active mapping faces in this map. More...
 
DllExport void CollapseDeadFaces (MNFace *faces)
 Eliminates the MN_DEAD map faces from the array. More...
 
DllExport void Clear ()
 Sets the number of UVVerts and map faces to 0. More...
 
DllExport void ClearAndFree ()
 Sets the number of UVVerts and map faces to 0 and deallocates the memory. More...
 
DllExport void Transform (Matrix3 &xfm)
 Transforms each UVVert with the specified matrix. More...
 
DllExport void ShallowCopy (const MNMap &from)
 Copies pointers. More...
 
DllExport void NewAndCopy ()
 Creates new pointers and copies over all the data. More...
 
DllExport void MNDebugPrint (MNFace *faces)
 Uses DebugPrint to print out information about this MNMap to the Debug Results window in DevStudio. More...
 
DllExport bool CheckAllData (int mapChannel, int nf, MNFace *faces)
 Checks the MNMap for internal errors, such as a MNMapFace referring to an out of range map vertex. More...
 
DllExport IOResult Save (ISave *isave, MNFace *faces=NULL)
 Used internally to save this MNMap to the 3ds Max file. More...
 
DllExport IOResult Load (ILoad *iload, MNFace *faces=NULL)
 Used internally to load this MNMap from the 3ds Max file. More...
 
Initialization Functions
DllExport void Init ()
 Initializes the map - sets numv and numf to 0, and sets the pointers to NULL. More...
 
DllExport void VAlloc (int num, bool keep=TRUE)
 Allocates the specified number of UVVerts in the v array. More...
 
DllExport void FAlloc (int num, bool keep=TRUE)
 Allocates the specified number of map faces in the f array. More...
 
Data Access Functions
int VNum () const
 Returns the current number of UVVerts. More...
 
UVVert V (int i) const
 Returns the 'i-th' UVVert. More...
 
int FNum () const
 Returns the number of map faces. More...
 
MNMapFaceF (int i) const
 Returns a pointer to the 'i-th' map face. More...
 
Operators
DllExport MNMapoperator= (const MNMap &from)
 Assignment operator. More...
 
DllExport MNMapoperator+= (const MNMap &from)
 Appends the specified MNMap object onto this MNMap. More...
 
DllExport MNMapoperator+= (const MNMesh &from)
 Appends a default planar map corresponding to the mesh passed onto this map. More...
 
- Public Member Functions inherited from FlagUser
 FlagUser ()
 
void SetFlag (DWORD fl, bool val=TRUE)
 
void ClearFlag (DWORD fl)
 
bool GetFlag (DWORD fl) const
 
void ClearAllFlags ()
 
void CopyFlags (DWORD fl)
 
void CopyFlags (const FlagUser &fu)
 
void CopyFlags (const FlagUser *fu)
 
void CopyFlags (DWORD fl, DWORD mask)
 
void CopyFlags (const FlagUser &fu, DWORD mask)
 
void CopyFlags (const FlagUser *fu, DWORD mask)
 
void OrFlags (const FlagUser &fu)
 
void OrFlags (const FlagUser *fu)
 
void AndFlags (const FlagUser &fu)
 
void AndFlags (const FlagUser *fu)
 
bool FlagMatch (DWORD fmask, DWORD fl) const
 
bool FlagMatch (DWORD fmask, const FlagUser &fu) const
 
bool FlagMatch (DWORD fmask, const FlagUser *fu) const
 
DWORD ExportFlags () const
 
void ImportFlags (DWORD fl)
 
IOResult WriteFlags (ISave *isave, ULONG *nb) const
 
IOResult ReadFlags (ILoad *iload, ULONG *nb)
 

Public Attributes

MNMapFacef
 The array of map faces. More...
 
UVVertv
 The array of UVVerts. More...
 
int numv
 The number of vertices in the v array. More...
 
int numf
 The number of map faces in the f array. More...
 

Friends

class MNMesh
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Constructor & Destructor Documentation

MNMap ( )
inline

Constructor.

This calls Init().

860 { Init(); }
DllExport void Init()
Initializes the map - sets numv and numf to 0, and sets the pointers to NULL.
~MNMap ( )
inline

Destructor.

This calls ClearAndFree().

863 { ClearAndFree (); }
DllExport void ClearAndFree()
Sets the number of UVVerts and map faces to 0 and deallocates the memory.

Member Function Documentation

DllExport void Init ( )

Initializes the map - sets numv and numf to 0, and sets the pointers to NULL.

Also initializes private allocation related data members.

DllExport void VAlloc ( int  num,
bool  keep = TRUE 
)

Allocates the specified number of UVVerts in the v array.

(If you're creating a number of map verts, but you're not sure exactly how many, it's good to pre-allocate a large number using this method.) This method doesn't affect MNMap::numv, only the allocation amount.

Parameters:
int num

The number of UVVerts to allocate.

bool keep=TRUE

If TRUE any previous verts are kept; otherwise they are discarded.
DllExport void FAlloc ( int  num,
bool  keep = TRUE 
)

Allocates the specified number of map faces in the f array.

This method doesn't affect MNMap::numf, just the number allocated.

Parameters:
int num

The number of map verts to allocate.

bool keep=TRUE

If TRUE any previous map faces are kept; otherwise they are discarded.
int VNum ( ) const
inline

Returns the current number of UVVerts.

895 { return numv; }
int numv
The number of vertices in the v array.
Definition: mnmesh.h:854
UVVert V ( int  i) const
inline

Returns the 'i-th' UVVert.

Parameters:
int i

The zero based index into the v array of the UVVert to return.
901 { return v[i]; }
UVVert * v
The array of UVVerts.
Definition: mnmesh.h:851
int FNum ( ) const
inline

Returns the number of map faces.

904 { return numf; }
int numf
The number of map faces in the f array.
Definition: mnmesh.h:857
MNMapFace* F ( int  i) const
inline

Returns a pointer to the 'i-th' map face.

Parameters:
int i

The zero based index of the map face to return.
910 { return &(f[i]); }
MNMapFace * f
The array of map faces.
Definition: mnmesh.h:848
DllExport int NewTri ( int  a,
int  b,
int  c 
)

Like MNMesh::NewTri, this creates a new mapping face, of degree 3, with the specified map vertices.

Parameters:
int a

int b

int c

The mapping vertices for the new triangle.
DllExport int NewTri ( int vv)

Like MNMesh::NewTri, this creates a new mapping face, of degree 3, with the specified map vertices.

Parameters:
int *vv

The mapping vertices for the new triangle.
DllExport int NewQuad ( int  a,
int  b,
int  c,
int  d 
)

Like MNMesh::NewQuad, this creates a quad, with the specified map vertices.

Parameters:
int a

int b

int c

int d

The mapping vertices for this quad. (The two faces are formed with mapping verts (a,b,c) and (c,d,a).
DllExport int NewQuad ( int vv)

Like MNMesh::NewQuad, this creates a quad, with the specified map vertices.

Parameters:
int *vv

The mapping vertices for this quad. (The two faces are formed with mapping verts (vv[0],vv[1],vv[2]) and (vv[2],vv[3],vv[0]).
DllExport int NewFace ( int  degg = 0,
int vv = NULL 
)

Like MNMesh::NewFace, this creates a new mapping face with the specified degree and map vertices.

Parameters:
int degg=0

The degree of the new face. (Note that this should match the degree of the associated MNFace.)

int *vv=NULL

The new mapping vertices, in order around the perimeter.
DllExport void setNumFaces ( int  nfnum)

Sets the number of map faces keeping any previously allocated faces.

Parameters:
int nfnum

The number of faces to set.
DllExport int NewVert ( UVVert  p,
int  uoff = 0,
int  voff = 0 
)

Allocates storage for a new specified UVVert.

An optional offset to the UVVert may be supplied. (The offset is useful when you want to create a new UVVert which is on the other side of a seam in U or V from some existing UVVert p.)

Parameters:
UVVert p

The UVVert to store.

int uoff=0

If non-zero this is an offset applied in U when p is stored.

int voff=0

If non-zero this is an offset applied in V when p is stored.
DllExport void setNumVerts ( int  nvnum)

Sets the number of UVVerts keeping any previously allocated UVVerts.

Parameters:
int nvnum

The number of UVVerts to set.
DllExport void CollapseDeadVerts ( MNFace faces)

Eliminates the mapping vertices not used by any active mapping faces in this map.

(Analogous to the Mesh::DeleteIsoMapVerts method.)

Parameters:
MNFace *faces

This should point to the MNFace array of the parent MNMesh. This allows the method to find out if any faces should be considered MN_DEAD, so that it won't mark such faces' map verts as used. (The MN_DEAD flag is stored in the MNFace, but not in the related MNMapFaces.)
DllExport void CollapseDeadFaces ( MNFace faces)

Eliminates the MN_DEAD map faces from the array.

This should be called immediately before calling CollapseDeadFaces on the parent MNMesh, to keep the face arrays in sync.

Parameters:
MNFace *faces

The parent MNMesh's array of MNFaces. This array is used to find out which faces are MN_DEAD.
DllExport void Clear ( )

Sets the number of UVVerts and map faces to 0.

DllExport void ClearAndFree ( )

Sets the number of UVVerts and map faces to 0 and deallocates the memory.

DllExport void Transform ( Matrix3 xfm)

Transforms each UVVert with the specified matrix.

Parameters:
Matrix3 &xfm

The matrix to transform the UVVerts by.
DllExport MNMap& operator= ( const MNMap from)

Assignment operator.

DllExport MNMap& operator+= ( const MNMap from)

Appends the specified MNMap object onto this MNMap.

Parameters:
const MNMap &from

The source MNMap.
DllExport MNMap& operator+= ( const MNMesh from)

Appends a default planar map corresponding to the mesh passed onto this map.

This is typically used when joining two MNMeshes together when one MNMesh has a map channel active but the other doesn't. Rather than eliminate the map channel, we just use the object coordinates of the other mesh to generate a planar map for its faces.

Parameters:
const MNMesh &from

The source MNMesh.
DllExport void ShallowCopy ( const MNMap from)

Copies pointers.

To avoid memory errors, this method should only be used by the pipeline.

Parameters:
const MNMap & from

The map to copy pointers from.
DllExport void NewAndCopy ( )

Creates new pointers and copies over all the data.

To avoid memory errors, this method should only be used by the pipeline.

DllExport void MNDebugPrint ( MNFace faces)

Uses DebugPrint to print out information about this MNMap to the Debug Results window in DevStudio.

This includes all map verts and faces, one per line.

Parameters:
MNFace *faces

This should be the MNFace array of the parent MNMesh. It's used to prevent the DebugPrinting of MN_DEAD faces.
DllExport bool CheckAllData ( int  mapChannel,
int  nf,
MNFace faces 
)

Checks the MNMap for internal errors, such as a MNMapFace referring to an out of range map vertex.

If an error is found, an error message is DebugPrinted, and a the method returns FALSE. This is strictly a debugging tool of no use in releases - a good way to use it is to say

, so it won't be called when not in a Debug build, and so it'll throw up an assertion failure if something's wrong. Error messages generated: Map d: Wrong number of faces. Should be d, is d. (Sent if nf != MNMap::numf) Map d, Face d has wrong degree. Should be d, is d. (Sent if f[i].deg != faces[i].deg) Map d, Face d has wrong hdegree. Should be d, is d. (Sent if f[i].hdeg != faces[i].hdeg) Map d, Face d has an out-of-range map vertex: d. Map d, Face d has an out-of-range hidden map vertex: d

Parameters:
int mp

The map channel this MNMap represents - used to give more helpful debug information.

int nf

The number of faces of the parent MNMesh.

MNFace *faces

The parent MNMesh's face array. This is used to prevent checking of MN_DEAD faces, which may safely be invalid.
DllExport IOResult Save ( ISave isave,
MNFace faces = NULL 
)

Used internally to save this MNMap to the 3ds Max file.

DllExport IOResult Load ( ILoad iload,
MNFace faces = NULL 
)

Used internally to load this MNMap from the 3ds Max file.

Friends And Related Function Documentation

friend class MNMesh
friend

Member Data Documentation

The array of map faces.

UVVert* v

The array of UVVerts.

int numv

The number of vertices in the v array.

int numf

The number of map faces in the f array.