#include <math.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/MArrayDataHandle.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnLightDataAttribute.h>
#include <maya/MFloatVector.h>
#include <maya/MFnPlugin.h>
{
public:
ShadowMatte();
virtual ~ShadowMatte();
static void * creator();
private:
static MObject aLightShadowFraction;
static MObject aPreShadowIntensity;
};
MTypeId ShadowMatte::id( 0x81013 );
MObject ShadowMatte::aOutTransparency;
MObject ShadowMatte::aLightDirection;
MObject ShadowMatte::aLightIntensity;
MObject ShadowMatte::aLightAmbient;
MObject ShadowMatte::aLightDiffuse;
MObject ShadowMatte::aLightSpecular;
MObject ShadowMatte::aLightShadowFraction;
MObject ShadowMatte::aPreShadowIntensity;
MObject ShadowMatte::aLightBlindData;
void ShadowMatte::postConstructor( )
{
setMPSafe(true);
}
ShadowMatte::ShadowMatte()
{
}
ShadowMatte::~ShadowMatte()
{
}
void * ShadowMatte::creator()
{
return new ShadowMatte();
}
{
aOutTransparency = nAttr.
createColor(
"outTransparency",
"ot" );
aLightDirection = nAttr.
createPoint(
"lightDirection",
"ld" );
aLightIntensity = nAttr.
createColor(
"lightIntensity",
"li" );
aLightAmbient = nAttr.
create(
"lightAmbient",
"la",
aLightDiffuse = nAttr.
create(
"lightDiffuse",
"ldf",
aLightSpecular = nAttr.
create(
"lightSpecular",
"ls",
aLightShadowFraction = nAttr.
create(
"lightShadowFraction",
"lsf",
aPreShadowIntensity = nAttr.
create(
"preShadowIntensity",
"psi",
aLightBlindData = nAttr.
createAddr(
"lightBlindData",
"lbld");
aLightData = lAttr.
create(
"lightDataArray",
"ltd",
aLightDirection, aLightIntensity, aLightAmbient,
aLightDiffuse, aLightSpecular,
aLightShadowFraction,
aPreShadowIntensity,
aLightBlindData);
lAttr.
setDefault(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
true,
true,
false, 0.0f, 1.0f, NULL);
addAttribute(aLightData);
addAttribute(aOutColor);
addAttribute(aOutTransparency);
addAttribute(aViewColor);
attributeAffects (aViewColor, aOutColor);
attributeAffects (aLightIntensity, aOutColor);
attributeAffects (aLightData, aOutColor);
attributeAffects (aLightAmbient, aOutColor);
attributeAffects (aLightSpecular, aOutColor);
attributeAffects (aLightDiffuse, aOutColor);
attributeAffects (aLightDirection, aOutColor);
attributeAffects (aLightShadowFraction, aOutColor);
attributeAffects (aPreShadowIntensity, aOutColor);
attributeAffects (aLightBlindData, aOutColor);
attributeAffects (aViewColor, aOutTransparency);
attributeAffects (aLightIntensity, aOutTransparency);
attributeAffects (aLightData, aOutTransparency);
attributeAffects (aLightAmbient, aOutTransparency);
attributeAffects (aLightSpecular, aOutTransparency);
attributeAffects (aLightDiffuse, aOutTransparency);
attributeAffects (aLightDirection, aOutTransparency);
attributeAffects (aLightShadowFraction, aOutTransparency);
attributeAffects (aPreShadowIntensity, aOutTransparency);
attributeAffects (aLightBlindData, aOutTransparency);
}
{
if ((plug != aOutColor) && (plug.
parent() != aOutColor) &&
(plug != aOutTransparency) && (plug.
parent() != aOutTransparency))
for( int count=1; count <= numLights; count++ )
{
float lightShadow = currentLight.
child(aLightShadowFraction).
asFloat();
shadowColor[0] += lightShadow;
shadowColor[1] += lightShadow;
shadowColor[2] += lightShadow;
if( !lightData.
next() )
break;
}
if (ViewFlag)
outColor = shadowColor;
else
outColor = ghostColor;
outTrans = shadowColor;
}
{
const MString UserClassify(
"shader/surface" );
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
plugin.registerNode( "shadowMatte", ShadowMatte::id,
ShadowMatte::creator, ShadowMatte::initialize,
}
{
plugin.deregisterNode( ShadowMatte::id );
}