Archive *DirectorEngine::openMainArchive(const Common::String movie) { delete _mainArchive; _mainArchive = createArchive(); if (!_mainArchive->openFile(movie)) error("Could not open '%s'", movie.c_str()); return _mainArchive; }
void DirectorEngine::loadSharedCastsFrom(Common::String filename) { Archive *shardcst = createArchive(); debugC(1, kDebugLoading, "Loading Shared cast '%s'", filename.c_str()); shardcst->openFile(filename); _sharedDIB = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedSTXT = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedSound = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedBMP = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; Score *castScore = new Score(this, shardcst); castScore->loadConfig(*shardcst->getResource(MKTAG('V','W','C','F'), 1024)); castScore->loadCastData(*shardcst->getResource(MKTAG('V','W','C','R'), 1024)); _sharedCasts = &castScore->_casts; Common::Array<uint16> dib = shardcst->getResourceIDList(MKTAG('D','I','B',' ')); if (dib.size() != 0) { debugC(3, kDebugLoading, "Loading %d DIBs", dib.size()); for (Common::Array<uint16>::iterator iterator = dib.begin(); iterator != dib.end(); ++iterator) { debugC(3, kDebugLoading, "Shared DIB %d", *iterator); _sharedDIB->setVal(*iterator, shardcst->getResource(MKTAG('D','I','B',' '), *iterator)); } } Common::Array<uint16> stxt = shardcst->getResourceIDList(MKTAG('S','T','X','T')); if (stxt.size() != 0) { debugC(3, kDebugLoading, "Loading %d STXTs", stxt.size()); for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { debugC(3, kDebugLoading, "Shared STXT %d", *iterator); _sharedSTXT->setVal(*iterator, shardcst->getResource(MKTAG('S','T','X','T'), *iterator)); } } Common::Array<uint16> bmp = shardcst->getResourceIDList(MKTAG('B','I','T','D')); if (bmp.size() != 0) { debugC(3, kDebugLoading, "Loading %d BITDs", bmp.size()); for (Common::Array<uint16>::iterator iterator = bmp.begin(); iterator != bmp.end(); ++iterator) { _sharedBMP->setVal(*iterator, shardcst->getResource(MKTAG('B','I','T','D'), *iterator)); } } Common::Array<uint16> sound = shardcst->getResourceIDList(MKTAG('S','N','D',' ')); if (stxt.size() != 0) { debugC(3, kDebugLoading, "Loading %d SNDs", sound.size()); for (Common::Array<uint16>::iterator iterator = sound.begin(); iterator != sound.end(); ++iterator) { _sharedSound->setVal(*iterator, shardcst->getResource(MKTAG('S','N','D',' '), *iterator)); } } }
/** \param file File handle to check. \return Pointer to newly created archive, or 0 upon error. */ IFileArchive* CArchiveLoaderZIP::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const { IFileArchive *archive = 0; io::IReadFile* file = FileSystem->createAndOpenFile(filename); if (file) { archive = createArchive(file, ignoreCase, ignorePaths); file->drop(); } return archive; }
Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Common::String &folder) { Common::FSNode directory(folder); Common::FSList movies; const char *sharedMMMname; if (getPlatform() == Common::kPlatformWindows) sharedMMMname = "SHARDCST.MMM"; else sharedMMMname = "Shared Cast*"; Common::HashMap<Common::String, Score *> *nameMap = new Common::HashMap<Common::String, Score *>(); if (!directory.getChildren(movies, Common::FSNode::kListFilesOnly)) return nameMap; if (!movies.empty()) { for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) { debugC(2, kDebugLoading, "File: %s", i->getName().c_str()); if (Common::matchString(i->getName().c_str(), sharedMMMname, true)) { _sharedCastFile = i->getName(); continue; } Archive *arc = createArchive(); warning("name: %s", i->getName().c_str()); arc->openFile(i->getName()); Score *sc = new Score(this, arc); nameMap->setVal(sc->getMacName(), sc); debugC(2, kDebugLoading, "Movie name: \"%s\"", sc->getMacName().c_str()); } } return nameMap; }
MStatus AlembicWriteJob::PreProcess() { ESS_PROFILE_SCOPE("AlembicWriteJob::PreProcess"); // check filenames if (mFileName.length() == 0) { MGlobal::displayError("[ExocortexAlembic] No filename specified."); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: no filename specified"); return MStatus::kInvalidParameter; } // check objects if (mSelection.length() == 0) { MGlobal::displayError("[ExocortexAlembic] No objects specified."); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: no objects specified"); return MStatus::kInvalidParameter; } // check frames if (mFrames.size() == 0) { MGlobal::displayError("[ExocortexAlembic] No frames specified."); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: no frame specified"); return MStatus::kInvalidParameter; } // check if the file is currently in use if (getRefArchive(mFileName) > 0) { MGlobal::displayError("[ExocortexAlembic] Error writing to file '" + mFileName + "'. File currently in use."); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: no filename already in " "use"); return MStatus::kInvalidParameter; } // init archive (use a locally scoped archive) // TODO: determine how to access the current maya scene path // MString sceneFileName = "Exported from: // "+Application().GetActiveProject().GetActiveScene().GetParameterValue("FileName").GetAsText(); try { createArchive("Exported from Maya."); mTop = mArchive.getTop(); // get the frame rate mFrameRate = MTime(1.0, MTime::kSeconds).as(MTime::uiUnit()); const double timePerSample = 1.0 / mFrameRate; std::vector<AbcA::chrono_t> frames; for (LONG i = 0; i < mFrames.size(); i++) { frames.push_back(mFrames[i] * timePerSample); } // create the sampling if (frames.size() > 1) { const double timePerCycle = frames[frames.size() - 1] - frames[0]; AbcA::TimeSamplingType samplingType((Abc::uint32_t)frames.size(), timePerCycle); AbcA::TimeSampling sampling(samplingType, frames); mTs = mArchive.addTimeSampling(sampling); } else { AbcA::TimeSampling sampling(1.0, frames[0]); mTs = mArchive.addTimeSampling(sampling); } Abc::OBox3dProperty boxProp = AbcG::CreateOArchiveBounds(mArchive, mTs); MDagPath dagPath; { MItDag().getPath(dagPath); } SceneNodePtr exoSceneRoot = buildMayaSceneGraph(dagPath, this->replacer); const bool bFlattenHierarchy = GetOption("flattenHierarchy") == "1"; const bool bTransformCache = GetOption("transformCache") == "1"; const bool bSelectChildren = false; { std::map<std::string, bool> selectionMap; for (int i = 0; i < (int)mSelection.length(); ++i) { MFnDagNode dagNode(mSelection[i]); selectionMap[dagNode.fullPathName().asChar()] = true; } selectNodes(exoSceneRoot, selectionMap, !bFlattenHierarchy || bTransformCache, bSelectChildren, !bTransformCache, true); } // create object for each MProgressWindow::reserve(); MProgressWindow::setTitle("Alembic Export: Listing objects"); MProgressWindow::setInterruptable(true); MProgressWindow::setProgressRange(0, mSelection.length()); MProgressWindow::setProgress(0); MProgressWindow::startProgress(); int interrupt = 20; bool processStopped = false; std::deque<PreProcessStackElement> sceneStack; sceneStack.push_back(PreProcessStackElement(exoSceneRoot, mTop)); while (!sceneStack.empty()) { if (--interrupt == 0) { interrupt = 20; if (MProgressWindow::isCancelled()) { processStopped = true; break; } } PreProcessStackElement &sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); Abc::OObject oParent = sElement.oParent; Abc::OObject oNewParent; AlembicObjectPtr pNewObject; if (eNode->selected) { switch (eNode->type) { case SceneNode::SCENE_ROOT: break; case SceneNode::ITRANSFORM: case SceneNode::ETRANSFORM: pNewObject.reset(new AlembicXform(eNode, this, oParent)); break; case SceneNode::CAMERA: pNewObject.reset(new AlembicCamera(eNode, this, oParent)); break; case SceneNode::POLYMESH: pNewObject.reset(new AlembicPolyMesh(eNode, this, oParent)); break; case SceneNode::SUBD: pNewObject.reset(new AlembicSubD(eNode, this, oParent)); break; case SceneNode::CURVES: pNewObject.reset(new AlembicCurves(eNode, this, oParent)); break; case SceneNode::PARTICLES: pNewObject.reset(new AlembicPoints(eNode, this, oParent)); break; case SceneNode::HAIR: pNewObject.reset(new AlembicHair(eNode, this, oParent)); break; default: ESS_LOG_WARNING("Unknown type: not exporting " << eNode->name); } } if (pNewObject) { AddObject(pNewObject); oNewParent = oParent.getChild(eNode->name); } else { oNewParent = oParent; } if (oNewParent.valid()) { for (std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); ++it) { if (!bFlattenHierarchy || (bFlattenHierarchy && eNode->type == SceneNode::ETRANSFORM && isShapeNode((*it)->type))) { // If flattening the hierarchy, we want to attach each external // transform to its corresponding geometry node. // All internal transforms should be skipped. Geometry nodes will // never have children (If and XSI geonode is parented // to another geonode, each will be parented to its extracted // transform node, and one node will be parented to the // transform of the other. sceneStack.push_back(PreProcessStackElement(*it, oNewParent)); } else { // if we skip node A, we parent node A's children to the parent of A sceneStack.push_back(PreProcessStackElement(*it, oParent)); } } } //* else { ESS_LOG_ERROR("Do not have reference to parent."); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: do not have " "reference to parent"); return MS::kFailure; } //*/ } MProgressWindow::endProgress(); return processStopped ? MStatus::kEndOfFile : MStatus::kSuccess; } catch (AbcU::Exception &e) { this->forceCloseArchive(); MString exc(e.what()); MGlobal::displayError("[ExocortexAlembic] Error writing to file '" + mFileName + "' (" + exc + "). Do you still have it opened?"); MPxCommand::setResult( "Error caught in AlembicWriteJob::PreProcess: error writing file"); } return MS::kFailure; }
int main(int argc, char **argv) { GWEN_DB_NODE *db; const char *cmd; int rv; int err; GWEN_GUI *gui; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */ GWEN_ArgsType_Int, /* type */ "help", /* name */ 0, /* minnum */ 0, /* maxnum */ "h", /* short option */ "help", /* long option */ "Show this help screen", /* short description */ "Show this help screen" /* long description */ } }; err=GWEN_Init(); if (err) { fprintf(stderr, "Could not initialize Gwenhywfar.\n"); return 2; } gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); GWEN_Logger_Open(GSA_LOGDOMAIN, "gsa", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel(GSA_LOGDOMAIN, GWEN_LoggerLevel_Warning); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning); #ifdef GSA_IS_EXPERIMENTAL fprintf(stderr, "\n"); fprintf(stderr, "\n"); fprintf(stderr, "=================== WARNING ===================\n"); fprintf(stderr, "This tool is still EXPERIMENTAL !!!\n"); fprintf(stderr, "Please DON'T USE it with your data files !\n"); fprintf(stderr, "===============================================\n"); fprintf(stderr, "\n"); fprintf(stderr, "\n"); #endif db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM | GWEN_ARGS_MODE_STOP_AT_FREEPARAM, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments main\n"); return -1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); GWEN_Buffer_AppendString(ubuf, I18N("GWEN's Simple Archiver")); GWEN_Buffer_AppendString(ubuf, " (Gwenhywfar v" GWENHYWFAR_VERSION_FULL_STRING ")\n"); GWEN_Buffer_AppendString(ubuf, I18N("Usage: ")); GWEN_Buffer_AppendString(ubuf, argv[0]); GWEN_Buffer_AppendString(ubuf, I18N(" [GLOBAL OPTIONS] COMMAND " "[LOCAL OPTIONS]\n")); GWEN_Buffer_AppendString(ubuf, I18N("\nGlobal Options:\n")); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } GWEN_Buffer_AppendString(ubuf, I18N("\nCommands:\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" create:\n" " This command creates an archive file" "\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" add:\n" " Add files and folders to an archive file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" list:\n" " List files and folders in an archive file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" check:\n" " Check integrity of files and folders in an archive file\n\n")); fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv) { argc-=rv-1; argv+=rv-1; } cmd=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!cmd) { fprintf(stderr, "ERROR: Command needed.\n"); return 1; } if (strcasecmp(cmd, "create")==0) { rv=createArchive(db, argc, argv); } else if (strcasecmp(cmd, "add")==0) { rv=add2Archive(db, argc, argv); } else if (strcasecmp(cmd, "list")==0) { rv=listArchive(db, argc, argv); } else if (strcasecmp(cmd, "check")==0) { rv=checkArchive(db, argc, argv); } else if (strcasecmp(cmd, "extract")==0) { rv=extractArchive(db, argc, argv); } else if (strcasecmp(cmd, "sign")==0) { rv=signArchive(db, argc, argv); } else if (strcasecmp(cmd, "verify")==0) { rv=verifyArchive(db, argc, argv); } else if (strcasecmp(cmd, "mkkey")==0) { rv=mkArchiveKey(db, argc, argv); } else if (strcasecmp(cmd, "rfi")==0) { rv=releaseFillIn(db, argc, argv); } else { fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd); rv=1; } err=GWEN_Fini(); if (err) { fprintf(stderr, "WARNING: Could not deinitialize Gwenhywfar.\n"); } return rv; }