Public Member Functions | Public Attributes

Patch Class Reference

This reference page is linked to from the following overview topics: Edit Modifiers, Principal Classes.


Search for all occurrences

Detailed Description

See also:
Class PatchMesh, Class TVPatch, Working with Patches.

Description:
A PatchMesh is made up of a series of Patch objects derived from this class. This is similar to the way faces relate to a mesh. All methods of this class are implemented by the system.
Data Members:
int type;

The patch type. One of the following values:

PATCH_UNDEF

Undefined.

PATCH_TRI

Triangular patch.

PATCH_QUAD

Quadrilateral patch.

int v[4];

A patch can have three or four vertices based on the type. The corner vertices on a patch are referred to as a, b, c, (and if it's a quad patch d). These are ordered a, b, c, d going counter-clockwise around the patch.

int vec[8];

A patch can have six or eight vector points. The vectors are referred to as follows: ab is the vector coming out of vertex a towards b. ba is the one coming out of b towards a. bc is the vector coming out of b towards c. cb is the one coming out of c towards b, and so on.

int interior[4];

A patch can have three or four interior vertices.

Point3 aux[9];

This is used internally for triangular patches only (degree 4 control points).

int edge[4];

Pointers into the edge list. There can be three or four depending on the patch type.

DWORD smGroup;

The smoothing group. This defaults to 1. All patches are smoothed in a PatchMesh.

DWORD flags;

Patch Flags. The following value may be set.

PATCH_AUTO

Interior vertices are computed automatically if this flag is set (and normally it is set). An example of when this flag would not be set is if you were creating a primitive using patches that needed to make special interior control points to create the shape. In this case you'd clear this flag and then put whatever values you needed into the vec array.

PATCH_HIDDEN

The patch is hidden.

PATCH_LINEARMAPPING

This option is available in release 4.0 and later only.

The patch is using the old linear mapping scheme.

PATCH_USE_CRUVED_MAPPING_ON_VERTEX_COLOR

This option is available in release 4.0 and later only.

The patch is using the new curved mapping for vertex colors also.

int aux1;

This data member is available in release 3.0 and later only.

This is used to track topology changes during editing (Edit Patch).

int aux2;

This data member is available in release 3.0 and later only.

This is used to track topology changes during editing (PatchMesh).

#include <patch.h>

Inheritance diagram for Patch:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  Patch ()
CoreExport  Patch (int type)
CoreExport  Patch (Patch &fromPatch)
CoreExport  ~Patch ()
CoreExport void  Init ()
CoreExport void  setVerts (int *vrt)
void  setVerts (int a, int b, int c)
void  setVerts (int a, int b, int c, int d)
void  setVecs (int ab, int ba, int bc, int cb, int ca, int ac)
void  setVecs (int ab, int ba, int bc, int cb, int cd, int dc, int da, int ad)
void  setInteriors (int a, int b, int c)
void  setInteriors (int a, int b, int c, int d)
int  getVert (int index)
int *  getAllVerts (void)
MtlID  getMatID ()
void  setMatID (MtlID id)
Point3  getUVW (int index) const
Point2  getUV (int index) const
bool  getVertUVW (int vert, Point3 &uvw) const
bool  getVertUV (int vert, Point2 &uv) const
Point3  BicubicSurface (PatchMesh *pMesh, const float *uu, const float *vv)
CoreExport Point3  interp (PatchMesh *pMesh, float u, float v, float w)
CoreExport Point3  interp (PatchMesh *pMesh, float u, float v)
CoreExport Point3  WUTangent (PatchMesh *pMesh, float u, float v, float w)
CoreExport Point3  UVTangent (PatchMesh *pMesh, float u, float v, float w)
CoreExport Point3  VWTangent (PatchMesh *pMesh, float u, float v, float w)
CoreExport Point3  UTangent (PatchMesh *pMesh, float u, float v)
CoreExport Point3  VTangent (PatchMesh *pMesh, float u, float v)
CoreExport Point3  Normal (PatchMesh *pMesh, float u, float v, float w)
CoreExport Point3  Normal (PatchMesh *pMesh, float u, float v)
CoreExport void  ComputeAux (PatchMesh *pMesh, int index)
CoreExport void  ComputeAux (PatchMesh *pMesh)
CoreExport void  computeInteriors (PatchMesh *pMesh)
CoreExport void  SetType (int type, BOOL init=FALSE)
CoreExport Patch operator= (Patch &from)
CoreExport void  SetAuto (BOOL sw=TRUE)
BOOL  IsAuto ()
CoreExport void  SetHidden (BOOL sw=TRUE)
BOOL  IsHidden ()
int  WhichEdge (int v1, int v2)
int  WhichVert (int v)
CoreExport void  Dump ()
CoreExport IOResult  Save (ISave *isave)
CoreExport IOResult  Load (ILoad *iload)

Public Attributes

int  type
int  v [4]
int  vec [8]
int  interior [4]
Point3  aux [9]
int  edge [4]
DWORD  smGroup
DWORD  flags
int  aux1
int  aux2

Constructor & Destructor Documentation

CoreExport Patch ( )
Remarks:
Constructor. The type is set to undefined, the smooth group is set to 1, and the flags indicate automatic interior points. Note: This constructor does not allocate arrays. Use SetType(type).
CoreExport Patch ( int  type )
CoreExport Patch ( Patch fromPatch )
Remarks:
Constructor. The this pointer is set to the fromPatch.
CoreExport ~Patch ( )
Remarks:
Destructor.

Member Function Documentation

CoreExport void Init ( )
Remarks:
This method is used by the constructors internally. Developers should not call this method.
CoreExport void setVerts ( int *  vrt )
Remarks:
The vertices are copied from the array passed. Based on the patch type either three or four vertices are copied.
Parameters:
int *vrt

The vertices are set to these values. These values are indices into the v array.
void setVerts ( int  a,
int  b,
int  c 
) [inline]
Remarks:
Sets the vertices for Tri Patch to those passed.
Parameters:
int a, int b, int c

The vertices to set. v[0]=a; v[1]=b; v[2]=c;These values are indices into the v array.
{ assert(type == PATCH_TRI); v[0]=a; v[1]=b; v[2]=c; }
void setVerts ( int  a,
int  b,
int  c,
int  d 
) [inline]
Remarks:
Sets the vertices for a Quad Patch to those passed.
Parameters:
int a, int b, int c, int d

The vertices to set. v[0]=a; v[1]=b; v[2]=c; v[3] = d; These values are indices into the v array.
{ assert(type == PATCH_QUAD); v[0]=a; v[1]=b; v[2]=c; v[3]=d; }
void setVecs ( int  ab,
int  ba,
int  bc,
int  cb,
int  ca,
int  ac 
) [inline]
Remarks:
Sets the vectors for a Tri Patch to those passed.
Parameters:
int ab, int ba, int bc, int cb, int ca, int ac;

The vectors to set. vec[0]=ab; vec[1]=ba; vec[2]=bc;

vec[3]=cb; vec[4]=ca; vec[5]=ac;These values are indices into the vec array.
                                                                        {
            assert(type == PATCH_TRI);
            vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=ca; vec[5]=ac;
            }
void setVecs ( int  ab,
int  ba,
int  bc,
int  cb,
int  cd,
int  dc,
int  da,
int  ad 
) [inline]
Remarks:
Sets the vectors for a Quad patch to those passed.
Parameters:
int ab, int ba, int bc, int cb,

int cd, int dc, int da, int ad;

The vectors to set. vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb;

vec[4]=cd; vec[5]=dc; vec[6]=da, vec[7]=ad; These values are indices into the vec array.
                                                                                        {
            assert(type == PATCH_QUAD);
            vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=cd; vec[5]=dc; vec[6]=da, vec[7]=ad;
            }
void setInteriors ( int  a,
int  b,
int  c 
) [inline]
Remarks:
Sets the interior vertex values for a Tri Patch.
Parameters:
The interior values to set: interior[0]=a; interior[1]=b; interior[2]=c; These values are indices into the interior array.
                                                  {
            assert(type == PATCH_TRI);
            interior[0]=a; interior[1]=b; interior[2]=c;
            }
void setInteriors ( int  a,
int  b,
int  c,
int  d 
) [inline]
Remarks:
Sets the interior vertex values for a Tri Patch.
Parameters:
int a, int b, int c, int d

The interior values to set: interior[0]=a; interior[1]=b; interior[2]=c; interior[3]=d; These values are indices into the interior array.
                                                         {
            assert(type == PATCH_QUAD);
            interior[0]=a; interior[1]=b; interior[2]=c; interior[3]=d;
            }
int getVert ( int  index ) [inline]
Remarks:
Returns the vertex specified by the index.
Parameters:
int index

The vertex to retrieve. This value may be 0, 1, 2 (or 3 if it's a quad patch).
{ return v[index]; }
int* getAllVerts ( void  ) [inline]
Remarks:
Returns a pointer to the vertex array.
{ return v; }
MtlID getMatID ( ) [inline]
void setMatID ( MtlID  id ) [inline]
{flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
Point3 getUVW ( int  index ) const
Point2 getUV ( int  index ) const
bool getVertUVW ( int  vert,
Point3 uvw 
) const
bool getVertUV ( int  vert,
Point2 uv 
) const
Point3 BicubicSurface ( PatchMesh pMesh,
const float *  uu,
const float *  vv 
)
CoreExport Point3 interp ( PatchMesh pMesh,
float  u,
float  v,
float  w 
)
Remarks:
Triangle patch interpolator. This method returns a point on the surface of the patch based on the specified u, v and w values. The u, v, w values are barycentric coordinates. u+v+w = 1.0. If u is 1, and v and w are 0, the point is at the first vertex. If u is 0, v is 1, and w is 0, then the point is at the second vertex. If u and v are 0 and w is 1 then the point is at the third vertex. Varying positions between these values represent different positions on the patch.
Parameters:
PatchMesh *pMesh

Points to the PatchMesh to interpolate.

float u, float v, float w

The barycentric coordinates.
Returns:
A point on the surface of the patch.
CoreExport Point3 interp ( PatchMesh pMesh,
float  u,
float  v 
)
Remarks:
Quadrilateral patch interpolator. This method returns a point on the surface of the patch based on the specified u and v values.
Parameters:
PatchMesh *pMesh

Points to the PatchMesh to interpolate.

float u

The u value in the range 0.0 to 1.0. This defines the distance along one axis of the patch.

float v

The v value in the range 0.0 to 1.0. This defines the distance along the other axis of the patch.
Returns:
A point on the surface of the patch.
CoreExport Point3 WUTangent ( PatchMesh pMesh,
float  u,
float  v,
float  w 
)
CoreExport Point3 UVTangent ( PatchMesh pMesh,
float  u,
float  v,
float  w 
)
CoreExport Point3 VWTangent ( PatchMesh pMesh,
float  u,
float  v,
float  w 
)
CoreExport Point3 UTangent ( PatchMesh pMesh,
float  u,
float  v 
)
CoreExport Point3 VTangent ( PatchMesh pMesh,
float  u,
float  v 
)
CoreExport Point3 Normal ( PatchMesh pMesh,
float  u,
float  v,
float  w 
)
CoreExport Point3 Normal ( PatchMesh pMesh,
float  u,
float  v 
)
CoreExport void ComputeAux ( PatchMesh pMesh,
int  index 
)
Remarks:
This method is used internally. It compute the degree-4 alias control points.
CoreExport void ComputeAux ( PatchMesh pMesh )
CoreExport void computeInteriors ( PatchMesh pMesh )
Remarks:
Whenever you are done working on a PatchMesh, this method should be called. If the interior vertices of the patch are automatic it will update them to correctly match the changes to the other vectors. This computes interior vertices considering this patch only.
Parameters:
PatchMesh* pMesh

Points to the PatchMesh to compute the interior vertices of.
CoreExport void SetType ( int  type,
BOOL  init = FALSE 
)
Remarks:
Sets the type of the patch to either Tri or Quad and optionally resets the arrays.
Parameters:
int type

The patch type. One of the following values:

PATCH_TRI - Triangular Patch

PATCH_QUAD - Quadrilateral Patch

BOOL init = FALSE

If TRUE the arrays are reset to undefined; otherwise they are left unchanged. Normally this is set to FALSE.
CoreExport Patch& operator= ( Patch from )
Remarks:
Assignment operator.
Parameters:
Patch& from

The patch to copy from.
CoreExport void SetAuto ( BOOL  sw = TRUE )
Remarks:
Sets the flag controlling if interior vertices are computed automatically.
Parameters:
BOOL sw = TRUE

TRUE to set; FALSE to clear.
BOOL IsAuto ( ) [inline]
Remarks:
Returns TRUE if the PATCH_AUTO flag is set; otherwise FALSE.
{ return (flags & PATCH_AUTO) ? TRUE : FALSE; }
CoreExport void SetHidden ( BOOL  sw = TRUE )
Remarks:
This method is available in release 3.0 and later only.

Sets the hidden state of the patch.
Parameters:
BOOL sw = TRUE

TRUE to hide; FALSE to unhide.
BOOL IsHidden ( ) [inline]
Remarks:
This method is available in release 3.0 and later only.

Returns TRUE if the patch is hidden; otherwise FALSE.
{ return (flags & PATCH_HIDDEN) ? TRUE : FALSE; }
int WhichEdge ( int  v1,
int  v2 
)
Remarks:
This method is available in release 4.0 and later only.

This method provides an easy way to find out which edge of a patch uses two vertices. Simply supply the two vertices of the desired edge and call this method.
Parameters:
int v1, int v2

The index of the two vertices.
Returns:
The index of the edge within the patch (0 - 2 for triangular patches, 0 - 3 for quad patches).

CAUTION: Be sure to check the return value before using it for an index
  • If the two vertices supplied are not used as an edge on this patch, -1 is returned.
int WhichVert ( int  v )
Remarks:
This method is available in release 4.0 and later only.

This method provides an easy way to find out which corner of a patch uses a given vertex. Simply supply the vertex index and call this method.
Parameters:
int v

The index of the vertex.
Returns:
The corner index of the given vertex within the patch (0 - 2 for triangular patches, 0 - 3 for quad patches).

CAUTION: Be sure to check the return value before using it for an index
  • If the vertex supplied is not used as a corner on this patch, -1 is returned.
CoreExport void Dump ( )
Remarks:
This may be called to dump the patch mesh structure via DebugPrint(). See Debugging.
Operators:
CoreExport IOResult Save ( ISave isave )
CoreExport IOResult Load ( ILoad iload )

Member Data Documentation

int type
int v[4]
int vec[8]
int interior[4]
Point3 aux[9]
int edge[4]
DWORD smGroup
DWORD flags
int aux1
int aux2

Patch Patch Patch Patch Patch Patch Patch Patch Patch Patch
Patch Patch Patch Patch Patch Patch Patch Patch Patch Patch