// -------------------------------------- ReferenceFile* ReferenceManager::processReferenceFile(const MString& filename) { ReferenceFile* file = new ReferenceFile(); file->filename = filename; mFiles.push_back(file); #if MAYA_API_VERSION >= 800 return file; // Versions 8.00 and 8.50 of Maya don't allow us to create references inside a plug-in. #elif MAYA_API_VERSION >= 600 // Get the original transformations for this file. // 1. Create a new reference MString tempFilename; MObject tempReferenceNode; { MString command = MString("file -r -type \"COLLADA importer\" -namespace \"_TEMP_EXP_NAMESPACE\" \"") + filename + "\";"; MGlobal::executeCommand(command, tempFilename); tempFilename = getLastReferenceFilename ( tempFilename ); MObject tempReferenceNode = getReferenceNode ( tempFilename ); MString tempNodeName = MFnDependencyNode(tempReferenceNode).name(); command = MString("file -loadReference \"") + tempNodeName + "\" \"" + tempFilename + "\";"; MGlobal::executeCommand(command); } // 2. Get the original transformations for the root transforms of the temporary reference object MDagPathArray tempRoots; MObjectArray subReferences; getRootObjects ( tempReferenceNode, tempRoots, subReferences ); uint tempRootCount = tempRoots.length(); for (uint j = 0; j < tempRootCount; ++j) { MFnTransform tempT(tempRoots[j]); file->originalTransformations.push_back( tempT.transformation() ); } // 3. Get the original node names. This will be used as the URL for export file->rootNames.setLength(tempRootCount); for (uint j = 0; j < tempRootCount; ++j) { MString& originalName = file->rootNames[j]; originalName = tempRoots[j].partialPathName(); originalName = originalName.substring ( originalName.index(':') + 1, originalName.length() ); } // 4. Cleanup: remove this reference MString command = MString("file -rr \"") + tempFilename + "\";"; MGlobal::executeCommand ( command ); #endif // MAYA >= 600 return file; }
ostream& operator<<(ostream&s, timeLength z) { timeLength tUser = z; int years = static_cast<int>(tUser.getI(timeUnit::year())); timeLength tempT(years,timeUnit::year()); tUser -= tempT; int days = static_cast<int>(tUser.getI(timeUnit::day())); tUser -= timeLength(days,timeUnit::day()); int hours = static_cast<int>(tUser.getI(timeUnit::hour())); tUser -= timeLength(hours,timeUnit::hour()); int mins = static_cast<int>(tUser.getI(timeUnit::minute())); tUser -= timeLength(mins,timeUnit::minute()); int secs = static_cast<int>(tUser.getI(timeUnit::sec())); tUser -= timeLength(secs,timeUnit::sec()); int ms = static_cast<int>(tUser.getI(timeUnit::ms())); tUser -= timeLength(ms,timeUnit::ms()); int us = static_cast<int>(tUser.getI(timeUnit::us())); tUser -= timeLength(us,timeUnit::us()); int ns = static_cast<int>(tUser.getI(timeUnit::ns())); bool prev = false, compact = false; char cSt[5] = ", "; // this is a hack for those that want to print the time compressed if(s.flags() & ostream::oct) { compact=true; s.flags(ostream::dec); } if(compact == true) strcpy(cSt,","); s << "["; if(z.get_ns() == 0) { s << "0 time"; } else { if(years!=0) { s << (prev? cSt:"") << years << " years"; prev=true; } if(days!=0) { s << (prev? cSt:"") << days << " days"; prev=true; } if(hours!=0) { s << (prev? cSt:"") << hours << " hours"; prev=true; } if(mins!=0) { s << (prev? cSt:"") << mins << " mins"; prev=true; } if(secs!=0) { s << (prev? cSt:"") << secs << " secs"; prev=true; } if(ms!=0) { s << (prev? cSt:"") << ms << " ms"; prev=true; } if(us!=0) { s << (prev? cSt:"") << us << " us"; prev=true; } if(ns!=0) { s << (prev? cSt:"") << ns << " ns"; prev=true; } } s << "]"; return s; }