コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static SBScene LoadScene(string filePath, SBScene loadedScene)
        {
            DialogResult Result = DialogResult.OK;

            var settings = new IONET.ImportSettings();

            using (SBCustomDialog d = new SBCustomDialog(settings))
                Result = d.ShowDialog();

            if (Result == DialogResult.OK)
            {
                var ioModel = IONET.IOManager.LoadScene(filePath, settings);

                SBScene scene;
                if (loadedScene == null)
                {
                    SBConsole.WriteLine("No scene loaded, defaulted to Smash Ultimate scene");
                    scene = new SBSceneSSBH();

                    using (var dialog = new SBCustomDialog(SBSceneSSBH.NewImportSettings))
                        Result = dialog.ShowDialog();

                    if (Result == DialogResult.OK)
                    {
                        if (SBSceneSSBH.NewImportSettings.NUMATLB != null && SBSceneSSBH.NewImportSettings.NUMATLB != "")
                        {
                            MATL_Loader.Open(SBSceneSSBH.NewImportSettings.NUMATLB, scene);
                        }

                        if (SBSceneSSBH.NewImportSettings.NUSKTFile != null && SBSceneSSBH.NewImportSettings.NUSKTFile != "")
                        {
                            ioModel.Models[0].Skeleton = SKEL_Loader.Open(SBSceneSSBH.NewImportSettings.NUSKTFile, scene).ToIOSkeleton();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to import model");
                        return(null);
                    }
                }
                else
                {
                    scene = loadedScene;

                    using (var dialog = new SBCustomDialog(SBSceneSSBH.ImportSettings))
                        Result = dialog.ShowDialog();

                    if (Result == DialogResult.OK)
                    {
                        if (SBSceneSSBH.ImportSettings.UseExistingSkeleton)
                        {
                            ioModel.Models[0].Skeleton = ((SBSkeleton)scene.Skeleton).ToIOSkeleton();
                            //ioModel.ConvertToSkeleton((SBSkeleton)scene.Skeleton);
                            // ionet uses bone names so no need to convert bone mapping indices
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to import model");
                        return(null);
                    }
                }

                scene.FromIOModel(ioModel);
                return(scene);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: ssbucarlos/StudioSB
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static SBScene LoadScene(string filePath, SBScene loadedScene)
        {
            DialogResult Result = DialogResult.OK;

            var settings = new IONET.ImportSettings();

            using (SBCustomDialog d = new SBCustomDialog(settings))
                Result = d.ShowDialog();

            if (Result == DialogResult.OK)
            {
                IONET.Core.IOScene ioModel;
                try
                {
                    ioModel = IONET.IOManager.LoadScene(filePath, settings);
                }
                catch (ArgumentNullException e)
                {
                    throw new ArgumentNullException("This error is usually caused by missing textures. Make sure you can correctly preview your model with textures before exporting.\nOriginal Error Msg: \n" + e.Message, e);
                }
                catch (NullReferenceException e)
                {
                    throw new NullReferenceException("This error is usually caused by a not exporting the Skeleton along with the Meshes. \nOriginal Message: \n" + e.Message, e);
                }

                SBScene scene;
                if (loadedScene == null)
                {
                    SBConsole.WriteLine("No scene loaded, defaulted to Smash Ultimate scene");
                    scene = new SBSceneSSBH();

                    using (var dialog = new SBCustomDialog(SBSceneSSBH.NewImportSettings))
                        Result = dialog.ShowDialog();

                    if (Result == DialogResult.OK)
                    {
                        if (SBSceneSSBH.NewImportSettings.NumatbFile != null && SBSceneSSBH.NewImportSettings.NumatbFile != "")
                        {
                            MATL_Loader.Open(SBSceneSSBH.NewImportSettings.NumatbFile, scene);
                        }

                        if (SBSceneSSBH.NewImportSettings.NusktbFile != null && SBSceneSSBH.NewImportSettings.NusktbFile != "")
                        {
                            ioModel.Models[0].Skeleton = SKEL_Loader.Open(SBSceneSSBH.NewImportSettings.NusktbFile, scene).ToIOSkeleton();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to import model");
                        return(null);
                    }
                }
                else
                {
                    scene = loadedScene;

                    using (var dialog = new SBCustomDialog(SBSceneSSBH.ImportSettings))
                        Result = dialog.ShowDialog();

                    if (Result == DialogResult.OK)
                    {
                        if (SBSceneSSBH.ImportSettings.UseExistingSkeleton)
                        {
                            ioModel.Models[0].Skeleton = ((SBSkeleton)scene.Skeleton).ToIOSkeleton();
                            //ioModel.ConvertToSkeleton((SBSkeleton)scene.Skeleton);
                            // ionet uses bone names so no need to convert bone mapping indices
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to import model");
                        return(null);
                    }
                }

                scene.FromIOModel(ioModel);
                return(scene);
            }
            else
            {
                return(null);
            }
        }