Ejemplo n.º 1
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                Title  = "Open Material...",
                Filter = "Hedgehog Engine Material (*.material)|*.material|All files (*.*)|*.*"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var mat = new GensMaterial();
                try
                {
                    mat.Load(ofd.FileName);
                }
                catch (Exception ex)
                {
                    GUI.ShowErrorBox($"ERROR: {ex.Message}");
                    return;
                }

                useMirageHeader = (mat.Header is MirageHeader);
                if (useMirageHeader)
                {
                    root = new SerializableNode(((MirageHeader)mat.Header).RootNode);
                }

                Material = mat;
                matPath  = ofd.FileName;
                UpdateTitle(Path.GetFileNameWithoutExtension(ofd.FileName));
                RefreshUI();
            }
        }
Ejemplo n.º 2
0
        public MaterialEditor(GensMaterial mat, string matName, string matPath)
        {
            Material = mat;
            InitializeComponent();

            this.matPath = matPath;
            UpdateTitle(matName);
            RefreshUI();
        }
Ejemplo n.º 3
0
        public static void SaveMaterial(string path, GensMaterial mat)
        {
            uint rootNodeType = mat.Header.RootNodeType;

            switch (Types.CurrentDataType)
            {
            case Types.DataTypes.Forces:
            case Types.DataTypes.LW:
                mat.Header = new MirageHeader();
                mat.Header.RootNodeType = rootNodeType;
                break;

            case Types.DataTypes.Gens:
            case Types.DataTypes.SU:
                mat.Header = new GensHeader();
                mat.Header.RootNodeType = rootNodeType;
                break;

            // TODO: Add Storybook Support
            case Types.DataTypes.Storybook:
                throw new NotImplementedException(
                          "Could not save, Storybook materials are not yet supported!");

            // TODO: Add Colors Support
            case Types.DataTypes.Colors:
                throw new NotImplementedException(
                          "Could not save, Colors materials are not yet supported!");

            // TODO: Add 06 Support
            case Types.DataTypes.S06:
                throw new NotImplementedException(
                          "Could not save, '06 materials are not yet supported!");

            // TODO: Add Heroes/Shadow Support
            case Types.DataTypes.Shadow:
            case Types.DataTypes.Heroes:
                throw new NotImplementedException(
                          "Could not save, Heroes/Shadow materials are not yet supported!");

            // TODO: Add SA2 Support
            case Types.DataTypes.SA2:
                throw new NotImplementedException(
                          "Could not save, SA2 materials are not yet supported!");

            default:
                throw new Exception(
                          "Could not save, game type has not been set!");
            }

            mat.Save(path, true);
        }
Ejemplo n.º 4
0
        public void NewMaterial()
        {
            Material = new GensMaterial();
            var mHeader = new MirageHeader()
            {
                RootNodeType = 3
            };

            mHeader.GenerateNodes(GensMaterial.MaterialMirageType);
            root = new SerializableNode(mHeader.RootNode);

            matPath = null;
            UpdateTitle("Untitled");
            RefreshUI();
        }
Ejemplo n.º 5
0
        // Methods
        public static void LoadDefaults()
        {
            // Load default model
            var    watch   = System.Diagnostics.Stopwatch.StartNew();
            string cubePth = Path.Combine(Program.StartupPath,
                                          Program.ResourcesPath, $"DefaultCube{Model.MDLExtension}");

            var mdl = new Model();

            mdl.Load(cubePth);

            // Load default texture
            string defaultTexPath = Path.Combine(Program.StartupPath,
                                                 Program.ResourcesPath, $"DefaultTexture{DDS.Extension}");

            Texture defaultTex;

            if (File.Exists(defaultTexPath))
            {
                defaultTex = new DDS();
                defaultTex.Load(defaultTexPath);
            }
            else
            {
                defaultTex = new Texture()
                {
                    Width       = 1,
                    Height      = 1,
                    PixelFormat = Texture.PixelFormats.RGB,
                    MipmapCount = 1,
                    ColorData   = new byte[][]
                    {
                        new byte[] { 255, 255, 255 }
                    }
                };
            }

            // Setup default texture/material/model
            DefaultTexture  = GenTexture(defaultTex);
            DefaultMaterial = new GensMaterial();
            DefaultCube     = new VPModel(mdl, true);

            watch.Stop();
            Console.WriteLine("Default assets init time: {0}",
                              watch.ElapsedMilliseconds);
        }
Ejemplo n.º 6
0
        public static GensMaterial LoadMaterial(string path,
                                                string name = null, bool nonEditable = true)
        {
            // Don't bother loading this material again if we've already loaded it
            if (string.IsNullOrEmpty(name))
            {
                name = Path.GetFileNameWithoutExtension(path);
            }

            if (Materials.ContainsKey(name))
            {
                return(Materials[name]);
            }

            // Figure out what type of material to use
            GensMaterial mat; // TODO: Set to generic material type once one is made

            switch (Types.CurrentDataType)
            {
            case Types.DataTypes.Forces:
            case Types.DataTypes.LW:
            case Types.DataTypes.Gens:
            case Types.DataTypes.SU:
                mat = new GensMaterial();
                break;

            // TODO: Add Storybook Support
            case Types.DataTypes.Storybook:
                throw new NotImplementedException(
                          "Could not load, Storybook materials are not yet supported!");

            // TODO: Add Colors Support
            case Types.DataTypes.Colors:
                throw new NotImplementedException(
                          "Could not load, Colors materials are not yet supported!");

            // TODO: Add 06 Support
            case Types.DataTypes.S06:
                throw new NotImplementedException(
                          "Could not load, '06 materials are not yet supported!");

            // TODO: Add Heroes/Shadow Support
            case Types.DataTypes.Shadow:
            case Types.DataTypes.Heroes:
                throw new NotImplementedException(
                          "Could not load, Heroes/Shadow materials are not yet supported!");

            // TODO: Add SA2 Support
            case Types.DataTypes.SA2:
                throw new NotImplementedException(
                          "Could not load, SA2 materials are not yet supported!");

            default:
                throw new Exception(
                          "Could not load, game type has not been set!");
            }

            // Material
            mat.Load(path);

            string dir    = Path.GetDirectoryName(path);
            var    resDir = ResourceDirectories.AddDirectory(dir);

            Materials.Add(name, new Asset <GensMaterial>(resDir, mat, nonEditable));

            // Textures
            foreach (var tex in mat.Texset.Textures)
            {
                GetTexture(tex.TextureName);
            }

            return(mat);
        }
Ejemplo n.º 7
0
 public void SaveMaterial(string path, GensMaterial mat)
 {
     path = FormatCacheDir(path);
     Data.SaveMaterial(path, mat);
 }