#include <stdlib.h>
#include <string.h>
#include <vector>
#include <maya/MFStream.h>
#include <maya/MIOStream.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MFnPlugin.h>
#include <maya/MPxFileTranslator.h>
#include <maya/MAnimCurveClipboard.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MItDag.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MFnAnimCurve.h>
#include <maya/MAnimUtil.h>
#include <maya/MFnDagNode.h>
#include <maya/MDagPath.h>
#include <maya/MPlugArray.h>
#include <maya/MObjectArray.h>
#include <maya/MProgressWindow.h>
#include <maya/MAnimControl.h>
#include <maya/MDagModifier.h>
#include <maya/MMessage.h>
#include <maya/MSceneMessage.h>
#include "atomImportExport.h"
#include "atomFileUtils.h"
#include "atomImportExportStrings.h"
#include "atomNodeNameReplacer.h"
#include "atomCachedPlugs.h"
#if defined (OSMac_)
# include <sys/param.h>
extern "C" int strcasecmp (const char *, const char *);
#endif
const char *const animImportDefaultOptions =
"targetTime=4;copies=1;option=replace;pictures=0;connect=0;match=hierarchy;";
atomImport::atomImport()
{
}
atomImport::~atomImport()
{
}
void *atomImport::creator()
{
return new atomImport();
}
bool atomImport::replaceNameAndFindPlug(
const MString& origName,
atomNodeNameReplacer& replacer,
{
bool rtn = false;
origName.
split(
'.', nameParts);
if (replacer.findNode(atomNodeNameReplacer::eDag,tmpName,0,0)) {
newName += (".");
unsigned int ii;
for (ii = 1; ii < nameParts.
length(); ++ii) {
if (ii > 1) {
attrName += (".");
}
attrName += nameParts[ii];
}
newName += attrName;
if (!rtn) {
{
replacedPlug = fnNode.findPlug(attrName,false);
}
}
}
}
return rtn;
}
bool
atomImport::checkPlugAgainstTemplate(
const MString& nodeName,
atomTemplateReader* templateReader)
{
if (NULL != templateReader) {
plugName.
split(
'.', nameParts);
return (templateReader->findNodeAndAttr(nodeName,leafAttr));
}
return true;
}
void atomImport::connectionFailedCallback(
MPlug& srcPlug,
void* clientData)
{
atomEditsHelper* helper = (NULL != clientData) ? (atomEditsHelper*)clientData : NULL;
atomNodeNameReplacer* replacer = (NULL != helper) ? helper->fReplacer : NULL;
atomTemplateReader* templateReader = (NULL != helper) ? helper->fTemplateReader : NULL;
if (NULL != replacer && srcPlug.
isNull()) {
if (replaceNameAndFindPlug(srcName,*replacer,srcPlug)) {
return;
}
}
}
if (NULL != replacer && dstPlug.
isNull()) {
if (replaceNameAndFindPlug(dstName,*replacer,dstPlug)) {
dstName.
split(
'.', dstParts);
if (!checkPlugAgainstTemplate(dstParts[0],dstPlug,templateReader))
return;
return;
}
}
}
srcName.
split(
'.', nameParts);
MPlug leafPlug = fnLoc.findPlug(leafAttr);
if (!leafPlug.isNull()) {
fnLoc.setName(nameParts[0]);
}
}
}
}
FileAccessMode mode)
{
#if defined (OSMac_)
char fname[MAXPATHLEN];
strcpy (fname, fileName.
asChar());
ifstream animFile(fname);
#else
ifstream animFile(fileName.
asChar());
#endif
if(animFile.good()==false)
return status;
bool replaceLayers = false;
bool includeChildren = false;
atomNodeNameReplacer::ReplaceType type = atomNodeNameReplacer::eHierarchy;
bool useTemplate = false;
const MString flagSrcTime(
"srcTime");
const MString flagDstTime(
"dstTime");
const MString flagOldDstTime(
"time");
const MString flagCopies(
"copies");
const MString flagOption(
"option");
const MString flagConnect(
"connect");
const MString flagSearch(
"search");
const MString flagReplace(
"replace");
const MString flagPrefix(
"prefix");
const MString flagSuffix(
"suffix");
const MString flagMapFile(
"mapFile");
const MString flagHierarchy(
"hierarchy");
const MString flagString(
"string");
const MString flagSelected(
"selected");
const MString flagTemplate(
"template");
const MString optionChildrenToo(
"childrenToo");
const MString optionTemplate(
"template");
const MString flagExportEdits(
"exportEdits");
options.
split(
';', optionList);
unsigned nOptions = optionList.
length();
for (unsigned i = 0; i < nOptions; i++) {
optionList[i].split('=', theOption);
continue;
}
if (theOption[0] == flagCopies && theOption.
length() > 1) {
copyValue = theOption[1];;
}
else if (theOption[0] == flagOption && theOption.
length() > 1) {
flagValue = theOption[1];
}
else if (theOption[0] == flagConnect && theOption.
length() > 1) {
if (theOption[1].asInt() != 0) {
connectValue += theOption[1];
}
}
else if( theOption[0] == flagTemplate && theOption.
length() > 1)
{
templateName = theOption[1];
}
else if( theOption[0] == flagView && theOption.
length() > 1)
{
viewName = theOption[1];
}
else if (theOption[0] == flagSrcTime && theOption.
length() > 1) {
srcTimeValue += theOption[1];
}
else if ((theOption[0] == flagDstTime || theOption[0] == flagOldDstTime )&& theOption.
length() > 1) {
dstTimeValue += theOption[1];
}
else if (theOption[0] == flagMatch && theOption.
length() > 1) {
match = theOption[1];
}
else if (theOption[0] == flagSearch && theOption.
length() > 1) {
search = theOption[1];
}
else if (theOption[0] == flagReplace && theOption.
length() > 1) {
replace = theOption[1];
}
else if (theOption[0] == flagPrefix && theOption.
length() > 1) {
prefix = theOption[1];
}
else if (theOption[0] == flagSuffix && theOption.
length() > 1) {
suffix = theOption[1];
}
else if (theOption[0] == flagMapFile && theOption.
length() > 1) {
mapFile = theOption[1];
}
else if (theOption[0] == flagSelected && theOption.
length() > 1) {
includeChildren = (theOption[1] == optionChildrenToo) ? true : false;
if(theOption[1] == optionTemplate)
useTemplate = true;
}
else if (theOption[0] == flagExportEdits && theOption.
length() > 1) {
exportEditsFile = theOption[1];
}
}
pasteFlags += " -copies ";
pasteFlags += copyValue;
pasteFlags += " ";
}
pasteFlags += " -option \"";
pasteFlags += flagValue;
pasteFlags += "\" ";
if(flagValue ==
MString(
"replace"))
replaceLayers = true;
}
if (connectValue.
length() > 0) {
pasteFlags += " -connect ";
pasteFlags += connectValue;
pasteFlags += " ";
}
if (dstTimeValue.
length() > 0) {
bool useQuotes = !dstTimeValue.
isDouble();
pasteFlags += " -time ";
if (useQuotes) pasteFlags += "\"";
pasteFlags += dstTimeValue;
if (useQuotes) pasteFlags += "\"";
pasteFlags += " ";
}
if (srcTimeValue.
length() > 0)
{
{
{
double lImportStartFrame = lTimes[0].asDouble();
double lImportEndFrame = lImportStartFrame;
{
lImportEndFrame = lTimes[1].asDouble();
}
fReader.setImportFrameRange( lImportStartFrame, lImportEndFrame );
}
else
{
fReader.clearImportFrameRange();
}
}
}
else
{
fReader.clearImportFrameRange();
}
{
if(match == flagHierarchy)
type = atomNodeNameReplacer::eHierarchy;
else if(match == flagString)
type = atomNodeNameReplacer::eSearchReplace;
else if(match == flagMapFile)
type = atomNodeNameReplacer::eMapFile;
}
}
std::vector<unsigned int> depths;
atomTemplateReader templateReader;
if(useTemplate == true)
{
templateReader.setTemplate(templateName,viewName);
includeChildren = false;
templateReader.selectNodes();
}
SelectionGetter::getSelectedObjects(includeChildren,sList,depths);
}
atomNodeNameReplacer replacer(type,sList,depths,prefix,suffix,search,replace,mapFile);
if (mode == kImportAccessMode) {
status = importAnim(sList,animFile,pasteFlags,replacer,exportEditsFile,templateReader,replaceLayers);
}
animFile.close();
return status;
}
bool atomImport::haveReadMethod() const
{
return true;
}
bool atomImport::haveWriteMethod() const
{
return false;
}
bool atomImport::canBeOpened() const
{
return false;
}
MString atomImport::defaultExtension()
const
{
}
const char* buffer,
short size) const
{
int nameLength = (int)strlen(name);
if ((nameLength > 5) && !strcasecmp(name+nameLength-5, ".atom")) {
return kIsMyFileType;
}
if (strncmp(buffer, "atomVersion", 11) == 0) {
return kIsMyFileType;
}
return kNotMyFileType;
}
atomImport::importAnim(
MSelectionList &sList,ifstream &animFile,
const MString &pasteFlags, atomNodeNameReplacer & replacer,
MString& exportEditsFile,atomTemplateReader &templateReader,
bool replaceLayers)
{
atomLayerClipboard atomClipboard;
bool removeExportEditsFile = false;
(status = fReader.readAtom(animFile, atomClipboard,
sList,replacer,atomExportEdits,removeExportEditsFile,templateReader, replaceLayers
))) {
return status;
}
if (atomExportEdits.
length() > 0 && exportEditsFile.
length() == 0) {
exportEditsFile = atomExportEdits;
}
else
removeExportEditsFile = false;
if (exportEditsFile.
length() > 0) {
atomEditsHelper helper(&replacer,&templateReader);
replacer.setAddMainPlaceholderNamespace(true);
MString command =
"doImportAtomOfflineFile(1,{\"";
command += exportEditsFile;
command += "\"})";
replacer.setAddMainPlaceholderNamespace(false);
if(removeExportEditsFile)
remove(exportEditsFile.
asChar());
}
status = atomClipboard.pasteKeys(fReader.getStartTime(), fReader.getEndTime(),
(float) fReader.getStartUnitless(), (float) fReader.getEndUnitless(),pasteFlags);
return status;
}
const char *const animExportDefaultOptions = "whichRange=1;range=0:10;options=keys;hierarchy=none;controlPoints=0;useChannelBox=0;copyKeyCmd=";
const int kDefaultPrecision = 8;
atomExport::atomExport()
{
}
atomExport::~atomExport()
{
}
void *atomExport::creator()
{
return new atomExport();
}
FileAccessMode mode)
{
#if defined (OSMac_)
char fname[MAXPATHLEN];
strcpy (fname, fileName.
asChar());
ofstream animFile(fname);
#else
ofstream animFile(fileName.
asChar());
#endif
MString copyFlags(
"copyKey -cb api -fea 1 ");
int precision = kDefaultPrecision;
bool statics = false;
bool includeChildren = false;
std::set<std::string> attrStrings;
bool useSpecifiedRange = false;
bool useTemplate = false;
bool cached = false;
bool constraint = false;
bool sdk = false;
bool animLayers = true;
const MString flagPrecision(
"precision");
const MString flagStatics(
"statics");
const MString flagConstraint(
"constraint");
const MString flagAnimLayers(
"animLayers");
const MString flagCopyKeyCmd(
"copyKeyCmd");
const MString flagSelected(
"selected");
const MString flagTemplate(
"template");
const MString optionChildrenToo(
"childrenToo");
const MString optionTemplate(
"template");
const MString flagWhichRange(
"whichRange");
const MString flagExportEdits(
"exportEdits");
options.
split(
';', optionList);
unsigned nOptions = optionList.
length();
for (unsigned i = 0; i < nOptions; i++) {
optionList[i].split('=', theOption);
continue;
}
if (theOption[0] == flagPrecision && theOption.
length() > 1) {
if (theOption[1].isInt()) {
precision = theOption[1].asInt();
}
}
else if( theOption[0] == flagTemplate && theOption.
length() > 1)
{
templateName = theOption[1];
}
else if( theOption[0] == flagView && theOption.
length() > 1)
{
viewName = theOption[1];
}
else if ( theOption[0] ==
flagWhichRange && theOption.
length() > 1) {
if (theOption[1].isInt())
useSpecifiedRange = (theOption[1].asInt() ==1) ? false : true;
}
else if ( theOption[0] ==
flagRange && theOption.
length() > 1)
{
theOption[1].split(':',rangeArray);
{
if(rangeArray[0].isDouble())
{
double val = rangeArray[0].asDouble();
}
else if(rangeArray[0].isInt())
{
double val = (double)rangeArray[0].asInt();
}
if(rangeArray[1].isDouble())
{
double val = rangeArray[1].asDouble();
}
else if(rangeArray[1].isInt())
{
double val = (double)rangeArray[1].asInt();
}
}
}
else if ( theOption[0] ==
flagStatics && theOption.
length() > 1) {
if (theOption[1].isInt()) {
statics = (theOption[1].asInt()) ? true : false;
}
}
else if ( theOption[0] ==
flagSDK && theOption.
length() > 1) {
if (theOption[1].isInt()) {
sdk = (theOption[1].asInt()) ? true : false;
}
}
else if ( theOption[0] ==
flagConstraint && theOption.
length() > 1) {
if (theOption[1].isInt()) {
constraint = (theOption[1].asInt()) ? true : false;
}
}
else if ( theOption[0] ==
flagAnimLayers && theOption.
length() > 1) {
if (theOption[1].isInt()) {
animLayers = (theOption[1].asInt()) ? true : false;
}
}
else if ( theOption[0] ==
flagCached && theOption.
length() > 1) {
if (theOption[1].isInt()) {
cached = (theOption[1].asInt()) ? true : false;
}
}
else if (theOption[0] == flagSelected && theOption.
length() > 1) {
includeChildren = (theOption[1] == optionChildrenToo) ? true : false;
if(theOption[1] == optionTemplate)
useTemplate = true;
}
else if (theOption[0] == flagAttr && theOption.
length() > 1) {
std::string str(theOption[1].asChar());
attrStrings.insert(str);
}
else if ( theOption[0] ==
flagCopyKeyCmd && theOption.
length() > 1) {
const char *optStr = theOption[1].asChar();
size_t nChars = strlen(optStr);
char *copyStr = new char[nChars+1];
copyStr = strcpy(copyStr, optStr);
for (size_t j = 0; j < nChars; j++) {
if (copyStr[j] == '>') {
copyStr[j] = '"';
}
}
copyFlags += copyStr;
delete [] copyStr;
}
else if (theOption[0] == flagExportEdits && theOption.
length() > 1)
{
exportEditsFile = theOption[1];
}
}
}
animFile.precision(precision);
atomTemplateReader templateReader;
if(useTemplate == true)
{
includeChildren = false;
templateReader.setTemplate(templateName,viewName);
templateReader.selectNodes();
}
status = exportSelected(animFile, copyFlags, attrStrings, includeChildren,
useSpecifiedRange, startTime, endTime, statics,
cached,sdk,constraint, animLayers, exportEditsFile,templateReader);
animFile.flush();
animFile.close();
return status;
}
bool atomExport::haveReadMethod() const
{
return false;
}
bool atomExport::haveWriteMethod() const
{
return true;
}
MString atomExport::defaultExtension()
const
{
}
const char* buffer,
short size) const
{
int nameLength = (int)strlen(name);
if ((nameLength > 5) && !strcasecmp(name+nameLength-5, ".atom")) {
return kIsMyFileType;
}
return kNotMyFileType;
}
MStatus atomExport::writeAnimCurves(ofstream &animFile,
MString &nodeName,atomCachedPlugs *cachedPlugs,
atomNodeWithAnimLayers *layerPlugs,
MString &command,
bool &haveAnimatedCurves,
atomTemplateReader &templateReader)
{
int result = 0;
if(templateReader.isTemplateSet())
{
templateAttrs = templateReader.attributesForNode(nodeName);
if(templateAttrs.length()==0)
}
std::set<std::string> layerNames;
std::set<std::string>::iterator iter;
bool isLayered = layerPlugs && layerPlugs->isNodeLayered(layerNames);
iter = layerNames.begin();
do
{
if(isLayered && iter != layerNames.end())
{
std::string val = *iter;
}
else
isLayered =false;
if(isLayered ==
false || layerName.
length()==0 )
copyFromOne = command +
MString(
" ") + templateAttrs +
MString(
" ") + nodeName;
else
copyFromOne = command +
MString(
" -al ") + layerName +
MString(
" ") + templateAttrs +
MString(
" ") + nodeName;
haveAnimatedCurves = true;
{
haveAnimatedCurves = false;
}
{
haveAnimatedCurves = false;
}
if (haveAnimatedCurves &&
MS::kSuccess != ( fWriter.writeClipboard(animFile,
{
haveAnimatedCurves = false;
}
if(isLayered && iter != layerNames.end())
{
++iter;
}
}while (isLayered && iter != layerNames.end());
}
MStatus atomExport::exportSelected( ofstream &animFile,
std::set<std::string> &attrStrings,
bool includeChildren,
bool useSpecifiedTimes,
bool statics,
bool cached,
bool sdk,
bool constraint,
bool layers,
atomTemplateReader &templateReader)
{
std::vector<unsigned int> depths;
SelectionGetter::getSelectedObjects(includeChildren,sList,depths);
}
if (!fWriter.writeHeader(animFile,useSpecifiedTimes,
startTime,endTime)) {
}
atomAnimLayers animLayers;
std::vector<atomNodeWithAnimLayers *> nodesWithAnimLayers;
if(layers)
{
bool hasAnimLayers = animLayers.getOrderedAnimLayers();
hasAnimLayers = setUpAnimLayers(sList,animLayers, nodesWithAnimLayers,attrStrings,templateReader);
if(hasAnimLayers)
{
unsigned int oldLength = sList.
length();
animLayers.addLayersToStartOfSelectionList(sList);
unsigned int diffLength = sList.
length() - oldLength;
atomNodeWithAnimLayers * nullPad = NULL;
for(unsigned int k =0 ;k < diffLength;++k)
{
nodesWithAnimLayers.insert(nodesWithAnimLayers.begin(),nullPad);
depths.insert(depths.begin(),0);
}
}
}
std::vector<atomCachedPlugs *> cachedPlugs;
if(cached)
{
bool passed = setUpCache(sList,cachedPlugs,animLayers,sdk, constraint, layers, attrStrings,templateReader,startTime, endTime,
fWriter.getAngularUnit(), fWriter.getLinearUnit());
if(passed == false)
{
for(unsigned int z = 0; z< cachedPlugs.size(); ++z)
{
if(cachedPlugs[z])
delete cachedPlugs[z];
}
for(unsigned int zz = 0; zz< nodesWithAnimLayers.size(); ++zz)
{
if(nodesWithAnimLayers[zz])
delete nodesWithAnimLayers[zz];
}
}
}
unsigned int numObjects = sList.
length();
bool computationFinished = true;
bool hasActiveProgress = false;
hasActiveProgress = true;
}
if (exportEditsFile.
length() > 0) {
fWriter.writeExportEditsFilePresent(animFile);
}
if(layers)
{
animLayers.writeAnimLayers(animFile,fWriter);
}
bool haveAnyAnimatableStuff = false;
for (unsigned int i = 0; i < numObjects; i++)
{
if(hasActiveProgress)
bool haveAnimatedCurves = false;
bool haveAnimatableChannels = false;
{
if(templateReader.findNode(name)== false)
continue;
atomCachedPlugs * cachedPlug = NULL;
if(cached && i < cachedPlugs.size())
cachedPlug = cachedPlugs[i];
atomNodeWithAnimLayers *layerPlug = NULL;
if(layers && i < nodesWithAnimLayers.size())
layerPlug = nodesWithAnimLayers[i];
unsigned int depth = depths[i];
atomNodeNameReplacer::NodeType nodeType = (
object.hasFn(
MFn::kShape)) ? atomNodeNameReplacer::eShape : atomNodeNameReplacer::eDag;
fWriter.writeNodeStart(animFile,nodeType,name,depth,childCount);
if(writeAnimCurves(animFile,name,cachedPlug, layerPlug, command, haveAnimatedCurves,templateReader) !=
MS::kSuccess )
{
}
else if(haveAnimatedCurves)
{
haveAnyAnimatableStuff = true;
}
if(statics||cached)
{
writeStaticAndCached (animatablePlugs,cachedPlug,statics,cached,animFile,attrStrings,name,depth,childCount, haveAnimatableChannels,templateReader);
}
fWriter.writeNodeEnd(animFile);
}
}
atomNodeNameReplacer::NodeType nodeType = atomNodeNameReplacer::eDepend;
atomNodeWithAnimLayers *layerPlug = NULL;
if(i< animLayers.length())
{
animLayers.getPlugs(i,animatablePlugs);
nodeType = atomNodeNameReplacer::eAnimLayer;
}
else
{
if(templateReader.findNode(name)== false)
{
continue;
}
if(layers && i < nodesWithAnimLayers.size())
layerPlug = nodesWithAnimLayers[i];
}
atomCachedPlugs * cachedPlug = NULL;
if(cached && i < cachedPlugs.size())
cachedPlug = cachedPlugs[i];
fWriter.writeNodeStart(animFile,nodeType,name);
if(writeAnimCurves(animFile,name, cachedPlug,layerPlug,command, haveAnimatedCurves,templateReader) !=
MS::kSuccess )
{
}
else if(haveAnimatedCurves)
{
haveAnyAnimatableStuff = true;
}
if(statics||cached)
{
writeStaticAndCached (animatablePlugs,cachedPlug,statics,cached,animFile,attrStrings,name,0,0,haveAnimatableChannels,templateReader);
}
fWriter.writeNodeEnd(animFile);
}
if(haveAnimatableChannels==true)
haveAnyAnimatableStuff = true;
{
computationFinished = false;
break;
}
}
if (exportEditsFile.
length() > 0) {
fWriter.writeExportEditsFile(animFile,exportEditsFile);
}
for(unsigned int z = 0; z< cachedPlugs.size(); ++z)
{
if(cachedPlugs[z])
delete cachedPlugs[z];
}
for(unsigned int zz = 0; zz< nodesWithAnimLayers.size(); ++zz)
{
if(nodesWithAnimLayers[zz])
delete nodesWithAnimLayers[zz];
}
if(computationFinished == false)
{
}
if(hasActiveProgress)
if(haveAnyAnimatableStuff == false)
{
}
}
void
atomExport::writeStaticAndCached (
MPlugArray &animatablePlugs, atomCachedPlugs *cachedPlugs,
bool statics,
bool cached,ofstream &animFile, std::set<std::string> &attrStrings,
unsigned int childCount,bool &hasAnimatable,atomTemplateReader &templateReader )
{
unsigned int numPlugs = animatablePlugs.
length();
if (numPlugs != 0) {
hasAnimatable = true;
if(statics)
fWriter.writeStaticValues (animFile, animatablePlugs,attrStrings, name, depth, childCount,templateReader);
if(cached && cachedPlugs != NULL)
fWriter.writeCachedValues (animFile, cachedPlugs,attrStrings, name, depth, childCount,templateReader);
}
}
bool
atomExport::setUpCache(
MSelectionList &sList, std::vector<atomCachedPlugs *> &cachedPlugs,atomAnimLayers &animLayers,
bool sdk, bool constraint, bool layers,
std::set<std::string> &attrStrings, atomTemplateReader &templateReader,
{
if(endTime<startTime)
return false;
unsigned int numObjects = sList.
length();
cachedPlugs.resize(numObjects);
double dStart = startTime.
value();
double dEnd = endTime.
value() + (.0000001);
unsigned int numItems = ((unsigned int)((dEnd - dStart)/tickStep)) + 1;
bool somethingIsCached = false;
for (unsigned int i = 0; i < numObjects; i++)
{
atomCachedPlugs *plug = NULL;
cachedPlugs[i] = plug;
{
}
continue;
}
name = fnNode.name();
}
{
if(i< animLayers.length())
{
animLayers.getPlugs(i,plugs);
std::set<std::string> tempAttrStrings;
atomTemplateReader tempTemplateReader;
plug = new atomCachedPlugs(name,node,plugs,sdk,constraint,layers,
tempAttrStrings,tempTemplateReader,numItems,angularUnit,
linearUnit);
if(plug->hasCached() ==false)
delete plug;
else
{
cachedPlugs[i] = plug;
somethingIsCached = true;
}
}
else
{
if(templateReader.findNode(name)== false)
{
continue;
}
plug = new atomCachedPlugs(name,node,animatablePlugs,sdk,constraint,layers,attrStrings,templateReader,numItems,angularUnit,
linearUnit);
if(plug->hasCached() ==false)
delete plug;
else
{
cachedPlugs[i] = plug;
somethingIsCached = true;
}
}
}
}
bool computationFinished = true;
if(somethingIsCached)
{
bool hasActiveProgress = false;
hasActiveProgress = true;
}
unsigned int count =0;
for(double tick = dStart; tick <= dEnd; tick += tickStep)
{
if(hasActiveProgress)
for(unsigned int z = 0; z< cachedPlugs.size(); ++z)
{
if(cachedPlugs[z])
cachedPlugs[z]->calculateValue(ctx,count);
}
{
computationFinished = false;
break;
}
++count;
}
if(hasActiveProgress)
}
return computationFinished;
}
bool
atomExport::setUpAnimLayers(
MSelectionList &sList,atomAnimLayers &animLayers, std::vector<atomNodeWithAnimLayers *> &nodesWithAnimLayers,
std::set<std::string> &attrStrings, atomTemplateReader &templateReader)
{
unsigned int numObjects = sList.
length();
nodesWithAnimLayers.resize(numObjects);
bool somethingIsAnimLayered = false;
for (unsigned int i = 0; i < numObjects; i++)
{
atomNodeWithAnimLayers *nodeWithLayer = NULL;
nodesWithAnimLayers[i] = nodeWithLayer;
{
if(templateReader.findNode(name)== false)
{
continue;
}
}
continue;
}
if(templateReader.findNode(name)== false)
{
continue;
}
}
{
unsigned int numPlugs = animatablePlugs.
length();
for (unsigned int k = 0; k < numPlugs; k++)
{
MPlug plug = animatablePlugs[k];
if(MAnimUtil::findAnimationLayers(plug,layers,plugs) && layers.
length() > 0)
{
bool layerAdded = animLayers.addAnimLayers(layers);
if(layerAdded)
{
if(nodeWithLayer == NULL)
nodeWithLayer = new atomNodeWithAnimLayers();
nodeWithLayer->addPlugWithLayer(plug,layers,plugs);
}
somethingIsAnimLayered = somethingIsAnimLayered == false ? layerAdded : true;
}
}
nodesWithAnimLayers[i] = nodeWithLayer;
}
}
return somethingIsAnimLayered;
}
{
MFnPlugin plugIn(obj, PLUGIN_COMPANY,
"1.0",
"Any");
stat = plugIn.registerFileTranslator("atomImport", "none",
atomImport::creator,
(char *)NULL,
(char *)animImportDefaultOptions,
true);
return stat;
}
stat = plugIn.registerFileTranslator("atomExport", "",
atomExport::creator,
(char *)NULL,
(char *)animExportDefaultOptions,
true);
return stat;
}
{
stat = plugIn.deregisterFileTranslator("atomImport");
return stat;
}
stat = plugIn.deregisterFileTranslator("atomExport");
return stat;
}