示例#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
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static SBScene LoadScene(string filePath, SBScene loadedScene)
        {
            IImportableModelType modelType = GetModelTypeFromPath(filePath);

            if (modelType == null)
            {
                return(null);
            }

            DialogResult Result = DialogResult.OK;

            if (modelType.Settings != null)
            {
                using (var dialog = new SBCustomDialog(modelType.Settings))
                    Result = dialog.ShowDialog();
            }

            if (Result == DialogResult.OK)
            {
                var ioModel = modelType.ImportIOModel(filePath);

                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.Skeleton = SKEL_Loader.Open(SBSceneSSBH.NewImportSettings.NUSKTFile, scene);
                        }
                    }
                    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.ConvertToSkeleton((SBSkeleton)scene.Skeleton);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to import model");
                        return(null);
                    }
                }

                scene.FromIOModel(ioModel);
                return(scene);
            }
            else
            {
                return(null);
            }
        }
示例#3
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)
            {
                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);
            }
        }