#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MIOStream.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>
#include <maya/MFnPlugin.h>
{
public:
VolumeNode();
virtual ~VolumeNode();
static void * creator();
private:
};
MObject VolumeNode::aOutTransparency;
void VolumeNode::postConstructor( )
{
setMPSafe(true);
}
VolumeNode::VolumeNode()
{
}
VolumeNode::~VolumeNode()
{
}
void* VolumeNode::creator()
{
return new VolumeNode();
}
{
aToggleCamera = nAttr.
create(
"cameraSpace",
"cs",
aToggleObject = nAttr.
create(
"objectSpace",
"os",
aFarPointC = nAttr.
createPoint(
"farPointCamera",
"fc" );
aFarPointW = nAttr.
createPoint(
"farPointWorld",
"fw" );
aOutTransparency = nAttr.
createColor(
"outTransparency",
"ot" );
}
{
if ((plug != aOutColor) && (plug.
parent() != aOutColor) &&
(plug != aOutTransparency) && (plug.
parent() != aOutTransparency))
if (Camera) {
interval = FarCamera - PointCam;
}
if (Object) {
interval = FarObject - PointObj;
}
if (World) {
interval = FarWorld - PointWor;
}
double value,dist;
if ((value = ((interval[0]*interval[0]) +
(interval[1]*interval[1]) +
(interval[2]*interval[2])) ))
{
dist = sqrt ( value );
}
else dist = 0.0;
if (dist <= Distance) {
resultColor[0] = InputColor[0];
resultColor[1] = InputColor[1];
resultColor[2] = InputColor[2];
}
outColor = resultColor;
MFloatVector transparency(resultColor[2],resultColor[2],resultColor[2]);
outTrans = transparency;
float& outAlpha = outAlphaHandle.
asFloat();
outAlpha = resultColor[2];
}
{
const MString UserClassify(
"shader/volume" );
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.5",
"Any");
CHECK_MSTATUS( plugin.registerNode(
"volumeNode", VolumeNode::id,
VolumeNode::creator, VolumeNode::initialize,
}
{
}