#include <maya/MFnDagNode.h>
#include <maya/MItDag.h>
#include <maya/MObject.h>
#include <maya/MDagPath.h>
#include <maya/MPxCommand.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>
{
public:
scanDag() {};
~scanDag() override;
static void* creator();
private:
void printTransformData(
const MDagPath& dagPath,
bool quiet);
};
scanDag::~scanDag() {}
void* scanDag::creator()
{
return new scanDag;
}
{
bool quiet = false;
status = parseArgs ( args, traversalType, filter, quiet );
if (!status)
return status;
return doScan( traversalType, filter, quiet);
};
bool & quiet)
{
const MString breadthFlagLong (
"-breadthFirst");
const MString depthFlagLong (
"-depthFirst");
const MString cameraFlagLong (
"-cameras");
const MString lightFlagLong (
"-lights");
const MString nurbsSurfaceFlag (
"-n");
const MString nurbsSurfaceFlagLong (
"-nurbsSurfaces");
const MString quietFlagLong (
"-quiet");
for (
unsigned int i = 0; i < args.
length(); i++ ) {
if (!stat)
continue;
if ( arg == breadthFlag || arg == breadthFlagLong )
else if ( arg == depthFlag || arg == depthFlagLong )
else if ( arg == cameraFlag || arg == cameraFlagLong )
else if ( arg == lightFlag || arg == lightFlagLong )
else if ( arg == nurbsSurfaceFlag || arg == nurbsSurfaceFlagLong )
else if ( arg == quietFlag || arg == quietFlagLong )
quiet = true;
else {
arg += ": unknown argument";
displayError(arg);
return MS::kFailure;
}
}
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);
return MS::kSuccess;
}
void scanDag::printTransformData(
const MDagPath& dagPath,
bool quiet)
{
return;
if (!status) {
status.
perror(
"MFnDagNode constructor");
return;
}
if (!quiet)
{
<< endl;
}
double threeDoubles[3];
matrix.getRotation (threeDoubles, rOrder);
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( "scanDag", scanDag::creator );
if ( !status )
status.
perror(
"registerCommand");
return status;
}
{
status = plugin.deregisterCommand( "scanDag" );
if ( ! status )
status.
perror(
"deregisterCommand");
return status;
}