3ds Max C++ API Reference
Face Class Reference

This class represents a single triangular face. More...

#include <mesh.h>

+ Inheritance diagram for Face:

Public Member Functions

 Face ()
 Constructor. More...
 
MtlID getMatID ()
 Retrieves the zero based material ID for this face. More...
 
void setMatID (MtlID id)
 Sets the material ID for this face. More...
 
void setSmGroup (DWORD i)
 Sets the smoothing group bits for this face. More...
 
DWORD getSmGroup (void)
 Returns the smoothing group bits for this face. More...
 
DllExport void setVerts (DWORD *vrt)
 Sets the vertices of this face. More...
 
void setVerts (int a, int b, int c)
 Sets the vertices of this face. More...
 
DllExport void setEdgeVis (int edge, int visFlag)
 Sets the visibility of the specified edge. More...
 
DllExport void setEdgeVisFlags (int va, int vb, int vc)
 Sets the visibility of the all the edges. More...
 
int getEdgeVis (int edge)
 Retrieves the edge visibility for the specified edge. More...
 
DWORD getVert (int index)
 Returns the index into the mesh vertex array of the specified vertex. More...
 
DWORD * getAllVerts (void)
 Retrieves a pointer to the vertex array. More...
 
BOOL Hidden ()
 Determines if the face is hidden or visible. More...
 
void Hide ()
 Hides this face (makes it invisible in the viewports). More...
 
void Show ()
 Shows this face (makes it visible in the viewports). More...
 
void SetHide (BOOL hide)
 Sets the hidden state of this face. More...
 
BOOL InForeground ()
 
void PushToForeground ()
 
void PushToBackground ()
 
void SetInForegound (BOOL foreground)
 
BOOL IsBackFacing ()
 
void SetBackFacing ()
 
void SetFrontFacing ()
 
void SetBackFacing (BOOL backFacing)
 
DllExport DWORD GetOtherIndex (DWORD v0, DWORD v1)
 Returns the first vertex in the face that isn't v0 or v1. More...
 
DllExport DWORD GetEdgeIndex (DWORD v0, DWORD v1)
 Returns the index of the edge in the face that goes from v0 to v1, or v1 to v0. More...
 
DllExport int Direction (DWORD v0, DWORD v1) const
 Indicates order in which vertices v0 and v1 appear in the face. More...
 
DllExport DWORD GetVertIndex (DWORD v0)
 Returns the index of the specified vertex in this face's vertex list (0, 1 or 2). More...
 
DllExport void OrderVerts (DWORD &v0, DWORD &v1)
 This method switches v0,v1 if needed to put them in face-order. More...
 

Public Attributes

DWORD v [3]
 These are zero-based indices into a mesh object's array of vertices. More...
 
DWORD smGroup
 Smoothing group bits for the face. More...
 
DWORD flags
 The Face Flags: Can be from the following list: More...
 

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...
 

Detailed Description

This class represents a single triangular face.

The class maintains three indices into the vertex list for the face, a 32-bit smoothing group for the face, and 32-bits of face flags. The flags also store information about the visibility of the face, the visibility of the three edges, and whether or not the face has texture vertices present. The most significant 16-bits of the face flags store the material index. All methods of this class are implemented by the system.

See also
Class Mesh.

Constructor & Destructor Documentation

◆ Face()

Face ( )
inline

Constructor.

The smoothing groups and face flags are initialized to zero.

217 { smGroup = flags = 0; }
DWORD flags
The Face Flags: Can be from the following list:
Definition: mesh.h:213
DWORD smGroup
Smoothing group bits for the face.
Definition: mesh.h:204

Member Function Documentation

◆ getMatID()

MtlID getMatID ( )
inline

Retrieves the zero based material ID for this face.

Note: typedef unsigned short MtlID;

221 { return (int)( ( flags >> FACE_MATID_SHIFT ) & FACE_MATID_MASK); }
#define FACE_MATID_SHIFT
The number of bits to shift the flags to access the material.
Definition: MeshFaceFlagConstants.h:54
#define FACE_MATID_MASK
A mask used to access the material ID.
Definition: MeshFaceFlagConstants.h:55

◆ setMatID()

void setMatID ( MtlID  id)
inline

Sets the material ID for this face.

Parameters
idSpecifies the zero based material index.
226 {flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}

◆ setSmGroup()

void setSmGroup ( DWORD  i)
inline

Sets the smoothing group bits for this face.

Parameters
iSpecifies the smoothing group bits for this face.
229 { smGroup = i; }

◆ getSmGroup()

DWORD getSmGroup ( void  )
inline

Returns the smoothing group bits for this face.

232 { return smGroup; }

◆ setVerts() [1/2]

DllExport void setVerts ( DWORD *  vrt)

Sets the vertices of this face.

Parameters
vrtAn array of the 3 vertices to store. These are zero based indices into the mesh object's array of vertices.

◆ setVerts() [2/2]

void setVerts ( int  a,
int  b,
int  c 
)
inline

Sets the vertices of this face.

The specified indexes are zero based indices into the mesh object's array of vertices.

Parameters
aSpecifies the first vertex.
bSpecifies the second vertex.
cSpecifies the third vertex.
244 { v[0]=a; v[1]=b; v[2]=c; }
DWORD v[3]
These are zero-based indices into a mesh object's array of vertices.
Definition: mesh.h:197

◆ setEdgeVis()

DllExport void setEdgeVis ( int  edge,
int  visFlag 
)

Sets the visibility of the specified edge.

Parameters
edgeSpecifies the edge to set the visibility of. You may use 0, 1, or 2.
visFlagOne of the following values:
  • EDGE_VIS Sets the edge as visible.
  • EDGE_INVIS Sets the edge as invisible.

◆ setEdgeVisFlags()

DllExport void setEdgeVisFlags ( int  va,
int  vb,
int  vc 
)

Sets the visibility of the all the edges.

Parameters
vaSpecifies the visibility for edge 0. Use either EDGE_VIS or EDGE_INVIS.
vbSpecifies the visibility for edge 1. Use either EDGE_VIS or EDGE_INVIS.
vcSpecifies the visibility for edge 2. Use either EDGE_VIS or EDGE_INVIS.

◆ getEdgeVis()

int getEdgeVis ( int  edge)
inline

Retrieves the edge visibility for the specified edge.

Parameters
edgeSpecifies the edge.
Returns
Nonzero if the edge is visible, zero if the edge is invisible.
268 { return flags & (VIS_BIT << edge); }
#define VIS_BIT
Definition: MeshFaceFlagConstants.h:20

◆ getVert()

DWORD getVert ( int  index)
inline

Returns the index into the mesh vertex array of the specified vertex.

Parameters
indexSpecifies the vertex to retrieve. You may use 0, 1 or 2.
273 { return v[index]; }

◆ getAllVerts()

DWORD* getAllVerts ( void  )
inline

Retrieves a pointer to the vertex array.

Returns
A pointer to the vertex array.
277 { return v; }

◆ Hidden()

BOOL Hidden ( )
inline

Determines if the face is hidden or visible.

Returns
TRUE if the face is hidden; otherwise FALSE.
281 {return flags&FACE_HIDDEN?TRUE:FALSE;}
#define FACE_HIDDEN
Face visibility bit.
Definition: MeshFaceFlagConstants.h:33

◆ Hide()

void Hide ( )
inline

Hides this face (makes it invisible in the viewports).

284 {flags|=FACE_HIDDEN;}

◆ Show()

void Show ( )
inline

Shows this face (makes it visible in the viewports).

287 {flags&=~FACE_HIDDEN;}

◆ SetHide()

void SetHide ( BOOL  hide)
inline

Sets the hidden state of this face.

Parameters
hideSpecifies the hidden state for the face. Pass TRUE to hide the face; FALSE to show it.
292 {if (hide) Hide(); else Show();}
void Hide()
Hides this face (makes it invisible in the viewports).
Definition: mesh.h:284
void Show()
Shows this face (makes it visible in the viewports).
Definition: mesh.h:287

◆ InForeground()

BOOL InForeground ( )
inline
294 {return flags&FACE_INFOREGROUND?TRUE:FALSE;}
#define FACE_INFOREGROUND
Used to track faces that are in the foreground.
Definition: MeshFaceFlagConstants.h:47

◆ PushToForeground()

void PushToForeground ( )
inline

◆ PushToBackground()

void PushToBackground ( )
inline

◆ SetInForegound()

void SetInForegound ( BOOL  foreground)
inline
297 {if (foreground) PushToForeground(); else PushToBackground();}
void PushToBackground()
Definition: mesh.h:296
void PushToForeground()
Definition: mesh.h:295

◆ IsBackFacing()

BOOL IsBackFacing ( )
inline
299 {return flags&FACE_BACKFACING?TRUE:FALSE;}
#define FACE_BACKFACING
Used to track which faces are back facing.
Definition: MeshFaceFlagConstants.h:48

◆ SetBackFacing() [1/2]

void SetBackFacing ( )
inline

◆ SetFrontFacing()

void SetFrontFacing ( )
inline

◆ SetBackFacing() [2/2]

void SetBackFacing ( BOOL  backFacing)
inline
302 {if (backFacing) SetBackFacing(); else SetFrontFacing();}
void SetBackFacing()
Definition: mesh.h:300
void SetFrontFacing()
Definition: mesh.h:301

◆ GetOtherIndex()

DllExport DWORD GetOtherIndex ( DWORD  v0,
DWORD  v1 
)

Returns the first vertex in the face that isn't v0 or v1.

Parameters
v0The zero based index of one of the vertices to check.
v1The zero based index of the other vertex to check.
Returns
The zero based index of the vertex found in the Mesh's vertex list.

◆ GetEdgeIndex()

DllExport DWORD GetEdgeIndex ( DWORD  v0,
DWORD  v1 
)

Returns the index of the edge in the face that goes from v0 to v1, or v1 to v0.

Parameters
v0The zero based index of the vertex at one end of the edge.
v1The zero based index of the vertex at the other end of the edge.
Returns
The zero based index of the edge found in the Mesh's edge list.

◆ Direction()

DllExport int Direction ( DWORD  v0,
DWORD  v1 
) const

Indicates order in which vertices v0 and v1 appear in the face.

Parameters
v0One vertex on this face.
v1Another vertex on this face.
Returns
1 if v1 follows v0 in sequence (This includes e.g. when Face::v[2] == v0 and Face::v[0] == v1.) -1 if v0 follows v1 in sequence 0 if v0 or v1 are not on the face.

◆ GetVertIndex()

DllExport DWORD GetVertIndex ( DWORD  v0)

Returns the index of the specified vertex in this face's vertex list (0, 1 or 2).

If not found 3 is returned.

Parameters
v0The zero based index of the vertex to check.

◆ OrderVerts()

DllExport void OrderVerts ( DWORD &  v0,
DWORD &  v1 
)

This method switches v0,v1 if needed to put them in face-order.

If v0 and v1 are in the order in which they appear in the face, or if one or both of them are not actually on the face, nothing happens. If however v0 follows v1, the values of the parameters are switched, so that they are then in the correct order for this face. Sample Code:

Face & f = mesh.faces[edge.f[0]];
DWORD v0 = edge.v[0];
DWORD v1 = edge.v[1];
// Switch v0, v1 if needed to match orientation in selected face.
f.OrderVerts(v0,v1);
This class represents a single triangular face.
Definition: mesh.h:192
DllExport void OrderVerts(DWORD &v0, DWORD &v1)
This method switches v0,v1 if needed to put them in face-order.
Parameters
v0One vertex on this face.
v1Another vertex on this face.

Member Data Documentation

◆ v

DWORD v[3]

These are zero-based indices into a mesh object's array of vertices.

◆ smGroup

DWORD smGroup

Smoothing group bits for the face.

Each bit of this 32 bit value represents membership in a smoothing group. The least significant bit represents smoothing group #1 while the most significant bit represents group #32. If two adjacent faces are assigned the same smoothing group bit, the edge between them is rendered smoothly.

◆ flags

DWORD flags

The Face Flags: Can be from the following list: