#include
<MPxPolyTrg.h>
MPxPolyTrg is the the parent class for nodes which define a custom face triangulation for meshes. In order to override default maya triangulation, the user has to do the following things:
Note: The number of vertices can be calculated by adding all the loop sizes.
The output of this function is an array of triangle description:
nbTrg = 2 trg: 0 1 2 2 3 0
Tip: Refer to the example plugin: polyTrgNode for more details on how to implement it.
Once the node is defined, the user has to inform the mesh about it. For each mesh the user wants to override the default triangulation, he has to set the usertTrg attribute on the mesh to the name under which the function has been registered.
Example: /code setAttr mesh.userTrg -type "string" "triangulate"; /endcode
Once that attribute is set, the default maya triangulation is turned off and the one provided by the user is used to draw the mesh.
Public Types |
|
typedef void(* | polyTrgFnct )(const float *vert, const float *norm, const int *loopSizes, const int nbLoop, const int nbTrg, unsigned short *trg) |
Pointer to a function which triangulates a
poly face. |
|
Public Member Functions |
|
MPxPolyTrg () | |
virtual | ~MPxPolyTrg () |
virtual void | postConstructor () |
virtual MStatus | compute (const MPlug &plug, MDataBlock &dataBlock) |
virtual bool | isAbstractClass () const |
MStatus | registerTrgFunction (char *name, polyTrgFnct f) |
MStatus | unregisterTrgFunction (char *name) |
MPxPolyTrg::MPxPolyTrg | ( | ) |
Constructor.
The constructor should never call any methods from MPxPolyTrg or make any calls that require the existence of the MObject associated with the user defined node. The postConstructor method should be used to do any initialization of this kind.
MPxPolyTrg::~MPxPolyTrg | ( | ) | [virtual] |
Destructor.
void MPxPolyTrg::postConstructor | ( | ) | [virtual] |
Post constructor.
Internally maya creates two objects when a user defined node is created, the internal MObject and the user derived object. The association between the these two objects is not made until after the MPxPolyTrg constructor is called. This implies that no MPxPolyTrg member function can be called from the MPxPolyTrg constructor. The postConstructor will get called immediately after the constructor when it is safe to call any MPxPolyTrg member function.
Reimplemented from MPxNode.
MStatus MPxPolyTrg::compute | ( | const MPlug & | plug, | |
MDataBlock & | block | |||
) | [virtual] |
This method should be overridden in user defined nodes. However, fror this particaular node we don't need to to do anything in the compute functione. Therefore, all we do is return MS:kSuccess in the derive class.
[in] | plug | plug representing the attribute that needs to be recomputed |
[in] | block | data block containing storage for the node's attributes |
Reimplemented from MPxNode.
bool MPxPolyTrg::isAbstractClass | ( | ) | const [virtual] |
Each new node has to implement that fuction. It returns false since this is not an abstract class.
Reimplemented from MPxNode.
MStatus MPxPolyTrg::registerTrgFunction | ( | char * | functName, | |
polyTrgFnct | funct | |||
) |
Register a triangulation function with maya. The name provided as a first argument is the name under which the function is registered. This name has to be used when setting 'userTrg' attribute on a mesh.
[in] | functName | Function name under which the function is register with maya. |
[in] | funct | Pointer to the static function which implement a face triangulation. |
MStatus MPxPolyTrg::unregisterTrgFunction | ( | char * | functName | ) |
[in] | functName | Function name under which the function is register with maya. |
Autodesk® Maya® 2011 © 1997-2010 Autodesk, Inc. All rights reserved. | Generated with 1.5.6 |