public GLTFExporter(GLTFRoot gltf, IMaterialExporter materialExporter, IMeshExporter meshExporter, IAnimationExporter animationExporter) { this.gltf = gltf; _materialExporter = materialExporter ?? new MaterialExporter(); _meshExporter = meshExporter ?? new MeshExporter(); _animationExporter = animationExporter ?? new AnimationExporter(); this.gltf.extensionsUsed.AddRange(extensionUsed); this.gltf.asset = new GLTFAsset { generator = "GLTFumaExporter", version = "2.0", }; }
/// <summary> /// Add a new Importer /// </summary> private static void AddExporter(ExportType key, IMeshExporter exporter) { AvailableExporters.Add(key, exporter); ExporterTypes.Add(key.ToString(), key); }
// export selected morph : // search for base mesh and applies selected morph deformation to it and to selected skeleton and exports the result. private void exportMorphToolStripMenuItem_Click(object sender, EventArgs e) { if (rawEbxBuffer != null && rawResBuffer != null) { string morphName = Path.GetFileName(currPath); var morph = new MorphStaticExtended(new MemoryStream(rawResBuffer), new MemoryStream(rawEbxBuffer), morphName); ExportMeshSaveDialog emd = new ExportMeshSaveDialog(morph.LodCount, 100f, true); if (emd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; // look for preset Mesh DataInfo presetMeshRes = SearchItemRES(morph.PresetMesh); if (presetMeshRes != null) { byte[] meshData = main.Host.getDataBySha1(presetMeshRes.sha1); MeshAsset presetMeshAsset = new MeshAsset(new MemoryStream(meshData)); SkeletonAsset skeleton = null; int lod = emd.Lod; string sha1 = emd.Skeleton; if (sha1 != null) { var sebx = new EBX(new MemoryStream(main.Host.getDataBySha1(Helpers.HexStringToByteArray(sha1)))); skeleton = new SkeletonAsset(sebx); } float oScale = emd.ExportScale; bool bakeMorphToMesh = emd.BakeMorph; string ext = emd.Format; IMeshExporter exporter = MeshExporter.GetExporterByExtension(ext, skeleton); Cursor.Current = Cursors.Default; if (emd.AllLod) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Select folder where to save all LODS..."; if (fbd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; for (int i = 0; i < morph.LodCount; i++) { ChunkInfo lodChunk = SearchChunk(Helpers.ByteArrayToHexString(presetMeshAsset.lods[i].chunkID)); if (lodChunk != null) { byte[] rawChunkBuffer = main.Host.getDataBySha1(lodChunk.sha1); presetMeshAsset.lods[i].LoadVertexData(new MemoryStream(rawChunkBuffer)); } } exporter.ExportAllLodsWithMorph(presetMeshAsset, morph, fbd.SelectedPath, oScale, bakeMorphToMesh); MessageBox.Show("Done."); Cursor.Current = Cursors.Default; } } else { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save Morph as..."; sfd.Filter = "*" + ext + "|*" + ext; sfd.FileName = Path.GetFileName(currPath) + ext; if (sfd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; ChunkInfo lodChunk = SearchChunk(Helpers.ByteArrayToHexString(presetMeshAsset.lods[lod].chunkID)); if (lodChunk != null) { byte[] rawChunkBuffer = main.Host.getDataBySha1(lodChunk.sha1); presetMeshAsset.lods[lod].LoadVertexData(new MemoryStream(rawChunkBuffer)); exporter.ExportLodWithMorph(presetMeshAsset, lod, morph, sfd.FileName, oScale, bakeMorphToMesh); MessageBox.Show("Done."); Cursor.Current = Cursors.Default; } else { MessageBox.Show("Error : chunk for this lod was not found"); } } } Cursor.Current = Cursors.Default; } else { MessageBox.Show("Error : Res data corresponding to preset mesh " + morph.PresetMesh + " not found."); } } } }