#include <maya/MPxLocatorNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MMatrix.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MColor.h>
#include <maya/M3dView.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnNurbsSurface.h>
#include <maya/MFnNurbsSurfaceData.h>
#include <maya/MFnPointArrayData.h>
#include <maya/MFnMatrixData.h>
#include <maya/MIOStream.h>
{
public:
cvColor();
virtual ~cvColor();
static void * creator();
};
cvColor::cvColor() {}
cvColor::~cvColor() {}
{
if ( plug == cvLocations ) {
if (!stat) {
stat.
perror(
"cvColor::compute get inputSurface");
return stat;
}
if (!stat) {
stat.
perror(
"cvColor::compute surface creator");
return stat;
}
if (!stat) {
stat.
perror(
"cvColor::compute get cvLocations");
return stat;
}
if (!stat) {
stat.
perror(
"cvColor::compute point array data creator");
return stat;
}
if (!stat) {
stat.
perror(
"cvColor::compute getCVs");
return stat;
}
stat = cvData.
set ( cvArray );
if (!stat) {
stat.
perror(
"cvColor::compute setCVs");
return stat;
}
if (!stat) {
stat.
perror(
"cvColor::compute setClean");
return stat;
}
} else {
}
}
{
MPlug enPlug( thisNode, drawingEnabled );
bool doDrawing;
stat = enPlug.getValue ( doDrawing );
if (!stat) {
stat.
perror(
"cvColor::draw get drawingEnabled");
return;
}
if (!doDrawing)
return;
MPlug szPlug( thisNode, pointSize );
float ptSize;
stat = szPlug.getValue ( ptSize );
if (!stat) {
stat.
perror(
"cvColor::draw get pointSize");
ptSize = 4.0;
}
MPlug cvPlug( thisNode, cvLocations );
stat = cvPlug.getValue(cvObject);
if (!stat) {
stat.
perror(
"cvColor::draw get cvObject");
return;
}
if (!stat) {
stat.
perror(
"cvColor::draw get point array data");
return;
}
if (!stat) {
stat.
perror(
"cvColor::draw get point array");
return;
}
MObject worldSpaceAttribute = fnThisNode.attribute(
"worldMatrix" );
MPlug matrixPlug( thisNode, worldSpaceAttribute);
matrixPlug = matrixPlug.elementByLogicalIndex (0);
stat = matrixPlug.getValue(matObject);
if (!stat) {
stat.
perror(
"cvColor::draw get matObject");
return;
}
if (!stat) {
stat.
perror(
"cvColor::draw get world matrix data");
return;
}
if (!stat) {
stat.
perror(
"cvColor::draw get world matrix");
return;
}
glPushAttrib( GL_CURRENT_BIT | GL_POINT_BIT );
glPointSize( ptSize );
glDisable ( GL_POINT_SMOOTH );
glBegin( GL_POINTS );
for (int i = 0; i < numCVs; i++) {
cv *= worldSpace;
if (cv.x < 0 && cv.y < 0) {
} else if (cv.x < 0 && cv.y >= 0) {
} else if (cv.x >= 0 && cv.y < 0) {
} else if (cv.x >= 0 && cv.y >= 0) {
}
glVertex3f( (float)cvs[i].x, (float)cvs[i].y, (float)cvs[i].z);
}
glEnd();
glPopAttrib();
}
bool cvColor::isBounded() const
{
return false;
}
void* cvColor::creator()
{
return new cvColor();
}
{
drawingEnabled = numericAttr.
create(
"drawingEnabled",
"en",
if (!stat) {
stat.
perror(
"create drawingEnabled attribute");
return stat;
}
pointSize = numericAttr.
create(
"pointSize",
"ps",
if (!stat) {
stat.
perror(
"create pointSize attribute");
return stat;
}
inputSurface = typedAttr.
create(
"inputSurface",
"is",
if (!stat) {
stat.
perror(
"create inputSurface attribute");
return stat;
}
cvLocations = typedAttr.
create(
"cvLocations",
"cv",
if (!stat) {
stat.
perror(
"create cvLocations attribute");
return stat;
}
defaultAttr = defaultArray.
create (defaultPoints);
if (!stat) {
stat.
perror(
"could not create default output attribute");
return stat;
}
stat = addAttribute (drawingEnabled);
if (!stat) { stat.
perror(
"addAttribute");
return stat;}
stat = addAttribute (pointSize);
if (!stat) { stat.
perror(
"addAttribute");
return stat;}
stat = addAttribute (inputSurface);
if (!stat) { stat.
perror(
"addAttribute");
return stat;}
stat = addAttribute (cvLocations);
if (!stat) { stat.
perror(
"addAttribute");
return stat;}
stat = attributeAffects( inputSurface, cvLocations );
if (!stat) { stat.
perror(
"attributeAffects");
return stat;}
stat = attributeAffects( drawingEnabled, cvLocations );
if (!stat) { stat.
perror(
"attributeAffects");
return stat;}
stat = attributeAffects( pointSize, cvLocations );
if (!stat) { stat.
perror(
"attributeAffects");
return stat;}
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode( "cvColor", cvColor::id,
&cvColor::creator, &cvColor::initialize,
if (!status) {
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode( cvColor::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}