#include <maya/MSimple.h>
#include <maya/MIOStream.h>
#include <maya/MRenderView.h>
#include <maya/M3dView.h>
#include <math.h>
#include <maya/MSyntax.h>
#include <maya/MArgDatabase.h>
{
public:
renderViewRenderRegion() {};
~renderViewRenderRegion() {};
static void* creator();
static const char * cmdName;
private:
bool doNotClearBackground;
};
static const char * kDoNotClearBackground = "-b";
static const char * kDoNotClearBackgroundLong = "-background";
const char * renderViewRenderRegion::cmdName = "renderViewRenderRegion";
void* renderViewRenderRegion::creator()
{
return new renderViewRenderRegion;
}
MSyntax renderViewRenderRegion::newSyntax()
{
syntax.
addFlag( kDoNotClearBackground, kDoNotClearBackgroundLong );
return syntax;
}
{
doNotClearBackground = argData.
isFlagSet( kDoNotClearBackground );
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.5" );
stat = plugin.registerCommand( renderViewRenderRegion::cmdName,
renderViewRenderRegion::creator,
renderViewRenderRegion::newSyntax);
if ( !stat )
stat.
perror(
"registerCommand" );
return stat;
}
{
stat = plugin.deregisterCommand( renderViewRenderRegion::cmdName );
if ( !stat )
stat.
perror(
"deregisterCommand" );
return stat;
}
{
unsigned int distance = (unsigned int) sqrt(double((x*x) + (y*y)));
pixel.
g = pixel.
r = 155.0f + (distance % 20) * 5;
return pixel;
}
{
unsigned int resX = 640;
unsigned int resY = 480;
{
setResult( "Cannot renderViewRenderRegion in batch render mode. "
"Please run in interactive mode, "
"so that the render editor exists." );
}
parseSyntax( argData );
{
setResult( "renderViewRenderRegion: error occurred in setCurrentCamera." );
}
unsigned int regionLeft, regionRight, regionBottom, regionTop;
regionBottom, regionTop );
{
setResult( "renderViewRenderRegion: error occurred in getRenderRegion." );
}
regionLeft, regionRight,
regionBottom, regionTop,
doNotClearBackground );
{
cout<<"Rendering Region ("<<regionLeft<<","<<regionBottom
<<") -> ("<<regionRight<<","<<regionTop<<")"<<endl;
unsigned int width = regionRight - regionLeft + 1;
unsigned int height = regionTop - regionBottom + 1;
unsigned int numPixels = width * height;
unsigned int middleX = width / 2;
unsigned int middleY = height / 2;
for( unsigned int x = 0; x < width; x++ )
{
for( unsigned int y = 0; y < height; y++ )
{
int index = y*width + x;
int xCoord = x - middleX;
int yCoord = y - middleY;
pixels[index] = evaluate( xCoord, yCoord );
}
}
regionBottom, regionTop,
pixels );
{
setResult( "renderViewRenderRegion: error occurred in updatePixels." );
}
regionBottom, regionTop );
{
setResult( "renderViewRenderRegion: error occurred in refresh." );
}
}
else
{
setResult( "renderViewRenderRegion: error occurred in startRegionRender." );
}
{
setResult( "renderViewRenderRegion: error occurred in endRender." );
}
setResult( "renderViewRenderRegion completed." );
return stat;
}