#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 );
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, args );
displayError( msg );
}
if ( !status )
return status;
bool fIsQuery = argData.isQuery();
if( depFn.typeId() != dx11ShaderNode::typeId() )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, nodeName );
displayError( msg );
}
dx11ShaderNode* shader = (dx11ShaderNode*) depFn.userNode();
if( !shader )
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kInvalidDx11ShaderNode, nodeName );
displayError( msg );
}
if ( fIsQuery )
{
if( parser.isFlagSet(kFXFileFlag) )
{
MString path = shader->effectName();
setResult( path );
}
else if( parser.isFlagSet( kListTechniquesFlag ) )
{
setResult( shader->techniques() );
}
else if( parser.isFlagSet( kListLightInformationFlag ) )
{
setResult( shader->lightInfoDescription() );
}
else if( parser.isFlagSet( kListUIGroupInformationFlag ) )
{
setResult( shader->getUIGroups() );
}
}
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 );
}
argData.getFlagArgument(kConnectLightFlag, 1, lightName);
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownSceneObject, lightName );
displayError( msg );
}
unsigned int numShapes = 0;
for (unsigned int i = 0; i < numShapes; ++i)
{
status = shapePath.extendToShapeDirectlyBelow(i);
{
lightShapeDagPath = shapePath;
break;
}
}
{
MString msg = dx11ShaderStrings::getString( dx11ShaderStrings::kNotALight, lightName );
displayError( msg );
}
shader->disconnectLight(lightIndex);
shader->connectLight(lightIndex,lightShapeDagPath);
}
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 );
}
setResult( shader->getLightConnectionInfo(lightIndex));
}
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 );
}
setResult( shader->getLightableParameters(lightIndex, parser.isFlagSet(kListLightParameterSemanticsFlag) ));
}
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 );
}
setResult( shader->getUIGroupParameters(uiGroupIndex) );
}
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 );
}
shader->disconnectLight(lightIndex);
}
}
}
{
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;
}