#if _MSC_VER >= 1700
#pragma warning( disable: 4005 )
#endif
#include "dx11ShaderCmd.h"
#include "dx11Shader.h"
#include "dx11ShaderStrings.h"
#include <maya/MGlobal.h>
#include <maya/MArgDatabase.h>
#include <maya/MCommandResult.h>
#include <maya/MDagPath.h>
#include <maya/MFeedbackLine.h>
#include <maya/MFnDagNode.h>
#include <maya/MSyntax.h>
#include <maya/MArgParser.h>
#include <maya/MSelectionList.h>
#define kReloadFlag "-r"
#define kReloadFlagLong "-reload"
#define kFXFileFlag "-fx"
#define kFXFileFlagLong "-fxFile"
#define kListTechniquesFlag "-lt"
#define kListTechniquesFlagLong "-listTechniques"
#define kClearParametersFlag "-c"
#define kClearParametersFlagLong "-clearParameters"
#define kListLightInformationFlag "-li"
#define kListLightInformationFlagLong "-listLightInformation"
#define kListLightParametersFlag "-lp"
#define kListLightParametersFlagLong "-listLightParameters"
#define kListLightParameterSemanticsFlag "-sem"
#define kListLightParameterSemanticsFlagLong "-semantics"
#define kListUIGroupInformationFlag "-lg"
#define kListUIGroupInformationFlagLong "-listUIGroupInformation"
#define kListUIGroupParametersFlag "-lgp"
#define kListUIGroupParametersFlagLong "-listUIGroupParameters"
#define kConnectLightFlag "-cl"
#define kConnectLightFlagLong "-connectLight"
#define kLightConnectionStatusFlag "-lcs"
#define kLightConnectionStatusFlagLong "-lightConnectionStatus"
#define kDisconnectLightFlag "-d"
#define kDisconnectLightFlagLong "-disconnectLight"
dx11ShaderCmd::dx11ShaderCmd()
{}
dx11ShaderCmd::~dx11ShaderCmd()
{}
{
parser.getCommandArgument( 0, nodeName );
status = list.
add( nodeName );
if( status != MS::kSuccess )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, args );
displayError( msg );
return MS::kFailure;
}
if ( !status )
return status;
bool fIsQuery = argData.isQuery();
if( depFn.typeId() != dx11ShaderNode::typeId() )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, nodeName );
displayError( msg );
return MS::kFailure;
}
dx11ShaderNode* shader = (dx11ShaderNode*) depFn.userNode();
if( !shader )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, nodeName );
displayError( msg );
return MS::kFailure;
}
if ( fIsQuery )
{
if( parser.isFlagSet(kFXFileFlag) )
{
MString path = shader->effectName();
setResult( path );
return MS::kSuccess;
}
else if( parser.isFlagSet( kListTechniquesFlag ) )
{
setResult( shader->techniques() );
return MS::kSuccess;
}
else if( parser.isFlagSet( kListLightInformationFlag ) )
{
setResult( shader->lightInfoDescription() );
return MS::kSuccess;
}
else if( parser.isFlagSet( kListUIGroupInformationFlag ) )
{
setResult( shader->getUIGroups() );
return MS::kSuccess;
}
}
else
{
if( parser.isFlagSet(kReloadFlag) )
{
dx11ShaderNode::reloadAll( shader->effectName() );
}
else if( parser.isFlagSet(kClearParametersFlag))
{
shader->clearParameters();
}
else if( parser.isFlagSet(kConnectLightFlag))
{
argData.getFlagArgument(kConnectLightFlag, 0, connectableLightName);
int lightIndex = shader->getIndexForLightName(connectableLightName);
if (lightIndex < 0)
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownConnectableLight, connectableLightName );
displayError( msg );
return MS::kFailure;
}
argData.getFlagArgument(kConnectLightFlag, 1, lightName);
if( status != MS::kSuccess )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownSceneObject, lightName );
displayError( msg );
return MS::kFailure;
}
unsigned int numShapes = 0;
for (unsigned int i = 0; i < numShapes; ++i)
{
status = shapePath.extendToShapeDirectlyBelow(i);
if( status == MS::kSuccess && shapePath.hasFn(
MFn::kLight))
{
lightShapeDagPath = shapePath;
break;
}
}
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kNotALight, lightName );
displayError( msg );
return MS::kFailure;
}
shader->disconnectLight(lightIndex);
shader->connectLight(lightIndex,lightShapeDagPath);
return MS::kSuccess;
}
else if( parser.isFlagSet(kLightConnectionStatusFlag))
{
argData.getFlagArgument(kLightConnectionStatusFlag, 0, connectableLightName);
int lightIndex = shader->getIndexForLightName(connectableLightName);
if (lightIndex < 0)
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownConnectableLight, connectableLightName );
displayError( msg );
return MS::kFailure;
}
setResult( shader->getLightConnectionInfo(lightIndex));
return MS::kSuccess;
}
else if(parser.isFlagSet(kListLightParametersFlag))
{
argData.getFlagArgument(kListLightParametersFlag, 0, connectableLightName);
int lightIndex = shader->getIndexForLightName(connectableLightName);
if (lightIndex < 0)
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownConnectableLight, connectableLightName );
displayError( msg );
return MS::kFailure;
}
setResult( shader->getLightableParameters(lightIndex, parser.isFlagSet(kListLightParameterSemanticsFlag) ));
return MS::kSuccess;
}
else if(parser.isFlagSet(kListUIGroupParametersFlag))
{
argData.getFlagArgument(kListUIGroupParametersFlag, 0, connectableUIGroupName);
int uiGroupIndex = shader->getIndexForUIGroupName(connectableUIGroupName);
if (uiGroupIndex < 0)
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownUIGroup, connectableUIGroupName );
displayError( msg );
return MS::kFailure;
}
setResult( shader->getUIGroupParameters(uiGroupIndex) );
return MS::kSuccess;
}
else if( parser.isFlagSet(kDisconnectLightFlag))
{
argData.getFlagArgument(kDisconnectLightFlag, 0, lightName);
int lightIndex = shader->getIndexForLightName(lightName);
if (lightIndex < 0)
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownConnectableLight, lightName );
displayError( msg );
return MS::kFailure;
}
shader->disconnectLight(lightIndex);
return MS::kSuccess;
}
}
return MS::kSuccess;
}
{
syntax.
addFlag( kReloadFlag, kReloadFlagLong);
syntax.
addFlag( kListTechniquesFlag, kListTechniquesFlagLong);
syntax.
addFlag( kClearParametersFlag, kClearParametersFlagLong);
syntax.
addFlag( kListLightInformationFlag, kListLightInformationFlagLong);
syntax.
addFlag( kListLightParameterSemanticsFlag, kListLightParameterSemanticsFlagLong );
syntax.
addFlag( kListUIGroupInformationFlag, kListUIGroupInformationFlagLong);
return syntax;
}
void* dx11ShaderCmd::creator()
{
return new dx11ShaderCmd;
}