#pragma once //- // =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== //+ // // CLASS: MPxPolyTrg // // **************************************************************************** #include #include OPENMAYA_MAJOR_NAMESPACE_OPEN // **************************************************************************** // CLASS DECLARATION (MPxPolyTrg) //! \ingroup OpenMaya MPx //! \brief User defined poly triangulation support. /*! 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: 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{.mel} 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. */ class OPENMAYA_EXPORT MPxPolyTrg : public MPxNode { public: MPxPolyTrg(); ~MPxPolyTrg() override; void postConstructor() override; MStatus compute( const MPlug& plug, MDataBlock& dataBlock ) override; bool isAbstractClass() const override; // Type for the signature of the triangulate function //! \brief Pointer to a function which triangulates a poly face. /* \param[in] vert Array of the face's vertex positions. \param[in] norm Array of the face's vertex normals. \param[in] loopSizes Array of loop sizes. \param[in] nbLoop Number of loops in the face. \param[in] nbTrg Expected number of triangles to be generated. \param[out] trg Array of face-relative vertex indices describing the generated triangles. */ typedef void (*polyTrgFnct)( const float *vert, const float *norm, const int *loopSizes, const int nbLoop, const int nbTrg, unsigned short *trg ); MStatus registerTrgFunction( const char *name, polyTrgFnct f ); MStatus unregisterTrgFunction( const char *name ); private: }; OPENMAYA_NAMESPACE_CLOSE