#include <maya/MPxCommand.h>
#include <maya/MStatus.h>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MObject.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MPoint.h>
#include <maya/MImage.h>
#include <maya/MIOStream.h>
#define IFFCHECKERR(stat, call) \
if (!stat) { \
MString string = reader.errorString(); \
string += " in method "; \
string += #call; \
displayError (string); \
return MS::kFailure; \
}
{
public:
convertBump();
virtual ~convertBump();
static void* creator();
};
convertBump::convertBump()
{
}
convertBump::~convertBump() {}
void* convertBump::creator()
{
return new convertBump;
}
bool convertBump::isUndoable() const
{
return false;
}
{
char buffer [256];
sprintf (buffer, "%d", n);
}
{
{
displayError ("Fatal Error! The required filter (kHeightFieldBumpFormat -> kNormalMapBumpFormat) isn't supported!");
}
{
displayError ("Syntax: convertBump inputFile outputFile [outputFormat [bumpScale]]");
displayError ("(eg: convertBump \"C:/bump.tga\" \"C:/bump_norm.tga\" \"tga\" 1.0)");
}
double bumpScale = 1.0;
MString inputFilename, outputFilename;
args.
get(0, inputFilename);
args.
get(1, outputFilename);
args.
get(2, outputFormat);
{
}
if (!stat)
{
displayError ("Unable to open input file \"" + inputFilename + "\".");
}
unsigned int width, height;
stat = image.
getSize(width, height);
if (!stat)
{
displayError ("Unable to get size.");
}
if (!stat)
{
displayError ("Unable to apply the filter from height field to normal map bump format.");
}
stat = image.
writeToFile(outputFilename, outputFormat);
if (!stat)
{
displayError ("Unable to write to output file \"" + outputFilename + "\" using output format " + outputFormat +
". (read-only? disk full? invalid path?)");
}
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.0.1",
"Any");
status = plugin.registerCommand( "convertBump", convertBump::creator );
if (!status)
status.
perror(
"registerCommand");
return status;
}
{
status = plugin.deregisterCommand( "convertBump" );
if (!status)
status.
perror(
"deregisterCommand");
return status;
}