#include <math.h>
#include <maya/MGlobal.h>
#include <maya/MPxNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnMatrixAttribute.h>
#include <maya/MFloatVector.h>
#include <maya/MFloatPoint.h>
#include <maya/MFloatMatrix.h>
#include <maya/MFnPlugin.h>
{
public:
mySChecker();
~mySChecker() override;
SchedulingType
schedulingType()
const override {
return SchedulingType::kParallel; }
static void * creator();
private:
};
const MTypeId mySChecker::id( 0x8100b );
#define MAKE_INPUT(attr) \
attr.setKeyable(true); attr.setStorable(true); \
attr.setReadable(true); attr.setWritable(true);
#define MAKE_OUTPUT(attr) \
attr.setKeyable(false); attr.setStorable(false); \
attr.setReadable(true); attr.setWritable(false);
mySChecker::mySChecker()
{
}
mySChecker::~mySChecker()
{
}
void * mySChecker::creator()
{
return new mySChecker();
}
{
MAKE_INPUT(nAttr);
MAKE_INPUT(nAttr);
MAKE_INPUT(nAttr);
aPlaceMat = mAttr.
create(
"placementMatrix",
"pm",
MAKE_INPUT(mAttr);
MAKE_INPUT(nAttr);
MAKE_OUTPUT(nAttr);
MAKE_OUTPUT(nAttr);
addAttribute(aColor1);
addAttribute(aColor2);
addAttribute(aPointWorld);
addAttribute(aPlaceMat);
addAttribute(aBias);
addAttribute(aOutColor);
addAttribute(aOutAlpha);
attributeAffects (aColor1, aOutColor);
attributeAffects (aColor1, aOutAlpha);
attributeAffects (aColor2, aOutColor);
attributeAffects (aColor2, aOutAlpha);
attributeAffects (aPointWorld, aOutColor);
attributeAffects (aPointWorld, aOutAlpha);
attributeAffects (aPlaceMat, aOutColor);
attributeAffects (aPlaceMat, aOutAlpha);
attributeAffects (aBias, aOutColor);
attributeAffects (aBias, aOutAlpha);
return MS::kSuccess;
}
{
if((plug != aOutColor) && (plug.
parent() != aOutColor) &&
(plug != aOutAlpha))
return MS::kUnknownParameter;
MFloatPoint pos(worldPos[0], worldPos[1], worldPos[2]);
pos *= mat;
int count = 0;
if (pos.x - floor(pos.x) < bias[0]) count++;
if (pos.y - floor(pos.y) < bias[1]) count++;
if (pos.z - floor(pos.z) < bias[2]) count++;
if (count & 1)
else
outColor = resultColor;
float& outAlpha = outAlphaHandle.
asFloat();
outAlpha = ( count & 1) ? 1.0f : 0.0f;
return MS::kSuccess;
}
{
const MString UserClassify(
"texture/3d" );
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.5",
"Any");
plugin.registerNode("solidChecker", mySChecker::id,
&mySChecker::creator, &mySChecker::initialize,
return MS::kSuccess;
}
{
plugin.deregisterNode( mySChecker::id );
return MS::kSuccess;
}