#include <maya/MFnDagNode.h>
#include <maya/MItDag.h>
#include <maya/MObject.h>
#include <maya/MDagPath.h>
#include <maya/MPxCommand.h>
#include <maya/MSyntax.h>
#include <maya/MArgDatabase.h>
#include <maya/MStatus.h>
#include <maya/MString.h>
#include <maya/MFnPlugin.h>
#include <maya/MArgList.h>
#include <maya/MFnCamera.h>
#include <maya/MPoint.h>
#include <maya/MVector.h>
#include <maya/MMatrix.h>
#include <maya/MTransformationMatrix.h>
#include <maya/MFnLight.h>
#include <maya/MColor.h>
#include <maya/MFnNurbsSurface.h>
#include <maya/MIOStream.h>
#define kBreadthFlag "-b"
#define kBreadthFlagLong "-breadthFirst"
#define kDepthFlag "-d"
#define kDepthFlagLong "-depthFirst"
#define kCameraFlag "-c"
#define kCameraFlagLong "-cameras"
#define kLightFlag "-l"
#define kLightFlagLong "-lights"
#define kNurbsSurfaceFlag "-n"
#define kNurbsSurfaceFlagLong "-nurbsSurfaces"
#define kQuietFlag "-q"
#define kQuietFlagLong "-quiet"
{
public:
scanDagSyntax() {};
virtual ~scanDagSyntax();
static void* creator();
private:
void printTransformData(
const MDagPath& dagPath,
bool quiet);
};
scanDagSyntax::~scanDagSyntax() {}
void* scanDagSyntax::creator()
{
return new scanDagSyntax;
}
{
syntax.
addFlag(kBreadthFlag, kBreadthFlagLong);
syntax.
addFlag(kDepthFlag, kDepthFlagLong);
syntax.
addFlag(kCameraFlag, kCameraFlagLong);
syntax.
addFlag(kLightFlag, kLightFlagLong);
syntax.
addFlag(kNurbsSurfaceFlag, kNurbsSurfaceFlagLong);
syntax.
addFlag(kQuietFlag, kQuietFlagLong);
return syntax;
}
{
bool quiet = false;
status = parseArgs ( args, traversalType, filter, quiet );
if (!status)
return status;
return doScan( traversalType, filter, quiet);
};
bool & quiet)
{
if (argData.isFlagSet(kBreadthFlag))
else if (argData.isFlagSet(kDepthFlag))
if (argData.isFlagSet(kCameraFlag))
else if (argData.isFlagSet(kLightFlag))
else if (argData.isFlagSet(kNurbsSurfaceFlag))
if (argData.isFlagSet(kQuietFlag))
quiet = true;
return stat;
}
bool quiet)
{
MItDag dagIterator( traversalType, filter, &status);
if ( !status) {
status.
perror(
"MItDag constructor");
return status;
}
{
if (!quiet)
cout << endl << "Starting Breadth First scan of the Dag";
} else {
if (!quiet)
cout << endl << "Starting Depth First scan of the Dag";
}
switch (filter) {
if (!quiet)
cout << ": Filtering for Cameras\n";
break;
if (!quiet)
cout << ": Filtering for Lights\n";
break;
if (!quiet)
cout << ": Filtering for Nurbs Surfaces\n";
break;
default:
cout << endl;
}
int objectCount = 0;
for ( ; !dagIterator.isDone(); dagIterator.next() ) {
status = dagIterator.getPath(dagPath);
if ( !status ) {
status.
perror(
"MItDag::getPath");
continue;
}
if ( !status ) {
status.
perror(
"MFnDagNode constructor");
continue;
}
if (!quiet)
cout << dagNode.name() << ": " << dagNode.typeName() << endl;
if (!quiet)
objectCount += 1;
if ( !status ) {
status.
perror(
"MFnCamera constructor");
continue;
}
printTransformData(dagPath, quiet);
if (!quiet)
{
cout << " eyePoint: "
cout << " upDirection: "
cout << " viewDirection: "
cout << " aspectRatio: " << camera.aspectRatio() << endl;
cout << " horizontalFilmAperture: "
<< camera.horizontalFilmAperture() << endl;
cout << " verticalFilmAperture: "
<< camera.verticalFilmAperture() << endl;
}
if ( !status ) {
status.
perror(
"MFnLight constructor");
continue;
}
printTransformData(dagPath, quiet);
color = light.color();
if (!quiet)
{
cout << " color: ["
}
color = light.shadowColor();
if (!quiet)
{
cout << " shadowColor: ["
cout << " intensity: " << light.intensity() << endl;
}
if ( !status ) {
status.
perror(
"MFnNurbsSurface constructor");
continue;
}
printTransformData(dagPath, quiet);
if (!quiet)
{
cout << " numCVs: "
<< surface.numCVsInU()
<< " * "
<< surface.numCVsInV()
<< endl;
cout << " numKnots: "
<< surface.numKnotsInU()
<< " * "
<< surface.numKnotsInV()
<< endl;
cout << " numSpans: "
<< surface.numSpansInU()
<< " * "
<< surface.numSpansInV()
<< endl;
}
} else {
printTransformData(dagPath, quiet);
}
}
if (!quiet)
{
cout.flush();
}
setResult(objectCount);
}
void scanDagSyntax::printTransformData(
const MDagPath& dagPath,
bool quiet)
{
return;
if (!status) {
status.
perror(
"MFnDagNode constructor");
return;
}
if (!quiet)
{
<< endl;
}
double threeDoubles[3];
if (!quiet)
{
cout << " rotation: ["
<< threeDoubles[0] << ", "
<< threeDoubles[1] << ", "
<< threeDoubles[2] << "]\n";
}
if (!quiet)
{
cout << " scale: ["
<< threeDoubles[0] << ", "
<< threeDoubles[1] << ", "
<< threeDoubles[2] << "]\n";
}
}
{
MFnPlugin plugin ( obj, PLUGIN_COMPANY,
"3.0",
"Any" );
status = plugin.registerCommand( "scanDagSyntax",
scanDagSyntax::creator,
scanDagSyntax::newSyntax );
return status;
}
{
status = plugin.deregisterCommand( "scanDagSyntax" );
return status;
}