Ejemplo n.º 1
0
        private void ScanAllAnimations()
        {
            //if (MODEL.IS_PLAYER)
            //    return; //todo
            //lock (_lock_AdditiveOverlays)
            //{
            //    _additiveBlendOverlays = new List<NewHavokAnimation>();
            //    _additiveBlendOverlayNames = new List<string>();
            //}


            List <string> allAnimNames = new List <string>();

            lock (_lock_animDict)
            {
                foreach (var kvp in animHKXsToLoad)
                {
                    allAnimNames.Add(kvp.Key);
                }
            }

            LoadingTaskMan.DoLoadingTaskSynchronous("ScanningAllAnimations", "Loading animations...", prog =>
            {
                for (int i = 0; i < allAnimNames.Count; i++)
                {
                    prog?.Report(1.0 * i / allAnimNames.Count);
                    CurrentAnimationName = allAnimNames[i];
                }
                CurrentAnimationName = null;
                prog?.Report(1.0);
            });
        }
Ejemplo n.º 2
0
        public static Model LoadObject(string id)
        {
            Model obj = null;

            LoadingTaskMan.DoLoadingTaskSynchronous($"LOAD_OBJ_{id}", $"Loading object {id}...", progress =>
            {
                if (GameType == GameTypes.DS3)
                {
                    var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx");

                    obj = new Model(progress, id, chrbnd, 0, null, null);
                }
                else if (GameType == GameTypes.DS1)
                {
                    var chrbnd = BND3.Read($@"{InterrootPath}\obj\{id}.objbnd");

                    obj = new Model(progress, id, chrbnd, 0, null, null);
                }
                else if (GameType == GameTypes.DS1R)
                {
                    var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx");

                    obj = new Model(progress, id, chrbnd, 0, null, null);
                }
                else if (GameType == GameTypes.BB)
                {
                    var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx");

                    obj = new Model(progress, id, chrbnd, 0, null, null);
                }

                Scene.AddModel(obj);

                var texturesToLoad = obj.MainMesh.GetAllTexNamesToLoad();

                LoadingTaskMan.DoLoadingTask($"LOAD_OBJ_{id}_TEX",
                                             "Loading additional object textures...", innerProgress =>
                {
                    if (GameType == GameTypes.DS1)
                    {
                        foreach (var tex in texturesToLoad)
                        {
                            TexturePool.AddTpfFromPath($@"{InterrootPath}\map\tx\{tex}.tpf");
                        }
                    }
                    else if (GameType == GameTypes.DS3)
                    {
                        int objGroup = int.Parse(id.Substring(1)) / 1_0000;
                        var tpfBnds  = System.IO.Directory.GetFiles($@"{InterrootPath}\map\m{objGroup:D2}", "*.tpfbhd");
                        foreach (var t in tpfBnds)
                        {
                            TexturePool.AddSpecificTexturesFromBinder(t, texturesToLoad, directEntryNameMatch: true);
                        }
                    }
                    obj.MainMesh.TextureReloadQueued = true;
                });
            });

            return(obj);
        }
Ejemplo n.º 3
0
        //public enum MapModelSearchType
        //{
        //    CHR,
        //    OBJ,
        //    MAP
        //}
        //public static string GetMapThatModelIsIn(string modelName, MapModelSearchType searchType)
        //{
        //    if (GameType == GameTypes.DS3)
        //    {
        //        foreach (var msbName in System.IO.Directory.GetFiles(GetInterrootPath($@"map\MapStudio", "*.msb.dcx")))
        //        {
        //            var shortMsbName = Utils.GetShortIngameFileName(msbName);
        //            var msb = MSB3.Read(msbName);

        //            if (searchType == MapModelSearchType.CHR)
        //            {
        //                foreach (var m in msb.Models.Enemies)
        //                    if (m.Name == modelName)
        //                        return shortMsbName;
        //            }
        //            else if (searchType == MapModelSearchType.OBJ)
        //            {
        //                foreach (var m in msb.Models.Objects)
        //                    if (m.Name == modelName)
        //                        return shortMsbName;
        //            }
        //            else if (searchType == MapModelSearchType.MAP)
        //            {
        //                foreach (var m in msb.Models.MapPieces)
        //                    if (m.Name == modelName)
        //                        return shortMsbName;
        //            }
        //        }
        //    }
        //}


        public static void LoadSystex()
        {
            LoadingTaskMan.DoLoadingTask("LoadSystex", "Loading SYSTEX textures...", progress =>
            {
                if (GameType == GameTypes.DS1)
                {
                    TexturePool.AddTpfsFromPaths(new List <string>
                    {
                        GetInterrootPath($@"other\SYSTEX_TEX.tpf"),
                        GetInterrootPath($@"other\envlight.tpf"),
                        GetInterrootPath($@"other\lensflare.tpf"),
                    }, progress);
                }
                else if (GameType == GameTypes.DS1R)
                {
                    TexturePool.AddTpfsFromPaths(new List <string>
                    {
                        GetInterrootPath($@"other\SYSTEX_TEX.tpf.dcx"),
                        GetInterrootPath($@"other\envlight.tpf.dcx"),
                        GetInterrootPath($@"other\lensflare.tpf.dcx"),
                    }, progress);
                }
                else if (GameType == GameTypes.DS3)
                {
                    TexturePool.AddTpfsFromPaths(new List <string>
                    {
                        GetInterrootPath($@"other\systex.tpf.dcx"),
                        GetInterrootPath($@"other\bloodtex.tpf.dcx"),
                        GetInterrootPath($@"other\decaltex.tpf.dcx"),
                        GetInterrootPath($@"other\sysenvtex.tpf.dcx"),
                        GetInterrootPath($@"parts\common_body.tpf.dcx"),
                    }, progress);
                }
                else if (GameType == GameTypes.BB)
                {
                    // TODO: completely confirm these because I just
                    // copied them from a BB network test file list.
                    TexturePool.AddTpfsFromPaths(new List <string>
                    {
                        GetInterrootPath($@"other\SYSTEX.tpf.dcx"),
                        GetInterrootPath($@"other\decalTex.tpf.dcx"),
                        GetInterrootPath($@"other\bloodTex.tpf.dcx"),
                    }, progress);
                }
                else if (GameType == GameTypes.SDT)
                {
                    TexturePool.AddTpfsFromPaths(new List <string>
                    {
                        GetInterrootPath($@"other\systex.tpf.dcx"),
                        GetInterrootPath($@"other\maptex.tpf.dcx"),
                        GetInterrootPath($@"other\decaltex.tpf.dcx"),
                        GetInterrootPath($@"parts\common_body.tpf.dcx"),
                    }, progress);
                }
            });
        }
Ejemplo n.º 4
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (!(GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1 || GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R || GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS3))
            {
                ImguiOSD.DialogManager.DialogOK("Not Supported", "Only supported on DS1 PTDE, DS1R, and DS3 for now.");
                return;
            }

            LoadingTaskMan.DoLoadingTask("SoulsAssetPipeline_AnimFBXImport", "Importing Animation To Current...", prog =>
            {
                Invoke(new Action(() =>
                {
                    buttonImport.Enabled           = false;
                    buttonImportToLooseHKX.Enabled = false;
                }));

                try
                {
                    var finalHkxDataToImport = ImportAnimToHKX();

                    MainScreen.FileContainer.AddNewHKX(Utils.GetFileNameWithoutAnyExtensions(Scene.MainModel.AnimContainer.CurrentAnimationName), finalHkxDataToImport, out byte[] dataForAnimContainer);
                    MainScreen.Graph.ViewportInteractor.CurrentModel.AnimContainer.AddNewHKXToLoad(Scene.MainModel.AnimContainer.CurrentAnimationName, dataForAnimContainer);

                    MainScreen.ReselectCurrentAnimation();
                    MainScreen.HardReset();

                    Invoke(new Action(() =>
                    {
                        Main.WinForm.Focus();
                    }));
                }
                catch (Exception ex)
                {
                    ImguiOSD.DialogManager.DialogOK("Import Failed", $"Failed to import animation. Error below:\n\n{ex}");
                }
                finally
                {
                    Invoke(new Action(() =>
                    {
                        buttonImport.Enabled           = true;
                        buttonImportToLooseHKX.Enabled = true;
                    }));
                }
            }, disableProgressBarByDefault: true, isUnimportant: true);
        }
Ejemplo n.º 5
0
        private void buttonSaveImportedData_Click(object sender, EventArgs e)
        {
            if (DoSaveImport == null)
            {
                System.Windows.Forms.MessageBox.Show("Nothing to save.");
            }
            else
            {
                GameDataManager.CreateCharacterModelBackup(Scene.MainModel.Name);

                LoadingTaskMan.DoLoadingTask("SapFlver2SaveImportedData", "Saving imported model and textures...", prog =>
                {
                    for (int i = 0; i < DoSaveImport.Count; i++)
                    {
                        DoSaveImport[i]?.Invoke();
                        prog?.Report(1.0 * (i + 1) / DoSaveImport.Count);
                    }

                    System.Windows.Forms.MessageBox.Show("Saved file.");
                }, isUnimportant: true);
            }
        }
        private void PopulateAdditiveBlendOverlays()
        {
            //if (MODEL.IS_PLAYER)
            //    return; //todo

            lock (_lock_AdditiveOverlays)
            {
                _additiveBlendOverlays = new List <NewHavokAnimation>();
                List <string> allAnimNames = new List <string>();
                lock (_lock_animDict)
                {
                    foreach (var kvp in animHKXsToLoad)
                    {
                        allAnimNames.Add(kvp.Key);
                    }
                }

                LoadingTaskMan.DoLoadingTaskSynchronous("ScanningAllAnimations", "Loading animations...", prog =>
                {
                    for (int i = 0; i < allAnimNames.Count; i++)
                    {
                        prog?.Report(1.0 * i / allAnimNames.Count);
                        CurrentAnimationName = allAnimNames[i];
                        if (CurrentAnimation != null)
                        {
                            if (CurrentAnimation.IsAdditiveBlend)
                            {
                                var clone    = NewHavokAnimation.Clone(CurrentAnimation);
                                clone.Weight = -1;
                                _additiveBlendOverlays.Add(clone);
                            }
                        }
                    }
                    CurrentAnimationName = null;
                    prog?.Report(1.0);
                });
            }
        }
Ejemplo n.º 7
0
        private void buttonImportDirectlyTest_Click(object sender, EventArgs e)
        {
            LoadingTaskMan.DoLoadingTask("SoulsAssetPipeline_AnimFBXImport", "Importing Animation To Current...", prog =>
            {
                Invoke(new Action(() =>
                {
                    buttonImport.Enabled           = false;
                    buttonImportToLooseHKX.Enabled = false;
                }));

                try
                {
                    var anim = ImportAnim();
                    Scene.MainModel.AnimContainer.AddNewAnimation(Scene.MainModel.AnimContainer.CurrentAnimationName, new NewHavokAnimation(anim, Scene.MainModel.AnimContainer.Skeleton, Scene.MainModel.AnimContainer));
                    MainScreen.ReselectCurrentAnimation();
                    MainScreen.HardReset();

                    Invoke(new Action(() =>
                    {
                        Main.WinForm.Focus();
                    }));
                }
                catch (Exception ex)
                {
                    ImguiOSD.DialogManager.DialogOK("Import Failed", $"Failed to import animation. Error below:\n\n{ex}");
                }
                finally
                {
                    Invoke(new Action(() =>
                    {
                        buttonImport.Enabled           = true;
                        buttonImportToLooseHKX.Enabled = true;
                    }));
                }
            }, disableProgressBarByDefault: true, isUnimportant: true);
        }
Ejemplo n.º 8
0
        public static Model LoadCharacter(string id)
        {
            Model chr = null;

            LoadingTaskMan.DoLoadingTaskSynchronous($"LOAD_CHR_{id}", $"Loading character {id}...", progress =>
            {
                if (GameType == GameTypes.DS3)
                {
                    var chrbnd          = BND4.Read($@"{InterrootPath}\chr\{id}.chrbnd.dcx");
                    IBinder texbnd      = null;
                    IBinder extraTexbnd = null;
                    IBinder anibnd      = null;

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.texbnd.dcx"))
                    {
                        texbnd = BND4.Read($@"{InterrootPath}\chr\{id}.texbnd.dcx");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.texbnd.dcx"))
                    {
                        extraTexbnd = BND4.Read($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.texbnd.dcx");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.anibnd.dcx"))
                    {
                        anibnd = BND4.Read($@"{InterrootPath}\chr\{id}.anibnd.dcx");
                    }

                    chr = new Model(progress, id, chrbnd, 0, anibnd, texbnd,
                                    ignoreStaticTransforms: true, additionalTexbnd: extraTexbnd);
                }
                else if (GameType == GameTypes.DS1)
                {
                    var chrbnd          = BND3.Read($@"{InterrootPath}\chr\{id}.chrbnd");
                    IBinder anibnd      = null;
                    IBinder texbnd      = null;
                    IBinder extraTexbnd = null;

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.anibnd"))
                    {
                        anibnd = BND3.Read($@"{InterrootPath}\chr\{id}.anibnd");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd"))
                    {
                        extraTexbnd = BND3.Read($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.chrtpfbdt"))
                    {
                        var chrtpfbhd = chrbnd.Files.FirstOrDefault(fi => fi.Name.ToLower().EndsWith(".chrtpfbhd"));

                        if (chrtpfbhd != null)
                        {
                            texbnd = BXF3.Read(chrtpfbhd.Bytes, $@"{InterrootPath}\chr\{id}.chrtpfbdt");
                        }
                    }

                    chr = new Model(progress, id, chrbnd, 0, anibnd, texbnd,
                                    possibleLooseTpfFolder: $@"{InterrootPath}\chr\{id}\",
                                    ignoreStaticTransforms: true, additionalTexbnd: extraTexbnd);
                }
                else if (GameType == GameTypes.DS1R)
                {
                    var chrbnd          = BND3.Read($@"{InterrootPath}\chr\{id}.chrbnd.dcx");
                    IBinder anibnd      = null;
                    IBinder texbnd      = null;
                    IBinder extraTexbnd = null;

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.anibnd.dcx"))
                    {
                        anibnd = BND3.Read($@"{InterrootPath}\chr\{id}.anibnd.dcx");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd.dcx"))
                    {
                        extraTexbnd = BND3.Read($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd.dcx");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.chrtpfbdt"))
                    {
                        var chrtpfbhd = chrbnd.Files.FirstOrDefault(fi => fi.Name.ToLower().EndsWith(".chrtpfbhd"));

                        if (chrtpfbhd != null)
                        {
                            texbnd = BXF3.Read(chrtpfbhd.Bytes, $@"{InterrootPath}\chr\{id}.chrtpfbdt");
                        }
                    }

                    chr = new Model(progress, id, chrbnd, 0, anibnd, texbnd,
                                    possibleLooseTpfFolder: $@"{InterrootPath}\chr\{id}\",
                                    ignoreStaticTransforms: true, additionalTexbnd: extraTexbnd);
                }
                else if (GameType == GameTypes.BB)
                {
                    var chrbnd          = BND4.Read($@"{InterrootPath}\chr\{id}.chrbnd.dcx");
                    IBinder anibnd      = null;
                    IBinder extraTexbnd = null;

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id}.anibnd.dcx"))
                    {
                        anibnd = BND4.Read($@"{InterrootPath}\chr\{id}.anibnd.dcx");
                    }

                    if (System.IO.File.Exists($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd.dcx"))
                    {
                        extraTexbnd = BND4.Read($@"{InterrootPath}\chr\{id.Substring(0, 4)}9.chrbnd.dcx");
                    }

                    chr = new Model(progress, id, chrbnd, 0, anibnd, texbnd: null,
                                    additionalTpfNames: new List <string> {
                        $@"{InterrootPath}\chr\{id}_2.tpf.dcx"
                    },
                                    possibleLooseTpfFolder: $@"{InterrootPath}\chr\{id}\",
                                    ignoreStaticTransforms: true, additionalTexbnd: extraTexbnd);
                }

                Scene.AddModel(chr);
            });

            if (id == "c0000")
            {
                chr.IS_PLAYER = true;

                LoadingTaskMan.DoLoadingTask("c0000_ANIBNDs",
                                             "Loading additional player ANIBNDs...", progress =>
                {
                    string[] anibnds = System.IO.Directory.GetFiles($@"{InterrootPath}\chr",
                                                                    GameType == GameTypes.DS1 ? "c0000_*.anibnd" : "c0000_*.anibnd.dcx")
                                       .OrderBy(fn =>
                    {
                        var fnCheck = fn.ToLower();
                        if (fnCheck.Contains("lo"))
                        {
                            return(0);
                        }
                        else if (fnCheck.Contains("md"))
                        {
                            return(1);
                        }
                        else if (fnCheck.Contains("hi"))
                        {
                            return(2);
                        }
                        else
                        {
                            return(3);
                        }
                    }).ToArray();

                    for (int i = 0; i < anibnds.Length; i++)
                    {
                        IBinder anibnd = null;
                        if (BND3.Is(anibnds[i]))
                        {
                            anibnd = BND3.Read(anibnds[i]);
                        }
                        else
                        {
                            anibnd = BND4.Read(anibnds[i]);
                        }

                        chr.AnimContainer.LoadAdditionalANIBND(anibnd, null);

                        progress.Report(1.0 * i / anibnds.Length);
                    }

                    progress.Report(1);
                });
            }
            else
            {
                var additionalAnibnds = System.IO.Directory.GetFiles($@"{InterrootPath}\chr", $"{id}_*.anibnd*");

                if (additionalAnibnds.Length > 0)
                {
                    LoadingTaskMan.DoLoadingTask($"{id}_ANIBNDs",
                                                 "Loading additional character ANIBNDs...", progress =>
                    {
                        for (int i = 0; i < additionalAnibnds.Length; i++)
                        {
                            IBinder anibnd = null;
                            if (BND3.Is(additionalAnibnds[i]))
                            {
                                anibnd = BND3.Read(additionalAnibnds[i]);
                            }
                            else
                            {
                                anibnd = BND4.Read(additionalAnibnds[i]);
                            }

                            chr.AnimContainer.LoadAdditionalANIBND(anibnd, null);

                            progress.Report(1.0 * i / additionalAnibnds.Length);
                        }
                    });
                }
            }

            return(chr);
        }
Ejemplo n.º 9
0
        public Model(IProgress <double> loadingProgress, string name, IBinder chrbnd, int modelIndex,
                     IBinder anibnd, IBinder texbnd = null, List <string> additionalTpfNames = null,
                     string possibleLooseTpfFolder  = null, int baseDmyPolyID         = 0,
                     bool ignoreStaticTransforms    = false, IBinder additionalTexbnd = null)
            : this()
        {
            Name = name;
            List <BinderFile> flverFileEntries = new List <BinderFile>();

            List <TPF> tpfsUsed = new List <TPF>();

            if (additionalTpfNames != null)
            {
                foreach (var t in additionalTpfNames)
                {
                    if (File.Exists(t))
                    {
                        tpfsUsed.Add(TPF.Read(t));
                    }
                }
            }

            FLVER2 flver = null;

            foreach (var f in chrbnd.Files)
            {
                var nameCheck = f.Name.ToLower();
                if (flver == null && (nameCheck.EndsWith(".flver") || FLVER2.Is(f.Bytes)))
                {
                    if (nameCheck.EndsWith($"_{modelIndex}.flver") || modelIndex == 0)
                    {
                        flver = FLVER2.Read(f.Bytes);
                    }
                }
                else if (nameCheck.EndsWith(".tpf") || TPF.Is(f.Bytes))
                {
                    tpfsUsed.Add(TPF.Read(f.Bytes));
                }
                else if (anibnd == null && nameCheck.EndsWith(".anibnd"))
                {
                    if (nameCheck.EndsWith($"_{modelIndex}.anibnd") || modelIndex == 0)
                    {
                        if (BND3.Is(f.Bytes))
                        {
                            anibnd = BND3.Read(f.Bytes);
                        }
                        else
                        {
                            anibnd = BND4.Read(f.Bytes);
                        }
                    }
                }
            }

            if (flver == null)
            {
                throw new ArgumentException("No FLVERs found within CHRBND.");
            }

            LoadFLVER2(flver, useSecondUV: false, baseDmyPolyID, ignoreStaticTransforms);

            loadingProgress.Report(1.0 / 4.0);

            AnimContainer = new NewAnimationContainer(this);

            if (anibnd != null)
            {
                LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_ANIBND", $"Loading ANIBND for {Name}...", innerProg =>
                {
                    AnimContainer.LoadBaseANIBND(anibnd, innerProg);
                });
            }
            else
            {
                // This just messes up the model cuz they're already in
                // reference pose, whoops
                //Skeleton.ApplyBakedFlverReferencePose();
            }

            loadingProgress.Report(2.0 / 3.0);

            if (tpfsUsed.Count > 0)
            {
                LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_TPFs", $"Loading TPFs for {Name}...", innerProg =>
                {
                    for (int i = 0; i < tpfsUsed.Count; i++)
                    {
                        TexturePool.AddTpf(tpfsUsed[i]);
                        MainMesh.TextureReloadQueued = true;
                        innerProg.Report(1.0 * i / tpfsUsed.Count);
                    }
                    MainMesh.TextureReloadQueued = true;
                });
            }

            loadingProgress.Report(3.0 / 4.0);

            if (texbnd != null)
            {
                LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_TEXBND", $"Loading TEXBND for {Name}...", innerProg =>
                {
                    TexturePool.AddTextureBnd(texbnd, innerProg);
                    MainMesh.TextureReloadQueued = true;
                });
            }

            loadingProgress.Report(3.5 / 4.0);

            if (additionalTexbnd != null)
            {
                LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_AdditionalTEXBND",
                                                        $"Loading extra TEXBND for {Name}...", innerProg =>
                {
                    TexturePool.AddTextureBnd(additionalTexbnd, innerProg);
                    MainMesh.TextureReloadQueued = true;
                });
            }

            loadingProgress.Report(3.9 / 4.0);
            if (possibleLooseTpfFolder != null && Directory.Exists(possibleLooseTpfFolder))
            {
                TexturePool.AddTPFFolder(possibleLooseTpfFolder);
                MainMesh.TextureReloadQueued = true;
            }

            MainMesh.TextureReloadQueued = true;

            loadingProgress.Report(1.0);
        }
Ejemplo n.º 10
0
        private void buttonImportToLooseHKX_Click(object sender, EventArgs e)
        {
            if (!(GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1 || GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R || GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS3))
            {
                ImguiOSD.DialogManager.DialogOK("Not Supported", "Only supported on DS1 PTDE, DS1R, and DS3 for now.");
                return;
            }

            LoadingTaskMan.DoLoadingTask("SoulsAssetPipeline_AnimFBXImport", "Importing Animation To Current...", prog =>
            {
                Invoke(new Action(() =>
                {
                    buttonImport.Enabled           = false;
                    buttonImportToLooseHKX.Enabled = false;
                }));

                try
                {
                    var finalHkxDataToImport = ImportAnimToHKX();

                    var dlg = new SaveFileDialog()
                    {
                        Filter = "Havok Animation File (*.HKX)|*.HKX",
                        Title  = "Save Havok Animation File",
                    };

                    if (!string.IsNullOrWhiteSpace(ImportConfig.AssetPath))
                    {
                        string potentialDefaultDir = Path.GetDirectoryName(ImportConfig.AssetPath);
                        if (Directory.Exists(potentialDefaultDir))
                        {
                            dlg.InitialDirectory = potentialDefaultDir;
                        }
                    }

                    if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1)
                    {
                        dlg.Filter = "HKX 2010 x32 - For DS1: PTDE (*.HKX)|*.HKX";
                        dlg.Title  = "Save Dark Souls: PTDE Format Animation File";
                    }
                    else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R)
                    {
                        dlg.Filter = "HKX 2015 x64 - For DS1R (*.HKX)|*.HKX";
                        dlg.Title  = "Save Dark Souls Remastered Format Animation File";
                    }
                    else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS3)
                    {
                        dlg.Filter = "HKX 2014 x64 - For DS3 (*.HKX)|*.HKX";
                        dlg.Title  = "Save Dark Souls III Format Animation File";
                    }
                    else
                    {
                        throw new NotImplementedException($"Current GameType not supported by the save loose HKX code: '{GameDataManager.GameType}'");
                    }


                    if (!string.IsNullOrWhiteSpace(ImportConfig.AssetPath))
                    {
                        dlg.InitialDirectory = Path.GetDirectoryName(ImportConfig.AssetPath);
                    }

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllBytes(dlg.FileName, finalHkxDataToImport);
                    }
                }
                catch (Exception ex)
                {
                    ImguiOSD.DialogManager.DialogOK("Import Failed", $"Failed to import animation. Error below:\n\n{ex}");
                }
                finally
                {
                    Invoke(new Action(() =>
                    {
                        buttonImport.Enabled           = true;
                        buttonImportToLooseHKX.Enabled = true;
                    }));
                }
            }, disableProgressBarByDefault: true, isUnimportant: true);
        }
Ejemplo n.º 11
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            LoadingTaskMan.DoLoadingTask("SoulsAssetPipeline_FLVER2Import", "Importing Model...", prog =>
            {
                SaveValuesToConfig();

                Main.SaveConfig();

                var cfg = new FLVER2Importer.FLVER2ImportSettings();

                cfg.Game        = GameDataManager.GameType;
                cfg.FlverHeader = Scene.MainModel.MainMesh.Flver2Header;

                cfg.AssetPath      = ImportConfig.AssetPath;
                cfg.ConvertFromZUp = ImportConfig.ConvertFromZUp;
                cfg.SceneScale     = ImportConfig.SceneScale;

                SoulsAssetPipeline.FLVERImporting.FLVER2Importer.ImportedFLVER2Model importedFlver = null;

                using (var importer = new SoulsAssetPipeline.FLVERImporting.FLVER2Importer())
                {
                    importedFlver = importer.ImportFBX(textBoxFBX.Text, cfg);
                }

                List <Action> doImport = new List <Action>();

#if DEBUG
                byte[] flver = importedFlver.Flver.Write();
                File.WriteAllBytes($"{Scene.MainModel.Name}.flver", flver);
#endif

                var importedAnimStudioModel = GameDataManager.LoadCharacter(Scene.MainModel.Name, importedFlver, doImport, ImportConfig);

                DoSaveImport = doImport;


                var oldMainModel = Scene.MainModel;

                lock (Scene._lock_ModelLoad_Draw)
                {
                    importedAnimStudioModel.NpcParam        = oldMainModel.NpcParam;
                    importedAnimStudioModel.DefaultDrawMask = oldMainModel.DefaultDrawMask;
                    importedAnimStudioModel.DrawMask        = oldMainModel.DrawMask;
                    importedAnimStudioModel.NpcParam.ApplyToNpcModel(importedAnimStudioModel);


                    Scene.Models.Remove(oldMainModel);
                    oldMainModel?.Dispose();
                    importedAnimStudioModel.AnimContainer.CurrentAnimationName = null;
                }

                Main.TAE_EDITOR.Graph.ViewportInteractor.InitializeForCurrentModel();
                Main.TAE_EDITOR.ReselectCurrentAnimation();
                Main.TAE_EDITOR.HardReset();

                Invoke(new Action(() =>
                {
                    buttonSaveImportedData.Enabled = true;
                }));

                //foreach (var tex in importedFlver.Textures)
                //{
                //    TexturePool.AddFetchDDS(tex.Value, tex.Key);
                //}

                //Dictionary<string, int> boneIndexRemap = new Dictionary<string, int>();

                //for (int i = 0; i < Scene.MainModel.Skeleton.FlverSkeleton.Count; i++)
                //{
                //    if (!boneIndexRemap.ContainsKey(Scene.MainModel.Skeleton.FlverSkeleton[i].Name))
                //        boneIndexRemap.Add(Scene.MainModel.Skeleton.FlverSkeleton[i].Name, i);
                //}

                //var oldMainMesh = Scene.MainModel.MainMesh;
                //var newMainMesh = new NewMesh(importedFlver.Flver, false, boneIndexRemap);

                //lock (Scene._lock_ModelLoad_Draw)
                //{
                //    Scene.MainModel.MainMesh = newMainMesh;
                //}

                //oldMainMesh?.Dispose();

                Scene.ForceTextureReloadImmediate();
            }, disableProgressBarByDefault: true, isUnimportant: true);

            Main.WinForm.Focus();
        }
Ejemplo n.º 12
0
 public void UpdateGuiLockout()
 {
     SetGuiLock(LoadingTaskMan.AnyTasksRunning());
 }