#include <maya/MFnPlugin.h>
#include <maya/MFragmentManager.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MViewport2Renderer.h>
#include <maya/MPxCommand.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>
#include <iostream>
{
public:
static void* creator()
{
return new dumpFragment();
}
virtual ~dumpFragment() {}
{
bool includeUpstream = false;
bool useContext = false;
bool fragmentList = false;
bool fragmentName = false;
for (
unsigned int i=0; i<args.
length(); i++)
{
if (argStr == "-fl" || argStr == "-fragmentList")
{
fragmentList = true;
}
else if (argStr == "-fn" || argStr == "-fragmentName")
{
fragmentName = true;
}
else if (argStr == "-iu" || argStr == "-includeUpstream")
{
includeUpstream = true;
}
else if (argStr == "-oc" || argStr == "-objectContext")
{
useContext = true;
}
else
{
shaderName = argStr;
break;
}
}
if (!fragmentName && !fragmentList)
{
{
if (!list.
add(shaderName))
{
}
}
else
{
}
}
if (!fragmentName && !fragmentList)
{
if (useContext)
{
{
"Object context requested but no DAG object selected");
}
}
}
if (!fragmentName && !fragmentList)
{
{
if (fragmentMgr->
getFragmentXML(shaderObj, buffer, includeUpstream, useContext ? &path : NULL))
{
std::cerr << "##############################################################################" << std::endl;
std::cerr <<
"Fragment graph for shading network rooted at " << node.
name().
asChar();
std::cerr <<
"(type: " << node.
typeName().
asChar() <<
")" << std::endl;
if (useContext)
{
}
std::cerr << "##############################################################################" << std::endl;
std::cerr << buffer.
asChar() << std::endl;
std::cerr << "##############################################################################" << std::endl;
}
else
{
"Failed to get fragment graph XML for " + shaderName);
}
}
else
{
}
}
else
{
if (fragmentList)
{
}
{
{
}
else
{
}
}
}
}
};
{
MFnPlugin plugin(obj, PLUGIN_COMPANY,
"1.0",
"Any");
MStatus status = plugin.registerCommand(
"dumpFragment", dumpFragment::creator);
if (!status)
{
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
MStatus status = plugin.deregisterCommand(
"dumpFragment");
if (!status)
{
status.
perror(
"deregisterCommand");
return status;
}
return status;
}