public override FILEERROR Save(BaseSceneSaver node, Filename name, BaseDocument doc, SCENEFILTER filterflags) { List<string> textureFiles; string fileName = name.GetString(); string sceneRoot = Path.GetDirectoryName(fileName); var root = new FusConverter().FuseefyScene(doc, sceneRoot, out textureFiles); var ser = new Serializer(); using (var file = File.Create(fileName)) { ser.Serialize(file, root); } return FILEERROR.FILEERROR_NONE; }
public override FILEERROR Save(BaseSceneSaver node, Filename name, BaseDocument doc, SCENEFILTER filterflags) { if (_newVersionExists) { if (!C4dApi.QuestionDialog( "A newer version of the FUSEE export plugin is available at fusee3d.org/c4dexporter.\n\n" + "Would you like to \n" + " - complete this export operation using the existing plugin [Yes]\n" + "or\n" + " - cancel this export operation and download the newer version [No]?")) { C4dApi.GeOpenHTML("http://fusee3d.org/c4dexporter"); return FILEERROR.FILEERROR_NONE; } _newVersionExists = false; // stop annoying the user... } List<string> textureFiles; string htmlFilePath = name.GetString(); string htmlFileDir = Path.GetDirectoryName(htmlFilePath); string sceneRoot = Path.Combine(htmlFileDir, "Assets"); string fuseePlayerDir = Path.Combine(GetThisPluginPath(), "Viewer"); DirCopy.DirectoryCopy(fuseePlayerDir, htmlFileDir, true, true); string origHtmlFilePath = Path.Combine(htmlFileDir, "SceneViewer.html"); if (File.Exists(htmlFilePath)) File.Delete(htmlFilePath); File.Move(origHtmlFilePath, htmlFilePath); string sceneFileDir = Path.Combine(htmlFileDir, "Assets"); string sceneFilePath = Path.Combine(sceneFileDir, "Model.fus"); var root = new FusConverter().FuseefyScene(doc, sceneFileDir, out textureFiles); var ser = new Serializer(); using (var file = File.Create(sceneFilePath)) { ser.Serialize(file, root); } for (int i = 0; i < textureFiles.Count; i++) { textureFiles[i] = Path.Combine("Assets", textureFiles[i]); } if (textureFiles != null) CreateAssetManifest(htmlFileDir, textureFiles); StartServer(htmlFileDir); C4dApi.GeOpenHTML("http://localhost:4655/" + Path.GetFileName(htmlFilePath)); return FILEERROR.FILEERROR_NONE; }