void ExportManager::notifyEndDialog(Dialog* _sender, bool _result) { if (_result) { if (mOpenSaveFileDialog->getMode() == "Export") { RecentFilesManager::getInstance().setRecentFolder(mOpenSaveFileDialog->getCurrentFolder()); MyGUI::UString fileName = common::concatenatePath(mOpenSaveFileDialog->getCurrentFolder(), mOpenSaveFileDialog->getFileName()); exportSkin(fileName); } } mOpenSaveFileDialog->endModal(); }
/* ==================== DoExport ==================== */ int G3DAExport::DoExport(const TCHAR *name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options) { // clear the old data if(mRoot){delete mRoot, mRoot = NULL;} mNodeCount = 0; mSkins.clear(); // normalize the file path Str path = UnifySlashes(name); // get the export dir mPath = UnifySlashes(i->GetDir(APP_EXPORT_DIR)); mPath += '/'; if( !strstr( path.c_str(), mPath.c_str() ) ) { G3DAssert("The export path(%s) is illegal!",name); return 1; } // get the animation range Interval inter = i->GetAnimRange(); mTime = i->GetTime(); mStart = inter.Start(); mEnd = inter.End(); // recursive export all of the node exportNode(i->GetRootNode()); // export all of the skin for(int k = 0; k < mSkins.size(); k++) exportSkin(mSkins[k]); // recursive export all of the animation exportAnimation(mRoot); // check all of the nodes std::set<Str> names, duplicates; check(mRoot, names, duplicates); for(std::set<Str>::iterator it = duplicates.begin(); it != duplicates.end(); ++it) { G3DAssert( "Duplicate node name : %s", (*it).c_str() ); return 1; } #if 0 // write all of the data FILE *output = fopen(path.c_str(), "wb"); if(output==NULL) { G3DAssert("Fail to open the file : %s", path.c_str()); return 1; } // write count of the frame unsigned int frame_count = (mEnd-mStart)/GetTicksPerFrame()+1; fwrite( &frame_count, sizeof(unsigned int), 1, output ); // write number of the node fwrite( &mNodeCount, sizeof(unsigned int), 1, output ); // write count of the action unsigned int action_count = 0; fwrite( &action_count, sizeof(unsigned int), 1, output ); // write all of the node animation wirteAnimation(output,mRoot); // close file fclose(output); #else // write all of the data FILE *output = fopen(path.c_str(), "wb"); if(output==NULL) { G3DAssert("Fail to open the file : %s", path.c_str()); return 1; } // get the count of the frame unsigned int frame_count = (mEnd-mStart)/GetTicksPerFrame()+1; // begin to write the animation fprintf(output, "<animation>\n"); // begin to write the frame fprintf(output, "<frame count=\"%d\">\n", frame_count); // write all of the node frame wirteFrame(output,mRoot); // end to wirte the frame fprintf(output, "</frame>\n"); // end to wirte the animation fprintf(output, "</animation>\n"); // close file fclose(output); #endif // clear all of the data mSkins.clear(); if(mRoot){delete mRoot, mRoot = NULL;} return 1; }
bool SkeletalExporterBase::exportData(Runnable& r) { // Gather all the physique and skin nodes auto physiqueNodes = Vector<ExportNode>(); auto skinNodes = Vector<ExportNode>(); gather(ip->GetRootNode(), physiqueNodes, skinNodes); // Check that we got some nodes to export if (physiqueNodes.empty() && skinNodes.empty()) { LOG_ERROR_WITHOUT_CALLER << "Did not find any physiques or skins to export"; return false; } // Warn if both physiques and skins are found if (physiqueNodes.size() && skinNodes.size()) { LOG_WARNING_WITHOUT_CALLER << "Both Character Studio Physique and native ISkin nodes were found, ignoring ISkins"; skinNodes.clear(); } // Log the number of nodes found to export from if (physiqueNodes.size()) { LOG_INFO << "Found " << physiqueNodes.size() << " physique node" << (physiqueNodes.size() == 1 ? "" : "s"); // Go through physique nodes for (auto& physiqueNode : physiqueNodes) { auto result = true; r.beginTask("", 100.0f / float(physiqueNodes.size())); // Create a PhysiqueExport interface for the physique modifier auto phy = static_cast<IPhysiqueExport*>(physiqueNode.modifier->GetInterface(I_PHYINTERFACE)); if (phy) { // Create a ModContext export interface for this node of the physique modifier auto pcExport = static_cast<IPhyContextExport*>(phy->GetContextInterface(physiqueNode.node)); if (pcExport) { pcExport->ConvertToRigid(true); pcExport->AllowBlending(true); // Call physique export method for this physique result = exportPhysique(physiqueNode.node, phy, pcExport, physiqueNode.doExport); // Release export interface phy->ReleaseContextInterface(pcExport); } // Release the physique interface physiqueNode.modifier->ReleaseInterface(I_PHYINTERFACE, phy); } r.endTask(); if (!result) return false; } } else { LOG_INFO << "Found " << skinNodes.size() << " skin node" << (skinNodes.size() == 1 ? "" : "s") << " to export"; // Go through skin nodes for (auto& skinNode : skinNodes) { auto result = true; r.beginTask("", 100.0f / float(skinNodes.size())); auto skin = reinterpret_cast<ISkin*>(skinNode.modifier->GetInterface(I_SKIN)); if (skin) { auto skinContext = skin->GetContextInterface(skinNode.node); if (skinContext) { // Disable the skin modifier, storing its current enabled state auto isSkinModifierEnabled = (skinNode.modifier->IsEnabled() != 0); if (isSkinModifierEnabled) skinNode.modifier->DisableMod(); // Call skin export method for this skin result = exportSkin(skinNode.node, skin, skinContext, skinNode.doExport); // Restore the modifier's enabled state if (isSkinModifierEnabled) skinNode.modifier->EnableMod(); } // Release the I_SKIN interface skinNode.modifier->ReleaseInterface(I_SKIN, skin); } r.endTask(); if (!result) return false; } } return true; }