Class PatchMesh

3DS Max Plug-In SDK

Class PatchMesh

See Also: Class Patch, Class PatchVec, Class PatchEdge, Class PatchVert, Class BitArray, Class TessApprox, Class PatchTVert, Working with Patches.

class PatchMesh : public BaseInterfaceServer

Description:

A patch mesh can be made up of any number of patches. Each of these patches can be three or four sided. Each edge of a patch can only be used by either one patch (which makes it an open edge) or two patches (which makes it a transitional edge between the two).

All methods of this class are implemented by the system.

Friend Classes:

friend class Patch;

Method Groups:

The following hyperlinks take you to the start of groups of related methods:

Constructors / Destructor

Vert Access

TVert Access

Vec Access

Patch Access

Edge Access

RVert Access

Materials / Mapping

buildLinkages() / computeInteriors() / ApplyConstraints() / GetEdge()

Tri / Quad Patch Creation

Get/Set Mesh Steps and Adaptive Switch/TessApprox

Render / Snap / Hit Test

Display Flag Access

Selection Access

Data Flow Evaluation

Dump()

Operators

Data Members:

public:

Topology:

int numVerts;

The number of vertices.

int numVecs;

The number of vectors.

int numPatches;

The number of patches.

int numEdges;

The number of edges.

Patch *patches;

The list of patches.

PatchVec *vecs;

The list of PatchVecs.

PatchEdge *edges;

The list of PatchEdges.

Tab<HookPoint> hooks;

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

This table is used internally

Geometry:

PatchVert *verts;

The list of PatchVerts.

Texture coordinate assignment:

Tab<int> numTVerts;

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

A table containing the number of texture vertices for each channel.

Tab<PatchTVert *> tVerts;

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

A table containing pointers to the texture vertices for each channel.

Previous to R4.0 this was a Tab<UVVert *>.

Tab<TVPatch *> tvPatches;  

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

A table containing pointers to the texture vertex patches for each channel.

Material assignment

DWORD mtlIndex;

The object level material.

Selection

BitArray vertSel;

The selected vertices.

BitArray edgeSel;

The selected edges.

BitArray patchSel;

The selected patches.

int bezVecVert;

This is used internally.

DWORD dispFlags;

The display attribute flags. See List of Patch Display Flags.

DWORD selLevel;

The current selection level. One of the following values:

PATCH_OBJECT - Object level.

PATCH_VERTEX - Vertex level.

PATCH_PATCH - Patch level.

PATCH_EDGE - Edge level.

int cacheSteps;

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

The meshSteps used for the cache.

BOOL cacheAdaptive;

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

The adaptive switch used for the mesh cache.

Tab<Point3> extrudeDeltas;

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

This data member is for internal use only.

Tab<ExtrudeData> extrudeData;

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

This data member is for internal use only.

BitArray bevelEdges;

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

This data member is for internal use only.

Tab<float> edgeDistances;

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

This data member is for internal use only.

Methods:

public:

Constructors / Destructor

Prototype:

PatchMesh();

Remarks:

Constructor. Initializes data members (see Init() below).

Prototype:

PatchMesh(PatchMesh& fromPatch);

Remarks:

Constructor. This PatchMesh is initialized from the specified PatchMesh.

Prototype:

void Init();

Remarks:

Initializes the data members to default values:

meshSteps  = 5;

adaptive  = FALSE;

rVerts   = NULL;

cacheGW   = NULL;

numVerts   = 0;

numVecs   = 0;

numPatches   = 0;

numEdges  = 0;

patches   = NULL;

edges   = NULL;

numTVerts.ZeroCount();

tvPatches.ZeroCount();

tVerts.ZeroCount();

vecs   = NULL;

verts    = NULL;

mtlIndex   = 0;

flags    = 0;

snapVCt   = 0;

snapPCt   = 0; 

snapV   = NULL;

snapP   = NULL;

dispFlags = DISP_LATTICE;

selLevel = PATCH_OBJECT;

bezVecVert  = -1;

bdgBox.Init();

cacheSteps = -9999;

cacheAdaptive = -9999;

prodTess.u = 5;    

prodTess.v = 5;    

prodTess.dist = 2.0f;  

prodTess.ang = 10.0f;  

prodTess.edge = 1.0f;  

prodTess.view = TRUE;  

dispTess.type = TESS_CURVE; 

dispTess.v = 5;    

dispTess.dist = 2.0f;  

dispTess.ang = 10.0f;  

dispTess.edge = 1.0f;  

dispTess.view = TRUE;  

viewTess.u = 5;  

viewTess.v = 5;  

viewTess.view = FALSE; 

viewTess.ang = 20.0f; 

viewTess.dist = 10.0f; 

viewTess.edge = 10.0f; 

Prototype:

~PatchMesh();

Remarks:

Destructor. Frees up allocated arrays.

Prototype:

void CopyPatchDataFrom(PatchMesh &fromPatchMesh);

Remarks:

This method is available in release 3.0 and later only.

The following is similar to operator=, but just takes the major components, not the display flags, selection level, etc.

Parameters:

PatchMesh &fromPatchMesh

The patch mesh to copy from.

Vert Access

Prototype:

BOOL setNumVerts(int ct, BOOL keep = FALSE);

Remarks:

Sets the number of vertices in the patch mesh.

Parameters:

int ct

The new number of vertices.

BOOL keep = FALSE

If TRUE any old vertices are copied to the new array; otherwise they are freed.

Return Value:

TRUE if the number of vertices was allocated; otherwise FALSE.

Prototype:

int getNumVerts();

Remarks:

Returns the number of vertices in the patch mesh.

Prototype:

void setVert(int i, const Point3 &xyz)

Remarks:

Sets the 'i-th' vertex.

Parameters:

int i

The index of the vertex to set.

const Point3 &xyz

The vertex location.

Prototype:

void setVert(int i, float x, float y, float z)

Remarks:

Sets the 'i-th' vertex.

Parameters:

int i

The index of the vertex to set.

float x, float y, float z

The vertex location.

Prototype:

PatchVert &getVert(int i)

Remarks:

Returns the 'i-th' vertex.

Parameters:

int i

The index of the vertex to retrieve.

Prototype:

PatchVert *getVertPtr(int i)

Remarks:

Returns the address of the 'i-th' vertex.

Parameters:

int i

The index of the vertex.

TVert Access

Prototype:

BOOL setNumTVerts(int ct, BOOL keep=FALSE);

Remarks:

Sets the number of mapping verts in the original mapping channel (channel 1).

Parameters:

int ct

The number of map vertices desired.

BOOL keep = FALSE

If TRUE, any existing mapping verts are copied over into the new array.

Return Value:

TRUE if successful, FALSE if unsuccessful.

Prototype:

int getNumTVerts() const;

Remarks:

Returns the number of mapping vertices in the original mapping channel (channel 1).

Prototype:

BOOL setNumTVertsChannel(int mp, int ct, BOOL keep=FALSE);

Remarks:

This method is available in release 2.0 and later only.

Sets the number of mapping verticies in the original TV map or vertex color channel.

Parameters:

int mp

Specifies the channel. If 0, the number of vertices in the original mapping channel (map channel 1) is set. If nonzero, the number of vertices in the vertex color channel (map channel 0) is set.

int ct

The number of map vertices desired.

BOOL keep=FALSE

If TRUE, any existing mapping verts are copied over into the new array.

Return Value:

TRUE on success; otherwise FALSE.

Prototype:

int getNumTVertsChannel(int mp);

Remarks:

This method is available in release 2.0 and later only.

Returns the number of mapping verts in the original map or vertex colors.

Parameters:

int mp

If 0, the number of vertices in the original mapping channel (map channel 1) is returned. If nonzero, the number of vertices in the vertex color channel (map channel 0) is returned.

Prototype:

PatchTVert *mapVerts(int mp);

Remarks:

This method is available in release 4.0 and later only.

Returns a pointer to the list of PatchTVerts for the specified channel of this patch.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

Prototype:

BOOL setNumMapVerts(int mp, int ct, BOOL keep = FALSE);

Remarks:

This method is available in release 3.0 and later only.

Sets the number of mapping verts in the specified mapping channel.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int ct

The number of mapping verts desired.

BOOL keep=FALSE

If TRUE any old vertices are copied to the new array; otherwise they are freed.

Return Value:

TRUE if the number of vertices was allocated; otherwise FALSE.

Prototype:

int getNumMapVerts(int mp);

Remarks:

This method is available in release 3.0 and later only.

Returns the number of mapping verts in the specified mapping channel.

Parameters:

int mp

In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

Prototype:

void setTVert(int i, const UVVert &xyz)

Remarks:

Sets the 'i-th' map vertex.

Parameters:

int i

The index of the map vertex to set.

const UVVert &xyz

The value to set.

Prototype:

void setTVert(int i, float x, float y, float z)

Remarks:

Sets the 'i-th' map vertex.

Parameters:

int i

The index of the map vertex to set.

float x, float y, float z

The values to set.

Prototype:

void setTVertChannel(int channel, int i, const UVVert &xyz);

Remarks:

This method is available in release 2.0 and later only.

Sets the 'i-th' map vertex of the specified channel.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the map vertex to set.

const UVVert &xyz

The value to set.

Prototype:

void setTVertChannel(int channel, int i, float x, float y, float z);

Remarks:

This method is available in release 2.0 and later only.

Sets the 'i-th' map vertex of the specified channel.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the map vertex to set.

float x, float y, float z

The values to set.

Prototype:

void setTVPatchChannel(int channel, int i, TVPatch &tvp);

Remarks:

This method is available in release 3.0 and later only.

Sets the 'i-th' map patch.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the map vertex to set.

TVPatch &tvp

The map patch to set.

Prototype:

void setTVPatch(int i, TVPatch &tvp);

Remarks:

This method is available in release 3.0 and later only.

Sets the specified map patch.

Parameters:

int i

The zero based index of the texture patch to set.

TVPatch &tvp

The map patch to set.

Prototype:

void setMapVert(int mp, int i, const UVVert &xyz);

Remarks:

This method is available in release 3.0 and later only.

Sets the specified mapping vertex in the channel passed.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the vert to set.

const UVVert &xyz

The vert to set.

Prototype:

void setMapVert(int mp, int i, float x, float y, float z);

Remarks:

This method is available in release 3.0 and later only.

Sets the specified mapping vertex in the channel passed.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the vert to set.

float x

The x coordinate of the vert to set.

float y

The y coordinate of the vert to set.

float z

The z coordinate of the vert to set.

Prototype:

void setMapPatch(int mp, int i, const TVPatch &tvp);

Remarks:

This method is available in release 3.0 and later only.

Sets the specified mapping patch in the channel passed.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the TVPatch to set.

const TVPatch &tvp

The map patch to set.

Prototype:

PatchTVert &getMapVert(int mp, int i);

Remarks:

This method is available in release 3.0 and later only.

Previous to R4, this method returned an UVVert&.

Returns a reference to the specified mapping vert from the specified channel.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the vert to get.

Prototype:

PatchTVert *getMapVertPtr(int mp, int i);

Remarks:

This method is available in release 3.0 and later only.

Previous to R4, this method returned an UVVert*.

Returns a pointer to the specified mapping vert from the specified channel.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the vert to get.

Prototype:

TVPatch &getMapPatch(int mp, int i);

Remarks:

This method is available in release 3.0 and later only.

Returns a reference to the specified map patch from the specified channel.

Parameters:

int mp

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The zero based index of the map patch to get.

Prototype:

PatchTVert &getTVert(int i)

Remarks:

Previous to R4, this method returned an UVVert&.

Returns the 'i-th' map vertex.

Parameters:

int i

The index of the map vertex to retrieve.

Prototype:

PatchTVert *getTVertPtr(int i)

Remarks:

Previous to R4, this method returned an UVVert*.

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

Parameters:

int i

The index of the map vertex.

Prototype:

PatchTVert &getTVertChannel(int channel, int i);

Remarks:

This method is available in release 2.0 and later only.

Previous to R4, this method returned an UVVert&.

Returns the 'i-th' map vertex of the specified channel.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the map vertex to retrieve.

Prototype:

PatchTVert *getTVertPtrChannel(int channel, int i);

Remarks:

This method is available in release 2.0 and later only.

Previous to R4, this method returned an UVVert*.

Returns a pointer to the 'i-th' map vertex of the specified channel.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the texture vertex.

TVPatch Access

Prototype:

BOOL setNumTVPatches(int ct, BOOL keep=FALSE, int oldCt=0);

Remarks:

Sets the number of map patches in the original TV channel. (Note that setNumMapPatches() is called from setNumPatches(), so this doesn't need to be called separately once a map channel is active.)

Note:

If the map patches are NULL and keep = TRUE they stay NULL.

If the map patches are NULL and keep = FALSE they are allocated, and map verts also init themselves from the main vert array.

If the map patches are non-NULL and ct = 0 they are set to NULL (and freed)

Parameters:

int ct

The number of map patches desired -- should match the number of patches.

BOOL keep=FALSE

If TRUE, existing map patches are copied into the new map patch array. oldCt should specify how many patches were around previously.

int oldCt=0

The old number of patches. This is important for determining how much to copy over when keep is TRUE.

Return Value:

TRUE if storage has been allocated and the number is set; otherwise FALSE.

Prototype:

BOOL setNumTVPatchesChannel(int channel, int ct, BOOL keep=FALSE, int oldCt=0);

Remarks:

This method is available in release 2.0 and later only.

Sets the number of map patches in the original TV or vertex color channels. (Note that setNumMapPatches() is called from setNumPatches(), so this doesn't need to be called separately once a map channel is active.)

Note:

If the map patches are NULL and keep = TRUE they stay NULL.

If the map patches are NULL and keep = FALSE they are allocated, and map verts also init themselves from the main vert array.

If the map patches are non-NULL and ct = 0 they are set to NULL (and freed)

Parameters:

int channel

If 0, the number of map patches in the original map channel are set. If nonzero, the number of map patches in the vertex color channel is set.

int ct

The number of map patches desired -- should match the number of patches.

BOOL keep=FALSE

The keep flag. See above.

int oldCt=0

The old number of patches. This is important for determining how much to copy over when keep is TRUE.

Return Value:

TRUE if storage has been allocated and the number is set; otherwise FALSE.

Prototype:

BOOL setNumMapPatches(int channel, int ct, BOOL keep=FALSE, int oldCt=0);

Remarks:

This method is available in release 3.0 and later only.

Sets the number of map patches in the specified map channel. (Note that this is called from setNumPatches(), so it doesn't need to be called separately once a map channel is active.)

Note:

If the map patches are NULL and keep = TRUE they stay NULL.

If the map patches are NULL and keep = FALSE they are allocated, and map verts also init themselves from the main vert array.

If the map patches are non-NULL and ct = 0 they are set to NULL (and freed).

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int ct

The number of map patches desired -- should match the number of patches.

BOOL keep=FALSE

If TRUE, existing map patches are copied into the new map patch array. oldCt should specify how many patches were around previously.

int oldCt=0

The old number of patches. This is important for determining how much to copy over when keep is TRUE.

Return Value:

TRUE if storage has been allocated and the number is set; otherwise FALSE.

Prototype:

TVPatch &getTVPatchChannel(int channel, int i);

Remarks:

This method is available in release 2.0 and later only.

Returns the 'i-th' texture patch structure of the specified channel.

Parameters:

int channel

The mapping channel. In this method, 0 is the vertex color channel, and channels 1 through MAX_MESHMAPS-1 are the map channels.

int i

The index of the TVPatch.

Prototype:

TVPatch &getTVPatch(int i);

Remarks:

This method is available in release 2.0 and later only.

Returns the 'i-th' texture patch from map channel 1.

Parameters:

int i

The index of the TVPatch.

Vec Access

Prototype:

BOOL setNumVecs(int ct, BOOL keep = FALSE);

Remarks:

Sets the number of vectors.

Parameters:

int ct

The new vector count.

BOOL keep = FALSE

If TRUE any previous vectors are copied; otherwise they are freed.

Return Value:

TRUE if the number was allocated and set; otherwise FALSE.

Prototype:

int getNumVecs();

Remarks:

Returns the number of vectors.

Prototype:

void setVec(int i, const Point3 &xyz)

Remarks:

Sets the 'i-th' vector.

Parameters:

int i

The index of the vector to set.

const Point3 &xyz

The vector to set.

Prototype:

void setVec(int i, float x, float y, float z)

Remarks:

Sets the 'i-th' vector.

Parameters:

int i

The index of the vector to set.

float x, float y, float z

The vector values to set.

Prototype:

PatchVec &getVec(int i)

Remarks:

Returns the 'i-th' vector.

Parameters:

int i

The index of the vector to retrieve.

Prototype:

PatchVec *getVecPtr(int i)

Remarks:

Returns the address of the 'i-th' vector.

Parameters:

int i

The index of the vector.

Patch Access

Prototype:

BOOL setNumPatches(int ct, BOOL keep = FALSE);

Remarks:

Sets the number of patches.

Parameters:

int ct

The new patch count.

BOOL keep = FALSE

If TRUE any previous patches are copied; otherwise they are freed.

Return Value:

TRUE if the number was allocated and set; otherwise FALSE.

Prototype:

int getNumPatches();

Remarks:

Returns the number of patches.

Edge Access

Prototype:

BOOL setNumEdges(int ct, BOOL keep = FALSE);

Remarks:

Sets the number of edges.

Parameters:

int ct

The new edge count.

BOOL keep = FALSE

If TRUE any previous edges are copied; otherwise they are freed.

Return Value:

TRUE if the number was allocated and set; otherwise FALSE.

Prototype:

int getNumEdges();

Remarks:

Returns the number of edges.

RVert Access

Prototype:

PRVertex &getRVert(int i)

Remarks:

This method is not currently used.

Prototype:

PRVertex *getRVertPtr(int i)

Remarks:

This method is not currently used.

Material / Mapping Access

Prototype:

void setMtlIndex(DWORD i)

Remarks:

This method is no longer used.

Prototype:

DWORD getMtlIndex()

Remarks:

This method is no longer used.

Prototype:

void setNumMaps(int ct, BOOL keep=TRUE);

Remarks:

This method is available in release 3.0 and later only.

Set the number of texture maps used by this PatchMesh.

Parameters:

int ct

The number to use. This is a value between 2 and MAX_MESHMAPS-1.

BOOL keep=TRUE

TRUE to keep the old mapping information after the resize; FALSE to discard it.

Prototype:

void setMapSupport(int chan, BOOL init=TRUE);

Remarks:

This method is available in release 4.0 and later only.

This method will allocate mapping channels as needed. If the map channel is already present, no action is taken. Otherwise, the additional channels are created.

Parameters:

int chan

Specifies which channel. See List of Mapping Channel Index Values. If zero (special vertex color channel) and init is TRUE, all vertex colors are initialized to white (1,1,1).

BOOL init=TRUE

If TRUE, the channel is initialized to match the PatchMesh�s structure.

Prototype:

int getNumMaps();

Remarks:

This method is available in release 3.0 and later only.

Returns the number of mapping channels in use.

Prototype:

BOOL getMapSupport(int mp);

Remarks:

This method is available in release 3.0 and later only.

Returns TRUE if the specified mapping channel is supported; otherwise FALSE.

Parameters:

int mp

Specifies which channel. See List of Mapping Channel Index Values.

Prototype:

int NumMapChannels();

Remarks:

This method is available in release 3.0 and later only.

Returns the maximum number of possible mapping channels.

Prototype:

void ApplyUVWMap(int type,

float utile, float vtile, float wtile,

int uflip, int vflip, int wflip, int cap,

const Matrix3 &tm, int channel=1);

Remarks:

This method may be called to map this PatchMesh with UVW mapping coordinates.

Parameters:

int type

The mapping type. One of the following values:

MAP_PLANAR

MAP_CYLINDRICAL

MAP_SPHERICAL

MAP_BALL

MAP_BOX

float utile

Number of tiles in the U direction.

float vtile

Number of tiles in the V direction.

float wtile

Number of tiles in the W direction.

int uflip

If nonzero the U values are mirrored.

int vflip

If nonzero the V values are mirrored.

int wflip

If nonzero the W values are mirrored.

int cap

This is used with MAP_CYLINDRICAL. If nonzero, then any patch normal that is pointing more vertically than horizontally will be mapped using planar coordinates.

const Matrix3 &tm

This defines the mapping space. As each point is mapped, it is multiplied by this matrix, and then it is mapped.

int channel=1

This parameter is available in release 2.0 and later only.

This indicates which channel the mapping is applied to -- channel==1 corresponds to the original texture channel. Note that this is a change from what it meant before release 3.0. Previously channel 1 referred to the color per vertex channel (and this parameter defaulted to 0).

Prototype:

void ChangePatchToLinearMapping(int index);

Remarks:

This method is available in release 4.0 and later only.

This method changes the mapping of a patch or all selected patches to linear.

Parameters:

int index

The index of the patch for which to change the mapping to linear. A value < 0 indicates all selected patches are to be changed to linear mapping.

Prototype:

void ChangePatchToCurvedMapping(int index);

Remarks:

This method is available in release 4.0 and later only.

This method changes the mapping of a patch or all selected patches to curved.

Parameters:

int index

The index of the patch for which to change the mapping to curved. A value < 0 indicates all selected patches are to be changed to curved mapping.

Prototype:

BOOL ArePatchesLinearMapped(int index);

Remarks:

This method is available in release 4.0 and later only.

This method will check if one or all selected patches have linear mapping applied.

Parameters:

int index

The index of the patch for which to check if mapping is linear. A value < 0 indicates all selected patches are checked for linear mapping.

Return Value:

TRUE if the specified patch or selected patches have linear mapping applied, otherwise FALSE.

Prototype:

BOOL ArePatchesCurvedMapped(int index);

Remarks:

This method is available in release 4.0 and later only.

This method will check if one or all selected patches have curved mapping applied.

Parameters:

int index

The index of the patch for which to check if mapping is curved. A value < 0 indicates all selected patches are checked for curved mapping.

Return Value:

TRUE if the specified patch or selected patches have curved mapping applied, otherwise FALSE.

Prototype:

BOOL RecordTopologyTags();

Remarks:

This method tags the points in the patch components to record our topology (this stores identifying values in the various aux2 fields in the Patch). This information can be used after topology-changing operations to remap information tied to vertices, edges and patches.

Return Value:

Returns TRUE if tagged successfully; otherwise FALSE.

Prototype:

void Transform(Matrix3 &tm);

Remarks:

This method is available in release 3.0 and later only.

Transforms the vertices and vectors of the patch mesh, re- computes the interior bezier points for each patch in the mesh and invalidates the geometry cache.

Parameters:

Matrix3 &tm

The matrix to transform with.

Prototype:

BOOL Weld(float thresh, BOOL weldIdentical=FALSE, int startVert=0);

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

void DeletePatchParts(BitArray &delVerts, BitArray &delPatches);

Remarks:

This method is available in release 3.0 and later only.

This is a method which may be used to delete sets of verts or patches.

Parameters:

BitArray &delVerts

A bit array with bits set for verts to delete.

BitArray &delPatches

A bit array with bits set for patches set to delete.

Prototype:

void Subdivide(int type, BOOL propagate);

Remarks:

This method is available in release 3.0 and later only.

Subdivides the selected edge or patch.

Parameters:

int type

One of the following values:

SUBDIV_EDGES

Subdivides an edge.

SUBDIV_PATCHES

Subdivides an entire patch

BOOL propagate

TRUE to propogate; FALSE to not propogate.

Prototype:

void AddPatch(int type);

Remarks:

This method is available in release 3.0 and later only.

Add a patch of the desired type to each selected edge that doesn't have two patches attached.

Parameters:

int type

One of the following values:

PATCH_TRI

PATCH_QUAD

Prototype:

int AddHook();

Remarks:

This method is available in release 3.0 and later only.

This method is obsolete and should not be used.

Prototype:

int AddHook(int index);

Remarks:

This method is available in release 3.0 and later only.

This method is obsolete and should not be used.

Prototype:

int AddHook(int vertIndex, int segIndex);

Remarks:

This method is available in release 3.0 and later only.

This method is obsolete and should not be used.

Prototype:

int RemoveHook();

Remarks:

This method is available in release 3.0 and later only.

This method is obsolete and should not be used.

Prototype:

int UpdateHooks();

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

void CreateExtrusion(int type = PATCH_PATCH, BOOL edgeClone=FALSE);

Remarks:

This method is available in release 3.0 and later only.

This method will create all the necessary geometry for an extrusion operation.

Parameters:

int type

This option is available in release 4.0 and later only.

Specifies the extrusion type, either PATCH_PATCH or PATCH_EDGE. If the extrusion type is set to PATCH_EDGE, then the edgeClone paramter will tell the function to clone the selected edges prior to creating the extrusion geometry.

BOOL edgeClone

This option is available in release 4.0 and later only.

The edge clone flag. If set to TRUE the function will clone the selected edges prior to creating the exstrusion geometry.

Prototype:

Point3 AverageNormals(int type = PATCH_PATCH);

Remarks:

This method is available in release 3.0 and later only.

This method will allow you to obtain the average normal of all selected patches or edges.

Parameters:

int type

This option is available in release 4.0 and later only.

Specifies if the average normal return is based on all selected patches, using PATCH_PATCH, or all selected edges using PATCH_EDGE.

Prototype:

Point3 PatchNormal(int index);

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

void MoveNormal(float amount, BOOL useLocalNorms, int type);

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

void FlipPatchNormal(int index);

Remarks:

This method is available in release 4.0 and later only.

This method flips the normal of the specified patch. This is done by reordering the vertices. If the PatchMesh has textures assigned to it then the texture patches are processed as well.

Parameters:

int index

The index of the patch for which you want to flip the normal.

Prototype:

void UnifyNormals(BOOL useSel);

Remarks:

This method is available in release 4.0 and later only.

This method makes sure the patches in the operation set are all facing the same direction. This is determined by the vertex order around the edges of the patch.

Parameters:

BOOL useSel

If this parameter is set to TRUE, the operation set is the set of selected patches as indicated by the patchSel BitArray. If this parameter is set to FALSE, all patches are processed.

Prototype:

void AutoSmooth(float angle, BOOL useSel, BOOL preventIndirectSmoothing);

Remarks:

This method is available in release 4.0 and later only.

This method will perform automatic smoothing on the patch mesh. The smoothing angle is determined for each patch by computing the normals at each corner of the patch (using the corner vertex and the two edge vectors connected to that vertex), then averaging the normals of the two corners of each edge to arrive at a normal for that edge. These normals are used to determine whether adjacent patches are within the auto-smooth threshold angle.

Parameters:

float angle

The minimum angle between surface normals for smoothing to be applied, in radians.

BOOL useSel

If this parameter is set to TRUE then only the selected patches are smoothed.

BOOL preventIndirectSmoothing

TRUE to turn on; FALSE to leave it off. This matches the option in the Smooth Modifier UI -- use this to prevent smoothing �leaks" when using this method. If you use this method, and portions of the patch mesh that should not be smoothed become smoothed, then try this option to see if it will correct the problem. Note that the problem it corrects is rare, and that checking this slows the automatic smoothing process.

Prototype:

void CreateBevel();

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

void Bevel(float amount, int smoothStart, int smoothEnd);

Remarks:

This method is available in release 3.0 and later only.

This method is used internally.

Prototype:

Point3 GetBevelDir(int patchVertID);

Remarks:

This method is available in release 3.0 and later only.

This method is for internal use.

buildLinkages() / computeInteriors() / ApplyConstraints() / GetEdge()

Prototype:

BOOL buildLinkages(int patch = -1);

Remarks:

This is an important method to call after putting together a PatchMesh. This method does the work to figure out how the PatchMesh is connected together, one patch to another. It determines which edges are used by which patches and so on.

Parameters:

int patch

This option is available in release 4.0 and later only.

This optional parameter allows you to only update adjacency information for a single new patch. If the plugin code is adding new patches and not removing any others then you can call this method with the new patch index and the various adjacency information in vertices, vectors, and edges will be built. If you call this method for the entire object (no parameter or patch < 0) it will destroy all adjacency information and rebuild it from scratch.

Return Value:

TRUE if the patch mesh is valid, FALSE if it is not.

Prototype:

void computeInteriors();

Remarks:

This method computes the interior bezier points for each patch in the mesh. This method should be called after any modifications have been made to alter the PatchMesh (for example changes to point positions). If there are any automatic patches this will compute the interior vectors.

Prototype:

void ApplyConstraints(BOOL selOnly = FALSE);

Remarks:

This method may be called to apply the coplanar constraints to the patch mesh. The constraints may optionally only apply to selected vertices. There is a flag that may be set for a patch vertex (PVERT_COPLANAR). For example, you can set this flag to make a vertex coplanar with its vectors. If this is done, then when this method is called, the patch code will then go through the PatchMesh and find the average plane that is used by the vertex and all the vectors associated with it. It will then constrain all the vectors to lie in this plane (by rotating them so that they lie on the plane). In this way there will be a consistent transition between the patches sharing the vertex.

Parameters:

BOOL selOnly = FALSE

If TRUE the constraints are only applied to the selected vertices; otherwise all vertices.

Prototype:

int GetEdge(int v1, int v12, int v21, int v2, int p);

Remarks:

This method is used internally.

ClonePatchParts() / SingleEdgesOnly() / GetElement() / WeldEdges()

Prototype:

void ClonePatchParts(BitArray *patches = NULL);

Remarks:

This method is available in release 4.0 and later only.

This method will copy the patches specified by the BitArray, or by the patch selection set if the BitArray patches pointer is NULL. This method is used by Editable Patch and Edit Patch to facilitate the shift-copy operations.

Parameters:

BitArray *patches

The array containing the series of selected patches.

Prototype:

BOOL SingleEdgesOnly();

Remarks:

This method is available in release 4.0 and later only.

This method examines the selected edges and will return TRUE if all selected edges are used by only one single patch. If the method returns FALSE, there are no edges selected or any of the selected edges are used by more than one single patch.

Prototype:

BitArray& GetElement(int index);

Remarks:

This method is available in release 4.0 and later only.

This method will return a BitArray that defines the group of patches defining an element that contains the patch indicated by the specified index. A PatchMesh element is any set of patches sharing common vertices.

Parameters:

int index

The patch index for which to return the element.

Prototype:

BOOL WeldEdges();

Remarks:

This method is available in release 4.0 and later only.

This method will weld any edges which are selected and have the same endpoints.

Return Value:

TRUE if any welding took place, otherwise FALSE.

Selection Weights

Prototype:

float *GetVSelectionWeights();

Remarks:

This method is available in release 4.0 and later only.

This method provides direct access to the vertex weights array and is included to match a similar function in the Mesh class.

Return Value:

A pointer to the vertex weights array.

Default Implementation:

{ return mpVertexWeights; }

Prototype:

void SupportVSelectionWeights();

Remarks:

This method is available in release 4.0 and later only.

This method allocates a vertex weights array, if none is currently allocated. This method is included to match a similar function in the Mesh class.

Conversion to Mesh

Prototype:

void ComputeMesh(Mesh& msh, DWORD convertFlags);

Remarks:

This method is available in release 4.0 and later only.

This method will produce the mesh version of the PatchMesh.

Parameters:

Mesh& msh

The mesh in which the resulting mesh should be stored.

DWORD convertFlags

The flags modifying the mesh process.

PATCH_CONVERT_KEEPSEL

This flag indicates that the subobject vertex and patch selections in the PatchMesh should be converted to subobject vertex and face selections in the mesh.

PATCH_CONVERT_USESOFTSEL

This flag indicates that soft selections should be used in the mesh to interpolate between selected and nonselected vertices. (Soft Selections cannot be based on edge or patch selection in the PatchMesh, only vertex selection.)

Render / Snap / Hit Test

Prototype:

void render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int mumMat=1);

Remarks:

Renders a patch mesh using the specified graphics window and array of materials.

Parameters:

GraphicsWindow *gw

Points to the graphics window to render to.

Material *ma

The list of materials to use to render the patch.

RECT *rp

Specifies the rectangular region to render. If the patch mesh should be rendered to the entire viewport pass NULL.

int compFlags

One or more of the following flags:

COMP_TRANSFORM

Forces recalculation of the model to screen transformation; otherwise attempt to use the cache.

COMP_IGN_RECT

Forces all polygons to be rendered; otherwise only those intersecting the box will be rendered.

COMP_LIGHTING

Forces re-lighting of all vertices (as when a light moves); otherwise only re-light moved vertices

COMP_ALL

All of the above flags.

COMP_OBJSELECTED

If this bit is set then the node being displayed by this mesh is selected. Certain display flags only activate when this bit is set.

COMP_OBJFROZEN

If this bit is set then the node being displayed by this mesh is frozen.

int numMat=1

The number of materials supported.

Prototype:

BOOL select(GraphicsWindow *gw, Material *ma, HitRegion *hr,

int abortOnHit = FALSE, int numMat=1);

Remarks:

Checks the given HitRecord hr to see if it intersects the patch mesh object.

Parameters:

GraphicsWindow *gw

Points to the graphics window to check.

Material *ma

The list of materials for the patch mesh.

HitRegion *hr

This describes the properties of a region used for the hit testing. See Class HitRegion.

int abortOnHit = FALSE

If nonzero, the hit testing is complete after any hit; otherwise all hits are checked.

int numMat=1

The number of materials supported.

Return Value:

TRUE if the item was hit; otherwise FALSE.

Prototype:

void snap(GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm);

Remarks:

Checks to see if there is a snap point near the given mouse point.

Parameters:

GraphicsWindow *gw

The graphics window in which to check.

SnapInfo *snap

This structure describes the snap settings used, and the results of the snap test. See Structure SnapInfo.

IPoint2 *p

The mouse point to check.

Matrix3 &tm

The object transformation matrix. This is the transformation to place the object into the world coordinate system.

Prototype:

BOOL SubObjectHitTest(GraphicsWindow *gw, Material *ma, HitRegion *hr,

DWORD flags, SubPatchHitList& hitList, int numMat=1);

Remarks:

This method may be called to perform sub-object hit testing of the patch mesh.

Parameters:

GraphicsWindow *gw

The graphics window associated with the viewport the patch mesh is being hit tested in.

Material *ma

The list of materials for the patch mesh.

HitRegion *hr

This describes the properties of a region used for the hit testing. See Class HitRegion.

DWORD flags

Flags for sub object hit testing. One or more of the following values:

SUBHIT_PATCH_SELONLY

Selected only.

SUBHIT_PATCH_UNSELONLY

Unselected only.

SUBHIT_PATCH_ABORTONHIT

Abort hit testing on the first hit found.

SUBHIT_PATCH_SELSOLID

This treats selected items as solid and unselected items as not solid. Treating an item as solid means the patch will be hit if the mouse is anywhere inside the patch region and not just over a visible edge.

SUBHIT_PATCH_VERTS

Hit test vertices.

SUBHIT_PATCH_VECS

Hit test vectors.

SUBHIT_PATCH_PATCHES

Hit test patches.

SUBHIT_PATCH_EDGES

Hit test edges.

SubPatchHitList& hitList

See Class SubPatchHitList.

int numMat=1

The number of materials for the mesh.

Return Value:

TRUE if the item was hit; otherwise FALSE.

Bounding Box Methods

Prototype:

void buildBoundingBox();

Remarks:

Computes the bounding box of the patch mesh. The bounding box is stored with the patch mesh object, use getBoundingBox() to retrieve it.

Prototype:

Box3 getBoundingBox(Matrix3 *tm=NULL);

Remarks:

Retreives the bounding box of the patch mesh object.

Parameters:

Matrix3 *tm=NULL

The optional TM allows the box to be calculated in any space.

Prototype:

void renderGizmo(GraphicsWindow *gw);

Remarks:

This method is available in release 4.0 and later only.

This method will render a �gizmo� version of the PatchMesh and is used primarily by Editable Patch and Edit Patch to facilitate the Show End Result feature.

Parameters:

GraphicsWindow *gw

The graphics window associated with the viewport the patch mesh gizmo should be shown in.

Data Flow Evaluation

Prototype:

void InvalidateGeomCache();

Remarks:

This method should be called when the PatchMesh changes. It invalidates the caches of the patch mesh.

Prototype:

void FreeAll();

Remarks:

Frees everything from the patch mesh.

Prototype:

void ShallowCopy(PatchMesh *amesh, ULONG_PTR channels);

Remarks:

This method is used internally in data flow evaluation.

Prototype:

void DeepCopy(PatchMesh *amesh, ULONG_PTR channels);

Remarks:

This method is used internally in data flow evaluation.

Prototype:

void NewAndCopyChannels(ULONG_PTR channels);

Remarks:

This method is used internally in data flow evaluation.

Prototype:

void FreeChannels(ULONG_PTR channels, int zeroOthers=1);

Remarks:

This method is used internally in data flow evaluation.

Display Flags Access

Prototype:

void SetDispFlag(DWORD f);

Remarks:

Sets the state of the specified display flags.

Parameters:

DWORD f

The flags to set. See List of Patch Display Flags.

Prototype:

DWORD GetDispFlag(DWORD f);

Remarks:

Returns the state of the specified display flags.

Parameters:

DWORD f

The flags to get. See List of Patch Display Flags.

Prototype:

void ClearDispFlag(DWORD f);

Remarks:

Clears the specified display flags.

Parameters:

DWORD f

The flags to clear. See List of Patch Display Flags.

Selection Access

Prototype:

BitArray& VertSel();

Remarks:

Returns the bits representing the vertex selection status. See the Data Members above. See Class BitArray.

Prototype:

BitArray& PatchSel();

Remarks:

Returns the bits representing the patch selection status. See the Data Members above. See Class BitArray.

Prototype:

BitArray& EdgeSel();

Remarks:

Returns the bits representing the edge selection status. See the Data Members above. See Class BitArray.

Prototype:

BitArray VertexTempSel();

Remarks:

Constructs a vertex selection list based on the current selection level. For example if the selection level is at object level all the bits are set. If the selection level is at vertex level only the selected vertex bits are set. See Class BitArray.

Tri / Quad Patch Creation

Prototype:

BOOL MakeQuadPatch(int index, int va, int vab, int vba,

int vb, int vbc, int vcb, int vc, int vcd, int vdc,

int vd, int vda, int vad, int i1, int i2, int i3,

int i4, DWORD sm);

Remarks:

Create a quadrilateral patch given a patch index and a list of all the vertices, vectors, interiors, and a smoothing group.

Parameters:

int index - The index of the patch to create (0>= index < numPatches).

int va - The first vertex.

int vab - Vector ab.

int vba - Vector ba.

int vb - The second vertex.

int vbc - Vector bc.

int vcb - Vector cb.

int vc - The third vertex.

int vcd - Vector cd.

int vdc - Vector dc.

int vd - The fourth vertex.

int vda - Vector da.

int vad - Vector ad.

int i1 - Interior 1.

int i2 - Interior 2.

int i3 - Interior 3.

int i4 - Interior 4.

DWORD sm - The smoothing group.

Return Value:

TRUE if the patch was created; otherwise FALSE.

Prototype:

BOOL MakeTriPatch(int index, int va, int vab, int vba, nt vb,

int vbc, int vcb, int vc, int vca, int vac, nt i1, int i2,

int i3, DWORD sm);

Remarks:

Create a triangular patch given a patch index and a list of all the vertices, vectors, interiors, and a smoothing group.

Parameters:

int index - The index of the patch to create (0>= index < numPatches).

int va - The first vertex.

int vab - Vector ab.

int vba - Vector ba.

int vb - The second vertex.

int vbc - Vector bc.

int vcb - Vector cb.

int vc - The third vertex.

int vca - Vector ca.

int vac - Vector ac.

int i1 - Interior 1.

int i2 - Interior 2.

int i3 - Interior 3.

DWORD sm - The smoothing group.

Returns:

TRUE if the patch was created; otherwise FALSE.

Get/Set Mesh Steps and Adaptive Switch/TessApprox

Prototype:

void SetMeshSteps(int steps);

Remarks:

Sets the number of steps along each edge that determines how fine the mesh is generated off the patch.

Parameters:

int steps

The number of steps to set.

Prototype:

int GetMeshSteps();

Remarks:

Returns the number of mesh steps.

Prototype:

void SetMeshStepsRender(int steps);

Remarks:

This method is available in release 3.0 and later only.

Sets the Surface Render Steps setting.

Parameters:

int steps

The value to set.

Prototype:

int GetMeshStepsRender();

Remarks:

This method is available in release 3.0 and later only.

Returns the Surface Render Steps setting.

Prototype:

void SetShowInterior(BOOL si);

Remarks:

This method is available in release 3.0 and later only.

Sets the 'Show Interior Edges' value.

Parameters:

BOOL si

TRUE for on; FALSE for off.

Prototype:

BOOL GetShowInterior();

Remarks:

This method is available in release 3.0 and later only.

Returns the 'Show Interior Edge' setting; TRUE if on; FALSE if off.

Prototype:

void SetAdaptive(BOOL sw);

Remarks:

This is currently not used. Reserved for future use.

Prototype:

BOOL GetAdaptive();

Remarks:

This is currently not used. Reserved for future use.

Prototype:

void SetViewTess(TessApprox tess);

Remarks:

This method is available in release 2.0 and later only.

Sets the tesselation approximation object used for viewport rendering.

Parameters:

TessApprox tess

The tesselation approximation object to be used for viewport rendering.

Prototype:

TessApprox GetViewTess();

Remarks:

This method is available in release 2.0 and later only.

Returns the tesselation approximation object used for rendering in the viewports.

Prototype:

void SetProdTess(TessApprox tess);

Remarks:

This method is available in release 2.0 and later only.

Sets the tesselation approximation object used for production rendering.

Parameters:

TessApprox tess

The tesselation approximation object to be used for production rendering.

Prototype:

TessApprox GetProdTess();

Remarks:

This method is available in release 2.0 and later only.

Returns the tesselation approximation object used for production rendering.

Prototype:

void SetDispTess(TessApprox tess);

Remarks:

This method is available in release 3.0 and later only.

Sets the tesselation approximation object used for display in the viewports.

Parameters:

TessApprox tess

The tesselation approximation object to be used for the viewports.

Prototype:

TessApprox GetDispTess();

Remarks:

This method is available in release 3.0 and later only.

Returns the tesselation approximation object used for display in the viewports.

Prototype:

BOOL GetViewTessNormals();

Remarks:

This method is available in release 3.0 and later only.

Returns TRUE if normals are used from the viewport tesselator; otherwise FALSE.

Prototype:

void SetViewTessNormals(BOOL use);

Remarks:

This method is available in release 3.0 and later only.

Sets if normals are used from the viewport tesselator.

Parameters:

BOOL use

TRUE to use normals; FALSE to not use them.

Prototype:

BOOL GetProdTessNormals();

Remarks:

This method is available in release 3.0 and later only.

Returns TRUE if normals are used from the production renderer tesselator; otherwise FALSE.

Prototype:

void SetProdTessNormals(BOOL use);

Remarks:

This method is available in release 3.0 and later only.

Sets if normals are used from the production renderer tesselator.

Prototype:

BOOL GetViewTessWeld();

Remarks:

This method is available in release 3.0 and later only.

Returns TRUE if the viewport mesh is welded after tesselation; otherwise FALSE.

Prototype:

void SetViewTessWeld(BOOL weld);

Remarks:

This method is available in release 3.0 and later only.

Sets if the viewport mesh is welded after tesselation; otherwise FALSE.

Parameters:

BOOL weld

TRUE to weld; FALSE to not weld.

Prototype:

BOOL GetProdTessWeld();

Remarks:

This method is available in release 3.0 and later only.

Returns TRUE if the production renderer mesh is welded after tesselation; otherwise FALSE.

Prototype:

void SetProdTessWeld(BOOL weld);

Remarks:

This method is available in release 3.0 and later only.

Sets if the production renderer mesh is welded after tesselation; otherwise FALSE.

Parameters:

BOOL weld

TRUE to weld; FALSE to not weld.

Dump()

Prototype:

void Dump();

Remarks:

This method may be called to dump the patch mesh structure via DebugPrint(). See Debugging.

Prototype:

int IntersectRay(Ray& ray, float& at, Point3& norm);

Remarks:

This method is available in release 3.0 and later only.

Calculates the intersection of the specified ray with this patch mesh object. This method calls the method of the same name on the Mesh cache.

Parameters:

Ray& ray

Specifies the origin and direction of the ray to intersect with the patch mesh. See Class Ray.

float& at

The computed point of intersection on the surface of the patch mesh.

Point3& norm

The face normal at the point of intersection (at).

Return Value:

Nonzero if the ray intersected the mesh object; otherwise 0. Note that this method ignores backfaces when computing the result.

Operators:

Prototype:

PatchMesh& operator=(PatchMesh& fromPatchMesh);

Remarks:

Assignment operator from another PatchMesh.

Prototype:

PatchMesh& operator=(Mesh& fromMesh);

Remarks:

Assignment operator. This operator will do the conversion from a Mesh to a PatchMesh. Note that this can get very slow if there are a lot of faces in the mesh. When the system does the conversion is must do a fair amount of work with its interior connection lists. It builds a data base of what is connected to what and makes sure that the PatchMesh doesn't have any places where an edge is used by more than two patches. Also, for every face in the mesh it generates a triangular patch. Therefore use this method with some caution as it can create some very complex PatchMesh objects.