#include <maya/MPxImagePlane.h>
#include <maya/MFnPlugin.h>
#include <maya/MImage.h>
#include <maya/MString.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnNumericData.h>
#include <maya/MDataHandle.h>
#include <maya/MPlug.h>
{
public:
customImagePlane();
static void* creator();
private:
double fTransparency;
};
MObject customImagePlane::aTransparency;
customImagePlane::customImagePlane() :
fTransparency( 0.0 )
{
}
bool
customImagePlane::getInternalValueInContext(
{
if ( plug == aTransparency ) {
handle.
set( fTransparency );
return true;
}
}
bool
customImagePlane::setInternalValueInContext(
{
if ( plug == aTransparency ) {
setImageDirty();
return true;
}
}
customImagePlane::loadImageMap(
{
unsigned int width, height;
unsigned int size = width * height;
unsigned char *pixels = image.
pixels();
unsigned int i;
for ( i = 0; i < size; i ++, pixels += 4 ) {
pixels[3] = (unsigned char)(pixels[3] * (1.0 - fTransparency));
}
MPlug depthMap( thisMObject(), useDepthMap );
bool value;
depthMap.getValue( value );
if ( value ) {
float *buffer = new float[width*height];
unsigned int c, j;
for ( c = i = 0; i < height; i ++ ) {
for ( j = 0; j < width; j ++, c++ ) {
if ( i > height/2 ) {
buffer[c] = -1.0f;
} else {
buffer[c] = 0.0f;
}
}
}
delete [] buffer;
}
}
MTypeId customImagePlane::id( 0x1A19 );
void*
customImagePlane::creator()
{
return new customImagePlane;
}
customImagePlane::initialize()
{
aTransparency = nAttr.
create(
"transparency",
"tp",
addAttribute( aTransparency );
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"7.0",
"Any");
status = plugin.registerNode( "customImagePlane", customImagePlane::id,
customImagePlane::creator,
customImagePlane::initialize,
if (!status) {
status.
perror(
"registerNode");
return( status );
}
return( status );
}
{
status = plugin.deregisterNode( customImagePlane::id );
if (!status) {
status.
perror(
"deregisterNode");
return( status );
}
return( status );
}