private void btnExportModel_Click(object sender, EventArgs e) { List <int> parts = new List <int>(); foreach (TreeNode parent in tvRegions.Nodes) { if (!parent.Checked) { continue; } foreach (TreeNode child in parent.Nodes) { if (!child.Checked) { continue; } if (cache != null) { parts.Add((child.Tag as render_model.Region.Permutation).PieceIndex); } else { parts.Add(atpl.Objects.IndexOf(child.Tag as Node)); } } } var sfd = new SaveFileDialog() { Filter = "EMF Files|*.emf|OBJ Files|*.obj|AMF Files|*.amf|JMS Files|*.jms", FilterIndex = (int)DefaultModeFormat + 1, FileName = (tag != null) ? tag.Filename.Substring(tag.Filename.LastIndexOf("\\") + 1) : atpl.Name }; if (sfd.ShowDialog() != DialogResult.OK) { return; } try { var format = (ModelFormat)(sfd.FilterIndex - 1); if (cache != null) { ModelExtractor.SaveModelParts(sfd.FileName, cache, mode, format, parts, false); TagExtracted(this, tag); } else { ModelFunctions.WriteAMF(sfd.FileName, pak, atpl, parts); TagExtracted(this, item); } } catch (Exception ex) { ErrorExtracting(this, (tag != null) ? (object)tag : (object)item, ex); } }
/// <summary> /// Saves selected pieces of the model from a scenario_structure_bsp tag to disk. /// </summary> /// <param name="Filename">The full path and filename to save to.</param> /// <param name="Cache">The CacheFile containing the scenario_structure_bsp tag.</param> /// <param name="Tag">The scenario_structure_bsp tag.</param> /// <param name="Format">The format to save the model in.</param> /// <param name="ClusterIndices">A List containing the indices of the scenario_structure_bsp.Clusters to save.</param> /// <param name="InstanceIndices">A List containing the indices of the scenario_structure_bsp.GeomInstances to save.</param> public static void SaveBSPParts(string Filename, CacheBase Cache, scenario_structure_bsp BSP, ModelFormat Format, List<int> ClusterIndices, List<int> InstanceIndices) { switch (Format) { case ModelFormat.OBJ: ModelFunctions.WriteOBJ(Filename, Cache, BSP, ClusterIndices, InstanceIndices); break; case ModelFormat.EMF: ModelFunctions.WriteEMF3(Filename, Cache, BSP, ClusterIndices, InstanceIndices); break; default: ModelFunctions.WriteAMF(Filename, Cache, BSP, ClusterIndices, InstanceIndices); break; } }
/// <summary> /// Saves selected pieces of the model from a render_model tag to disk. /// </summary> /// <param name="Filename">The full path and filename to save to.</param> /// <param name="Cache">The CacheFile containing the render_model tag.</param> /// <param name="Tag">The render_model tag.</param> /// <param name="Format">The format to save the model in.</param> /// <param name="SplitMeshes">Whether to split the pieces into individual submeshes. Only applies when saving in EMF format.</param> /// <param name="PartIndices">A List containing the indices of the render_model.ModelParts to save.</param> public static void SaveModelParts(string Filename, CacheBase Cache, render_model Model, ModelFormat Format, List <int> PartIndices, bool SplitMeshes) { switch (Format) { case ModelFormat.EMF: ModelFunctions.WriteEMF3(Filename, Cache, Model, SplitMeshes, PartIndices); break; case ModelFormat.JMS: ModelFunctions.WriteJMS(Filename, Cache, Model, PartIndices); break; case ModelFormat.OBJ: ModelFunctions.WriteOBJ(Filename, Cache, Model, PartIndices); break; case ModelFormat.AMF: ModelFunctions.WriteAMF(Filename, Cache, Model, PartIndices); break; } }
private void btnExportBSP_Click(object sender, EventArgs e) { var clusts = new List <int>(); var igs = new List <int>(); foreach (TreeNode pnode in tvRegions.Nodes) { if (!pnode.Checked) { continue; } foreach (TreeNode cnode in pnode.Nodes) { if (!cnode.Checked) { continue; } if (cnode.Tag is scenario_structure_bsp.Cluster) { var cluster = cnode.Tag as scenario_structure_bsp.Cluster; clusts.Add(sbsp.Clusters.IndexOf(cluster)); } else if (cnode.Tag is scenario_structure_bsp.InstancedGeometry) { var ig = cnode.Tag as scenario_structure_bsp.InstancedGeometry; igs.Add(sbsp.GeomInstances.IndexOf(ig)); } else if (cnode.Tag is Node) { var obj = cnode.Tag as Node; clusts.Add(atpl.Objects.IndexOf(obj)); } } } var sfd = new SaveFileDialog() { Filter = "EMF Files|*.emf|OBJ Files|*.obj|AMF Files|*.amf", FilterIndex = (int)DefaultModeFormat + 1, FileName = (tag != null) ? tag.Filename.Substring(tag.Filename.LastIndexOf("\\") + 1) : atpl.Name }; if (sfd.ShowDialog() != DialogResult.OK) { return; } try { var format = (ModelFormat)(sfd.FilterIndex - 1); if (cache != null) { BSPExtractor.SaveBSPParts(sfd.FileName, cache, sbsp, format, clusts, igs); TagExtracted(this, tag); } else { ModelFunctions.WriteAMF(sfd.FileName, pak, atpl, clusts); TagExtracted(this, item); } } catch (Exception ex) { ErrorExtracting(this, (tag != null) ? (object)tag : (object)item, ex); } }