#include <maya/MFnPlugin.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/MFloatVector.h>
#define PERRORfail(stat,msg) \
if (!(stat)) { stat.perror((msg)); return (stat); }
class shiftNode;
{
public:
shiftNode();
virtual ~shiftNode();
static void * creator();
private:
float ox, oy, oz;
int initID, doneID;
static bool firstTime;
};
MObject shiftNode::aRefPointCamera;
shiftNode::shiftNode()
{
}
shiftNode::~shiftNode()
{
}
void * shiftNode::creator()
{
return new shiftNode();
}
{
aShift = nAttr.
create(
"shift",
"sh",
stat = addAttribute( aShift );
PERRORfail( stat, "addAttribute shift" );
aDist = nAttr.
create(
"distance",
"dis",
stat = addAttribute( aDist );
PERRORfail( stat, "addAttribute dist" );
stat = addAttribute( aColor );
PERRORfail( stat, "addAttribute inColor" );
aRefPointCamera = nAttr.
createPoint(
"refPointCamera",
"rpc" );
stat = addAttribute( aRefPointCamera );
PERRORfail( stat, "addAttribute refPointCamera" );
aUv = nAttr.
create(
"uvCoord",
"uv", u, v );
stat = addAttribute( aUv );
PERRORfail( stat, "addAttribute uv" );
PERRORfail(stat, "initialize create outColor attribute");
stat = addAttribute( aOutColor );
PERRORfail(stat, "addAttribute(outColor)");
attributeAffects ( aShift, aOutColor );
attributeAffects ( aDist, aOutColor );
attributeAffects ( aColor, aOutColor );
attributeAffects ( aRefPointCamera, aOutColor );
attributeAffects ( aUv, aOutColor );
attributeAffects ( aUv, aUv );
attributeAffects ( aRefPointCamera, aRefPointCamera );
}
{
if ((plug != aOutColor) && (plug.
parent() != aOutColor))
PERRORfail(stat, "compute getting shift attr");
bool shiftIt = shiftH.
asBool();
PERRORfail(stat, "compute getting distance attr");
if ( shiftIt && distance != 0.0 )
{
PERRORfail(stat, "compute getting refPointCamera attr");
outUV.
set( oldUV[0]-distance, oldUV[1] );
outPC.
set( refPC.
x + distance, refPC.
y + distance, refPC.
z + distance);
clr += color;
outUV.
set( oldUV[0]+distance, oldUV[1] );
outPC.
set( refPC.
x - distance, refPC.
y + distance, refPC.
z + distance);
clr += color;
outUV.
set( oldUV[0], oldUV[1]-distance );
outPC.
set( refPC.
x + distance, refPC.
y - distance, refPC.
z + distance);
clr += color;
outUV.
set( oldUV[0], oldUV[1]+distance );
outPC.
set( refPC.
x - distance, refPC.
y - distance, refPC.
z + distance);
clr += color;
clr /= 5.0;
outUV.
set( oldUV[0], oldUV[1] );
outPC.
set( refPC.
x, refPC.
y, refPC.
z );
}
else
{
}
oclr = clr;
}
{
const MString UserClassify(
"utility/general" );
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.5",
"Any");
plugin.registerNode( "shiftNode", shiftNode::id,
shiftNode::creator, shiftNode::initialize,
}
{
plugin.deregisterNode( shiftNode::id );
}