Class PatchObject

3DS Max Plug-In SDK

Class PatchObject

See Also: Class GeomObject, Class IPatchOps, Class IPatchSelect, Class IPatchSelectData, Class ISubMtlAPI, Class AttachMatDlgUser, Class PatchMesh, Class Patch, Class Mesh, Class TessApprox, Working with Patches.

class PatchObject : public GeomObject, IPatchOps, IPatchSelect, IPatchSelectData, ISubMtlAPI, AttachMatDlgUser

Description:

This class is the base class for the creation of Patch objects. This class stores an instance of a PatchMesh that holds all the Patches that make up this patch object. This class also maintains a Mesh cache. All methods of this class are implemented by the system.

Data Members:

public:

PatchMesh patch;

The patch mesh for this patch object.

Mesh mesh;

The Mesh cache.

BOOL meshValid;

Indicates if the mesh cache is valid.

BOOL showMesh;

Indicates if the mesh is shown in the viewports

GenericNamedSelSetList vselSet;

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

Vertex level named selection sets.

GenericNamedSelSetList eselSet;

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

Edge level named selection sets.

GenericNamedSelSetList pselSet;

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

Patch level named selection sets.

int patchSelSubType;

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

The sub-object selection level, defined by;

PO_PATCH

Patch sub-object level. When SetSubobjectLevel(PO_PATCH) is called, both the PatchMesh selection

level and patchSelSubType are set to PO_PATCH.

PO_ELEMENT

Element sub-object level. When SetSubobjectLevel(PO_ELEMENT) is called, the PatchMesh selection level is set to PO_PATCH and patchSelSubType is set to PO_ELEMENT.

Methods:

Prototype:

PatchObject();

Remarks:

Constructor.

Prototype:

~PatchObject();

Remarks:

Destructor.

Prototype:

void UpdatePatchMesh(TimeValue t);

Remarks:

This method is available in release 2.0 and later only.

This should be implemented by classes derived from PatchObject whose patches change over time.

Parameters:

TimeValue t

The time to update the patch mesh.

Default Implementation:

{}

Prototype:

void PrepareMesh(TimeValue t);

Remarks:

This method checks to see if the mesh cache is up to date, and if not, it generates it.

Parameters:

TimeValue t

This parameter is available in release 2.0 and later only.

The mesh cache should be generated to reflect this time.

Prototype:

BOOL ShowLattice();

Remarks:

Returns TRUE if the patch lattice is displayed; otherwise FALSE.

Prototype:

BOOL ShowVerts();

Remarks:

Returns TRUE if the patch vertices are shown; otherwise FALSE.

Prototype:

void SetShowLattice(BOOL sw);

Remarks:

Sets the state of the lattice display switch.

Parameters:

BOOL sw

TRUE to turn on the lattice display; FALSE to turn it off.

Prototype:

void SetShowVerts(BOOL sw);

Remarks:

Sets the state of the vertex display switch

Parameters:

BOOL sw

TRUE to turn on the vertex display; FALSE to turn it off.

Prototype:

void SetMeshSteps(int steps);

Remarks:

Sets the number of mesh steps (viewport).

Parameters:

int steps

The number of steps to set.

Prototype:

int GetMeshSteps();

Remarks:

Returns the number of mesh steps (viewport).

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:

Sets the state of the adaptive switch.

Parameters:

BOOL sw

TRUE to turn on; FALSE to turn off.

Prototype:

BOOL GetAdaptive();

Remarks:

Returns the state of the adaptive switch. TRUE is on; FALSE is off.

Prototype:

void SetViewTess(TessApprox tess);

Remarks:

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:

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

Prototype:

void SetProdTess(TessApprox tess);

Remarks:

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:

Returns the tesselation approximation object used for production rendering.

Prototype:

void SetDispTess(TessApprox tess);

Remarks:

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:

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

Prototype:

BOOL GetViewTessNormals();

Remarks:

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

Prototype:

void SetViewTessNormals(BOOL use);

Remarks:

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:

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

Prototype:

void SetProdTessNormals(BOOL use);

Remarks:

Sets if normals are used from the production renderer tesselator.

Parameters:

BOOL use

TRUE to use normals; FALSE to not use them.

Prototype:

BOOL GetViewTessWeld();

Remarks:

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

Prototype:

void SetViewTessWeld(BOOL weld);

Remarks:

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:

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

Prototype:

void SetProdTessWeld(BOOL weld);

Remarks:

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

Parameters:

BOOL weld

TRUE to weld; FALSE to not weld.

Prototype:

void InvalidateMesh();

Remarks:

Invalidates the mesh cache.

Prototype:

void SetFlag(DWORD fl, BOOL val=TRUE);

Remarks:

This method is available in release 4.0 and later only.

This method sets or clears the status of the Show End Result flag.

Parameters:

DWORD fl

The flag you wish to set or clear. Currently the only flag defined is the Show End Result flag EP_DISP_RESULT.

BOOL val

Specifies if the given flag should be set or cleared.

Prototype:

void ClearFlag (DWORD fl);

Remarks:

This method is available in release 4.0 and later only.

This method clears the status of the Show End Result flag.

Parameters:

DWORD fl

The flag you wish to set or clear. Currently the only flag defined is the Show End Result flag EP_DISP_RESULT.

Prototype:

bool GetFlag(DWORD fl);

Remarks:

This method is available in release 4.0 and later only.

This methods allows you to obtain the status of the Show End Result flag.

Parameters:

DWORD fl

The flag you wish to set or clear. Currently the only flag defined is the Show End Result flag EP_DISP_RESULT.

Prototype:

void ShowEndResultChanged(BOOL showEndResult);

Remarks:

This method is available in release 4.0 and later only.

This method is called by the system then the status of the Show End Result function changes (ie. the Show End Results button has been toggled on or off). Note that setting the state of the Show End Result is done through the Interface::SetShowEndResult() method.

Parameters:

BOOL showEndResult

This flag specifies the Show End Result status, which is TRUE if on; FALSE if off.

Prototype:

int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, ModContext *mc);

Remarks:

This method is available in release 4.0 and later only.

This method is used to display the gizmo version of the patch mesh.

Parameters:

TimeValue t

The time to display the object.

INode* inode

The node to display.

ViewExp* vpt

An interface pointer that may be used to call methods associated with the viewports.

int flags

The display flags. See the List of Display Flags for more information.

ModContext* mc

A pointer to the modifiers ModContext.

Prototype:

void GetWorldBoundBox (TimeValue t, INode * inode, ViewExp* vp, Box3& box, ModContext *mc);

Remarks:

This method is available in release 4.0 and later only.

This method returns the world space bounding box for the gizmo version of the patch mesh.

Parameters:

TimeValue t

The time to compute the bounding box.

INode* inode

The node to calculate the bounding box for.

ViewExp* vpt

An interface pointer that may be used to call methods associated with the viewports.

Box3& box

The bounding box which was computed.

ModContext* mc

A pointer to the modifiers ModContext.

Prototype:

int GetSubobjectType();

Remarks:

This method is available in release 4.0 and later only.

This method goes hand-in-hand with GetSubobjectLevel(), except that this method returns the type of geometry that is actually being acted upon.

Return Value:

The sub-object type, either PO_PATCH or PO_ELEMENT.

Prototype:

Color GetVertColor(int mp=0, bool *differs=NULL);

Remarks:

This method is available in release 4.0 and later only.

This method returns the common color for all selected vertices. If no vertices are selected then white (1,1,1) will be returned, however, if multiple vertices with different colors are selected, then black (0,0,0) will be returned.

Parameters:

int mp=0

The map channel.

bool *differs=NULL

This parameter is returned to indicate if there were any differences.

 

Prototype:

void SetVertColor(Color clr, int mp=0);

Remarks:

This method is available in release 4.0 and later only.

This method will set all selected vertices to the specified color.

Parameters:

Color clr

The color you wish to apply to all the selected vertices.

int mp=0

The map channel.

Prototype:

Color GetPatchColor(int mp=0, bool *differs=NULL);

Remarks:

This method is available in release 4.0 and later only.

This method returns the common color for all selected patches. If no patches are selected then white (1,1,1) will be returned, however, if different vertex colors are present in the selected patches, then black (0,0,0) will be returned.

Parameters:

int mp=0

The map channel.

bool *differs=NULL

This parameter is returned to indicate if there were any differences.

 

Prototype:

void SetPatchColor(Color clr, int mp=0);

Remarks:

This method is available in release 4.0 and later only.

This method will set all selected patches to the specified color.

Parameters:

Color clr

The color you wish to apply to all the selected patches.

int mp=0

The map channel.

Prototype:

void SelectVertByColor(VertColor clr, int deltaR, int deltaG, int deltaB, BOOL add, BOOL sub, int mp=0);

Remarks:

This method is available in release 4.0 and later only.

This method will select all vertices which fall into a specified color range.

Parameters:

VertColor clr

The starting color of the vertices you wish to select by color.

int deltaR

The difference range for the red color component.

int deltaG

The difference range for the green color component.

int deltaB

The difference range for the blue color component.

BOOL add

This flag adds vertices to the selection that fall into the color range.

BOOL sub

This flag subtracts vertices from the selection that fall into the color range.

int mp=0

The map channel.

Prototype:

void SelectOpenEdges();

Remarks:

This method is available in release 4.0 and later only.

This method examines the patch mesh and selects any edges used by only one single patch.

Prototype:

void DoBevel(TimeValue t);

Remarks:

When called with the Animate state active and on a nonzero TimeValue, this method will prepare the controllers for the geometry that is being created. The program can then fill in the animated vertex values later.

Parameters:

TimeValue t

This parameter is available in release 4.0 and later only.

The time at which to prepare and execute the bevel operation.

Prototype:

void DoExtrude(TimeValue t);

Remarks:

When called with the Animate state active and on a nonzero TimeValue, this method will prepare the controllers for the geometry that is being created. The program can then fill in the animated vertex values later.

Parameters:

TimeValue t

This parameter is available in release 4.0 and later only.

The time at which to prepare and execute the extrude operation.

Prototype:

void DoCreateShape();

Remarks:

This method is available in release 4.0 and later only.

This method will create a bezier spline shape from the selected edges of the patch mesh. Each edge will become a separate spline in the output shape. The user will be prompted to enter a name for the new editable spline object that will be created.

Prototype:

void DoEdgeWeld();

Remarks:

This method is available in release 4.0 and later only.

This method will perform the edge weld function on the patch object. Note that this does not take into account any threshold but welds edges only if they use the same two vertices as endpoints. When two or more edges are welded, the locations of the edge vectors are averaged to create the new edge.

Prototype:

void DoFlipNormals(int patchIndex = -1);

Remarks:

This method is available in release 4.0 and later only.

This method flips the normals of a specified patch or all selected patches. This method will save undo information and displays a prompt if patchIndex < 0 while there are no patches selected.

Parameters:

int patchIndex

The index of the patch for which to flip the normal. If this parameter is < 0, the normals of all selected patches will be flipped (if there are any selected).

Any vertices set to PVERT_COPLANAR that lie on the boundary between flipped and unflipped patches will have their type set to PVERT_CORNER. This is because attempting to compute normals of neighboring patches with opposite normals in order to get a proper plane often results in invalid normals being generated. Making the vertex a corner type prevents the problem. Any vertices not on the boundary between flipped and unflipped patches are left as is.

Prototype:

void DoUnifyNormals();

Remarks:

This method is available in release 4.0 and later only.

This method examines the selected patch set and attempts to make them all face the same direction. Preferred direction is arbitrary; the first selected patch encountered in each contiguous group determines the direction all patches in that group will attain.

Any vertices set to PVERT_COPLANAR that lie on the boundary between flipped and unflipped patches will have their type set to PVERT_CORNER. This is because attempting to compute normals of neighboring patches with opposite normals in order to get a proper plane often results in invalid normals being generated. Making the vertex a corner type prevents the problem. Any vertices not on the boundary between flipped and unflipped patches are left as is.

Prototype:

void DoBreak(BOOL interactive = TRUE);

Remarks:

This method is available in release 4.0 and later only.

In vertex mode, this method examines selected vertices, and if any of the vertices that are part of the selection set are used by more than one patch, those vertices (and any attached vectors) are duplicated into separate geometry for each patch using it.

In edge mode, this method examines the selected edges and any vectors on the selected edges that are used by more than one patch are duplicated into separate geometry for each patch using them. Any vertices used by more than one selected edge are duplicated as well for patches on opposite sides of the edge.

Note: If the vertices and vectors involved have controllers attached, they are removed by this operation.

Parameters:

BOOL interactive

If this parameter is set to TRUE it will cause the method to display the appropriate prompts, create an undo object, and notifies the dependents.

Prototype:

void DoDeleteSelected(BOOL interactive = TRUE);

Remarks:

This method is available in release 3.0 and later only.

This method will delete the selected patches, exactly like the DeleteMesh modifier does.

Parameters:

BOOL interactive

This parameter is available in release 4.0 and later only.

If this parameter is set to TRUE it will cause the method to display the appropriate prompts, create an undo object, and notifies the dependents.

Prototype:

void ChangeMappingTypeLinear(BOOL linear);

Remarks:

This method is available in release 4.0 and later only.

This method will change the mapping type of the selected patches to linear or curved.

Parameters:

BOOL linear

If TRUE the mapping type will be changed to linear. FALSE will change the mapping type to curved.

Prototype:

virtual void GetUIParam(patchUIParam uiCode, int &ret);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to get the edit patch parameters from the command panel. Currently not in use.

Parameters:

patchUIParam uiCode

This enum is currently empty.

int &ret

The returned value.

Default Implementation:

{ }

Prototype:

virtual void SetUIParam(patchUIParam uiCode, int val);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the edit patch parameters from the command panel. Currently not in use.

Parameters:

patchUIParam uiCode

This enum is currently empty.

int val

The value to set.

Default Implementation:

{ }

Prototype:

virtual void GetUIParam(patchUIParam uiCode, float &ret);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to get the edit patch parameters from the command panel. Currently not in use.

Parameters:

patchUIParam uiCode

This enum is currently empty.

float &ret

The returned value.

Default Implementation:

{ }

Prototype:

virtual void SetUIParam(patchUIParam uiCode, float val);

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the edit patch parameters from the command panel. Currently not in use.

Parameters:

patchUIParam uiCode

This enum is currently empty.

float val

The value to set.

Default Implementation:

{ }

Prototype:

bool Editing();

Remarks:

This method is available in release 4.0 and later only.

This method will return TRUE if the SplineShape object or Edit Spline modifier is active in the command panel.

Default Implementation:

{ return (ip && (editObj==this)) ? TRUE : FALSE; }