fxManagerCmd.cpp
#include <maya/MArgDatabase.h>
#include <maya/MGlobal.h>
#include "fxManagerCmd.h"
MStatus fxManagerCmd::doIt( const MArgList &args) {
MArgDatabase argData( syntax(), args);
MString nodeName;
glslShaderNode *node = NULL;
if (argData.isFlagSet( "-n")) {
argData.getFlagArgument( "-n", 0, nodeName);
node = glslShaderNode::findNodeByName(nodeName);
if (!node) {
MGlobal::displayError( MString("Node '") +nodeName +"' does not exist");
return MStatus::kFailure;
}
}
if (argData.isFlagSet( "-ls")) {
int pass;
if (argData.isFlagSet( "-vs")) {
argData.getFlagArgument( "-vs", 0, pass);
if (!node->printVertexShader(pass)) {
MGlobal::displayError( MString("No vertex shader available for pass ") + pass);
return MStatus::kFailure;
}
}
if (argData.isFlagSet( "-ps")) {
argData.getFlagArgument( "-ps", 0, pass);
if (!node->printPixelShader(pass)) {
MGlobal::displayError( MString("No pixel shader available for pass ") + pass);
return MStatus::kFailure;
}
}
}
return MStatus::kSuccess;
}
MStatus fxManagerCmd::undoIt(){
return MStatus::kSuccess;
}
MStatus fxManagerCmd::redoIt(){
return MStatus::kSuccess;
}
bool fxManagerCmd::isUndoable() const{
return false;
}
bool fxManagerCmd::hasSyntax() const {
return true;
}
MSyntax fxManagerCmd::mySyntax() {
MSyntax syntax;
syntax.addFlag( "-ls", "-listShader");
syntax.addFlag( "-ps", "-pixelShader", MSyntax::kLong);
syntax.addFlag( "-vs", "-vertexShader", MSyntax::kLong);
syntax.addFlag( "-n", "-node", MSyntax::kString);
return syntax;
}
bool fxManagerCmd::isHistoryOn() const {
return false;
}
MString fxManagerCmd::commandString() const {
return MString();
}
MStatus fxManagerCmd::setHistoryOn( bool state ){
return MStatus::kSuccess;
}
MStatus fxManagerCmd::setCommandString( const MString &str) {
return MStatus::kSuccess;
}