Public Member Functions | Public Attributes

Face Class Reference

This reference page is linked to from the following overview topics: Mesh Related Classes, 3DXI Mesh.


Search for all occurrences

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.

#include <mesh.h>

Inheritance diagram for Face:
Inheritance graph
[legend]

List of all members.

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)
  Retrieves the edge visibility for the specified edge.
DWORD  getVert (int index)
  Returns the index into the mesh vertex array of the specified vertex.
DWORD *  getAllVerts (void)
  Retrieves a pointer to the vertex array.
BOOL  Hidden ()
  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)
  Indicates order in which vertices v0 and v1 appear in the face.
DllExport DWORD  GetVertIndex (DWORD v0)
  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:

Constructor & Destructor Documentation

Face ( ) [inline]

Constructor.

The smoothing groups and face flags are initialized to zero.

{ smGroup = flags = 0; }

Member Function Documentation

MtlID getMatID ( ) [inline]

Retrieves the zero based material ID for this face.

Note: typedef unsigned short MtlID;

{ return (int)( ( flags >> FACE_MATID_SHIFT ) & FACE_MATID_MASK); }
void setMatID ( MtlID  id ) [inline]

Sets the material ID for this face.

Parameters:
id Specifies the zero based material index.
{flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
void setSmGroup ( DWORD  i ) [inline]

Sets the smoothing group bits for this face.

Parameters:
i Specifies the smoothing group bits for this face.
{ smGroup = i; }
DWORD getSmGroup ( void  ) [inline]

Returns the smoothing group bits for this face.

{ return smGroup; }
DllExport void setVerts ( DWORD *  vrt )

Sets the vertices of this face.

Parameters:
vrt An array of the 3 vertices to store. These are zero based indices into the mesh object's array of vertices.
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:
a Specifies the first vertex.
b Specifies the second vertex.
c Specifies the third vertex.
{ v[0]=a; v[1]=b; v[2]=c; }
DllExport void setEdgeVis ( int  edge,
int  visFlag 
)

Sets the visibility of the specified edge.

Parameters:
edge Specifies the edge to set the visibility of. You may use 0, 1, or 2.
visFlag One of the following values:
  • EDGE_VIS Sets the edge as visible.
  • EDGE_INVIS Sets the edge as invisible.
DllExport void setEdgeVisFlags ( int  va,
int  vb,
int  vc 
)

Sets the visibility of the all the edges.

Parameters:
va Specifies the visibility for edge 0. Use either EDGE_VIS or EDGE_INVIS.
vb Specifies the visibility for edge 1. Use either EDGE_VIS or EDGE_INVIS.
vc Specifies the visibility for edge 2. Use either EDGE_VIS or EDGE_INVIS.
int getEdgeVis ( int  edge ) [inline]

Retrieves the edge visibility for the specified edge.

Parameters:
edge Specifies the edge.
Returns:
Nonzero if the edge is visible, zero if the edge is invisible.
{ return flags & (VIS_BIT << edge); }
DWORD getVert ( int  index ) [inline]

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

Parameters:
index Specifies the vertex to retrieve. You may use 0, 1 or 2.
{ return v[index]; }
DWORD* getAllVerts ( void  ) [inline]

Retrieves a pointer to the vertex array.

Returns:
A pointer to the vertex array.
{ return v; }
BOOL Hidden ( ) [inline]

Determines if the face is hidden or visible.

Returns:
TRUE if the face is hidden; otherwise FALSE.
{return flags&FACE_HIDDEN?TRUE:FALSE;}
void Hide ( ) [inline]

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

{flags|=FACE_HIDDEN;}
void Show ( ) [inline]

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

{flags&=~FACE_HIDDEN;}
void SetHide ( BOOL  hide ) [inline]

Sets the hidden state of this face.

Parameters:
hide Specifies the hidden state for the face. Pass TRUE to hide the face; FALSE to show it.
{if (hide) Hide(); else Show();}
BOOL InForeground ( ) [inline]
{return flags&FACE_INFOREGROUND?TRUE:FALSE;}
void PushToForeground ( ) [inline]
{flags|=FACE_INFOREGROUND;}
void PushToBackground ( ) [inline]
{flags&=~FACE_INFOREGROUND;}
void SetInForegound ( BOOL  foreground ) [inline]
BOOL IsBackFacing ( ) [inline]
{return flags&FACE_BACKFACING?TRUE:FALSE;}
void SetBackFacing ( ) [inline]
{flags|=FACE_BACKFACING;}
void SetFrontFacing ( ) [inline]
{flags&=~FACE_BACKFACING;}
void SetBackFacing ( BOOL  backFacing ) [inline]
DllExport DWORD GetOtherIndex ( DWORD  v0,
DWORD  v1 
)

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

Parameters:
v0 The zero based index of one of the vertices to check.
v1 The zero based index of the other vertex to check.
Returns:
The zero based index of the vertex found in the Mesh's vertex list.
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:
v0 The zero based index of the vertex at one end of the edge.
v1 The 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.
DllExport int Direction ( DWORD  v0,
DWORD  v1 
)

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

Parameters:
v0 One vertex on this face.
v1 Another 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.
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:
v0 The zero based index of the vertex to check.
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);
Parameters:
v0 One vertex on this face.
v1 Another vertex on this face.

Member Data Documentation

DWORD v[3]

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

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.

DWORD flags

The Face Flags: Can be from the following list:


Face Face Face Face Face Face Face Face Face Face
Face Face Face Face Face Face Face Face Face Face