Ejemplo n.º 1
0
        private void menuSaveForClick(object sender, EventArgs e)
        {
            ToolStripMenuItem mi = (ToolStripMenuItem)sender;

            switch (mi.Text)
            {
            case "Carmageddon 2":
                sfdBrowse.Filter = "BRender ACT files (*.act)|*.act";

                if (sfdBrowse.ShowDialog() == DialogResult.OK)
                {
                    string directory = Path.GetDirectoryName(sfdBrowse.FileName) + "\\";
                    var    textures  = new HashSet <string>();
                    if (!Directory.Exists(directory + "tiffrgb"))
                    {
                        Directory.CreateDirectory(directory + "tiffrgb");
                    }

                    var ax = new ACTExporter();
                    ax.Export(SceneManager.Current.Models[0], sfdBrowse.FileName);

                    var dx = new DATExporter();
                    dx.Export(SceneManager.Current.Models[0], directory + Path.GetFileNameWithoutExtension(sfdBrowse.FileName) + ".dat");

                    var mx = new MATExporter();
                    mx.Export(SceneManager.Current.Materials, directory + Path.GetFileNameWithoutExtension(sfdBrowse.FileName) + ".mat");

                    foreach (var material in SceneManager.Current.Materials)
                    {
                        if (material.Texture.Name != null && textures.Add(material.Texture.Name))
                        {
                            var tx = new TIFExporter();
                            tx.Export(material.Texture, directory + "tiffrgb\\" + material.Texture.Name + ".tif");
                        }
                    }

                    SceneManager.Current.UpdateProgress(Path.GetFileName(sfdBrowse.FileName) + " saved successfully");
                }
                break;

            case "Carmageddon Reincarnation":
                sfdBrowse.Filter = "Stainless CNT files (*.cnt)|*.cnt";
                if (sfdBrowse.ShowDialog() == DialogResult.OK)
                {
                    var cx = new CNTExporter();
                    cx.Export(SceneManager.Current.Models[0], sfdBrowse.FileName);

                    var mx = new MDLExporter();
                    mx.Export(SceneManager.Current.Models[0], Path.GetDirectoryName(sfdBrowse.FileName) + "\\");
                }
                break;
            }
        }
Ejemplo n.º 2
0
        public static void SaveForCarmageddon2(string path)
        {
            string           directory = Path.GetDirectoryName(path);
            HashSet <string> textures  = new HashSet <string>();

            if (!Directory.Exists(Path.Combine(directory, "tiffrgb")))
            {
                Directory.CreateDirectory(Path.Combine(directory, "tiffrgb"));
            }

            ACTExporter ax = new ACTExporter();

            ax.Export(SceneManager.Current.Models[0], path);

            DATExporter dx = new DATExporter();

            dx.Export(SceneManager.Current.Models[0], Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(path)}.dat"));

            MATExporter mx = new MATExporter();

            mx.Export(SceneManager.Current.Materials, Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(path)}.mat"));

            foreach (Material material in SceneManager.Current.Materials)
            {
                if (material == null)
                {
                    continue;
                }

                if (material.Texture.Name != null && textures.Add(material.Texture.Name))
                {
                    TIFExporter tx = new TIFExporter();
                    tx.Export(material.Texture, Path.Combine(directory, "tiffrgb", $"{material.Texture.Name}.tif"));
                }
            }

            SceneManager.Current.UpdateProgress($"{Path.GetFileName(path)} saved successfully");
        }