#include <string.h>
#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MFnGenericAttribute.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnGeometryData.h>
#include <maya/MFnMesh.h>
#include <maya/MFnNurbsSurface.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MFnLattice.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MMatrix.h>
#include <maya/MVector.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MItGeometry.h>
#include <maya/MStringArray.h>
#include <maya/MFnSingleIndexedComponent.h>
#include <maya/MFnDoubleIndexedComponent.h>
#include <maya/MFnTripleIndexedComponent.h>
#define MCheckStatus(status,message) \
if( MStatus::kSuccess != status ) { \
cerr << message << "\n"; \
return status; \
}
class customComponentTag :
public MPxNode
{
public:
customComponentTag();
~customComponentTag() override;
static void* creator();
public:
};
MTypeId customComponentTag::id( 0x00081161 );
MObject customComponentTag::inputGeometry;
MObject customComponentTag::outputGeometry;
customComponentTag::customComponentTag() {}
customComponentTag::~customComponentTag() {}
MPlug customComponentTag::passThroughToOne(
const MPlug& iPlug)
const
{
if (iPlug == inputGeometry)
{
return MPlug(thisMObject(), outputGeometry);
}
else if (iPlug == outputGeometry)
{
return MPlug(thisMObject(), inputGeometry);
}
}
{
MCheckStatus( status, "ERROR getting state" );
MCheckStatus(status,"ERROR getting inputGeometry");
MCheckStatus(status,"ERROR getting outputGeometry");
outputDataHandle.
copy(inputDataHandle);
return status;
}
if( iPlug == outputGeometry )
{
MCheckStatus(status,"ERROR getting inputGeometry");
MCheckStatus(status,"ERROR getting outputGeometry");
cerr << "ERROR getting dataBlock" << endl;
else {
outputDataHandle.
copy(inputDataHandle);
geomDataFn.addComponentTag(leftTag);
geomDataFn.addComponentTag(rightTag);
MCheckStatus( status, "ERROR getting mesh" );
const int polyCount = meshFn.numPolygons( &status );
for (int polygonId = 0; polygonId < polyCount; ++polygonId) {
bool allLeft = true;
bool allRight = true;
status = meshFn.getPolygonVertices(polygonId, vertexList);
if (status) {
const unsigned int numVerts = vertexList.
length();
for (unsigned int i = 0; i < numVerts && allLeft; ++i) {
meshFn.getPoint(vertexList[i], pos);
allLeft = false;
}
else if (pos.
x > 0.0) {
allRight = false;
}
}
if (allLeft)
else if (allRight)
}
}
geomDataFn.setComponentTagContents(leftTag, leftFacesComp);
geomDataFn.setComponentTagContents(rightTag, rightFacesComp);
}
MCheckStatus( status, "ERROR getting nurbsSurface" );
int nu = geomFn.numCVsInU();
int nv = geomFn.numCVsInV();
for (int u = 0; u < nu; ++u) {
for (int v = 0; v < nv; ++v) {
geomFn.getCV(u, v, pos);
}
}
}
}
geomDataFn.setComponentTagContents(leftTag, leftCvsComp);
geomDataFn.setComponentTagContents(rightTag, rightCvsComp);
}
MCheckStatus( status, "ERROR getting nurbsCurve" );
int nu = geomFn.numCVs();
for (int u = 0; u < nu; ++u) {
geomFn.getCV (u, pos);
}
}
}
geomDataFn.setComponentTagContents(leftTag, leftCvsComp);
geomDataFn.setComponentTagContents(rightTag, rightCvsComp);
}
MCheckStatus( status, "ERROR getting lattice" );
unsigned int ns, nt, nu;
geomFn.getDivisions(ns, nt, nu);
for (unsigned int s = 0; s < ns; ++s) {
for (unsigned int t = 0; t < nt; ++t) {
for (unsigned int u = 0; u < nu; ++u) {
MPoint &pos = geomFn.point (s, t, u);
}
}
}
}
}
geomDataFn.setComponentTagContents(leftTag, leftPtsComp);
geomDataFn.setComponentTagContents(rightTag, rightPtsComp);
}
}
}
} else {
}
}
void* customComponentTag::creator()
{
return new customComponentTag();
}
MStatus customComponentTag::initialize()
{
inputGeometry = geoAttr.
create(
"inputGeometry",
"ig");
stat = addAttribute( inputGeometry );
if (!stat) {
return stat;
}
outputGeometry = geoAttr.
create(
"outputGeometry",
"og");
stat = addAttribute( outputGeometry );
if (!stat) {
return stat;
}
stat = attributeAffects( inputGeometry, outputGeometry );
if (!stat) {
stat.
perror(
"attributeAffects");
return stat;
}
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode( "customComponentTag", customComponentTag::id, customComponentTag::creator,
customComponentTag::initialize );
if (!status) {
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode( customComponentTag::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}