3ds Max C++ API Reference
Loading...
Searching...
No Matches
Face Class Reference

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

#include <mesh.h>

+ Inheritance diagram for Face:

Public Member Functions

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

Public Attributes

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

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

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.

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

Member Function Documentation

◆ getMatID()

MtlID getMatID ( )
inline

Retrieves the zero based material ID for this face.

Note: typedef unsigned short MtlID;

223{ 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.
228{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.
231{ smGroup = i; }

◆ getSmGroup()

DWORD getSmGroup ( void  )
inline

Returns the smoothing group bits for this face.

234{ 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.
246{ 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:199
float float b
Definition: texutil.h:51
float a
Definition: texutil.h:51

◆ 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) const
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.
270{ return flags & (VIS_BIT << edge); }
#define VIS_BIT
Definition: MeshFaceFlagConstants.h:20

◆ getVert()

DWORD getVert ( int  index) const
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.
275{ return v[index]; }

◆ getAllVerts()

DWORD * getAllVerts ( void  )
inline

Retrieves a pointer to the vertex array.

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

◆ Hidden()

BOOL Hidden ( ) const
inline

Determines if the face is hidden or visible.

Returns
TRUE if the face is hidden; otherwise FALSE.
283{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).

◆ Show()

void Show ( )
inline

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

289{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.
294{if (hide) Hide(); else Show();}
void Hide()
Hides this face (makes it invisible in the viewports).
Definition: mesh.h:286
void Show()
Shows this face (makes it visible in the viewports).
Definition: mesh.h:289

◆ InForeground()

BOOL InForeground ( )
inline
296{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
298{flags&=~FACE_INFOREGROUND;}

◆ SetInForegound()

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

◆ IsBackFacing()

BOOL IsBackFacing ( )
inline
301{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
303{flags&=~FACE_BACKFACING;}

◆ SetBackFacing() [2/2]

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

◆ 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) const

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:194
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: