#include <maya/MPxNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnGenericAttribute.h>
#include <maya/MFnMesh.h>
#include <maya/MFloatPointArray.h>
#include <maya/MFnPlugin.h>
#include <algorithm>
#define USE_TOPOLOGY_TRACKING_OPTIMIZATION 1
class topologyTrackingNode :
public MPxNode
{
public:
static void* creator();
#if USE_TOPOLOGY_TRACKING_OPTIMIZATION
#endif // USE_TOPOLOGY_TRACKING_OPTIMIZATION
private:
};
const MString topologyTrackingNode::name{
"topologyTrackingNode"};
const MTypeId topologyTrackingNode::id{0x00081150};
MObject topologyTrackingNode::divisionCount;
MObject topologyTrackingNode::offset;
MObject topologyTrackingNode::inMesh;
MObject topologyTrackingNode::outMeshLeft;
MObject topologyTrackingNode::outMeshRight;
void* topologyTrackingNode::creator()
{
return new topologyTrackingNode();
}
MStatus topologyTrackingNode::initialize()
{
inMesh = gAttrFn.
create(
"inMesh",
"im", &status);
outMeshLeft = gAttrFn.
create(
"outMeshLeft",
"oml", &status);
outMeshRight = gAttrFn.
create(
"outMeshRight",
"omr", &status);
#if USE_TOPOLOGY_TRACKING_OPTIMIZATION
#else
#endif // USE_TOPOLOGY_TRACKING_OPTIMIZATION
return status;
}
{
auto process = [this, &block, &plug](float offsetFactor) {
MPlug inPlug(thisNode, inMesh);
offsetVector *= offsetFactor;
for (
int i = 0, outPointsCount = outMesh.
numVertices(); i < outPointsCount; ++i)
{
point += offsetVector;
}
MPlug divisionCountPlug(thisNode, divisionCount);
const int divisionCount = divisionCountDataHandle.
asInt();
if (divisionCount > 0)
{
for (int i = 0; i < numPolygons; ++i)
{
facesToSubdivide[i] = i;
}
}
outputDataHandle.
set(outMeshObject);
};
if (plug == outMeshLeft)
{
process(1.5f);
}
else if (plug == outMeshRight)
{
process(-1.5f);
}
return ParentClass::compute(plug, block);
}
#if USE_TOPOLOGY_TRACKING_OPTIMIZATION
bool topologyTrackingNode::isTrackingTopology() const
{
return true;
}
#endif // USE_TOPOLOGY_TRACKING_OPTIMIZATION
{
MFnPlugin pluginFn(obj, PLUGIN_COMPANY,
"1.0",
"Any");
MStatus status = pluginFn.registerNode(
topologyTrackingNode::name,
topologyTrackingNode::id,
topologyTrackingNode::creator,
topologyTrackingNode::initialize
);
return status;
}
{
MStatus status = pluginFn.deregisterNode(topologyTrackingNode::id);
return status;
}