コード例 #1
0
ファイル: TexturePool.cs プロジェクト: micvb123/DSAnimStudio
 public static void AddMapTextures(int area, List <string> textureNames)
 {
     if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1)
     {
         foreach (var t in textureNames)
         {
             if (fetches.ContainsKey(t))
             {
                 continue;
             }
             string tpfPath = GameDataManager.GetInterrootPath($@"map\tx\{t}.tpf");
             if (File.Exists(tpfPath))
             {
                 AddTpfFromPath(tpfPath);
             }
         }
     }
     else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R)
     {
         var bxfs = Directory.GetFiles(GameDataManager.GetInterrootPath($@"map\m{area:D2}", isDirectory: true), "*.tpfbhd");
         foreach (var b in bxfs)
         {
             AddSpecificTexturesFromBXF3(b, textureNames);
         }
     }
     else
     {
         throw new NotImplementedException("ONLY FOR DS1(R)");
     }
 }
コード例 #2
0
        public static Model LoadObject(string id)
        {
            Model obj = null;

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

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

                    obj = new Model(progress, id, chrbnd, 0, null, null);
                }
                else if (GameType == GameTypes.DS1R)
                {
                    var chrbnd = BND4.Read(GetInterrootPath($@"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(GetInterrootPath($@"map\tx\{tex}.tpf"));
                        }
                    }
                    else if (GameType == GameTypes.DS3 || GameType == GameTypes.SDT || GameType == GameTypes.BB)
                    {
                        int objGroup      = int.Parse(id.Substring(1)) / 1_0000;
                        string mapDirName = GetInterrootPath($@"map\m{objGroup:D2}");
                        var tpfBnds       = GameDataManager.GetInterrootFiles(mapDirName, "*.tpfbhd");
                        foreach (var t in tpfBnds)
                        {
                            TexturePool.AddSpecificTexturesFromBinder(t, texturesToLoad, directEntryNameMatch: true);
                        }
                    }
                    obj.MainMesh.TextureReloadQueued = true;
                });
            });

            return(obj);
        }
コード例 #3
0
 public static void Flush()
 {
     lock (_lock_pool)
     {
         foreach (var fetch in fetches)
         {
             fetch.Value.Dispose();
         }
         fetches.Clear();
         Failures.Clear();
     }
     GameDataManager.LoadSystex();
 }
コード例 #4
0
        private void ImportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var dialog = new OpenFileDialog()
                {
                    Filter = "JSON Files (*.json)|*.json",
                    Title  = "Import c0000 equipment from JSON file...",
                };

                var result = dialog.ShowDialog(this);

                if (result == DialogResult.OK || result == DialogResult.Yes)
                {
                    var jsonText = System.IO.File.ReadAllText(dialog.FileName);

                    var jsonThing = Newtonsoft.Json.JsonConvert.DeserializeObject <NewChrAsmCfgJson>(jsonText);

                    if (!GameDataManager.CheckGameTypeParamIDCompatibility(GameDataManager.GameType, jsonThing.GameType))
                    {
                        MessageBox.Show($"Cannot import equipment. " +
                                        $"Equipment IDs in file are for " +
                                        $"{GameDataManager.GameTypeNames[jsonThing.GameType]}, " +
                                        $"but the GameParam and text currently loaded are those " +
                                        $"of {GameDataManager.GameTypeNames[GameDataManager.GameType]}",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return;
                    }

                    jsonThing.WriteToChrAsm(ChrAsm);

                    WriteChrAsmToGUI();

                    SetEverythingDisabled(true);
                    ChrAsm.UpdateModels(isAsync: true, onCompleteAction: () =>
                    {
                        Invoke(new Action(() =>
                        {
                            SetEverythingDisabled(false);
                        }));
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error while importing equipment (please report):\n\n\n{ex}",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: TexturePool.cs プロジェクト: micvb123/DSAnimStudio
 public static void Flush()
 {
     lock (_lock_pool)
     {
         foreach (var fetch in fetches)
         {
             fetch.Value.Dispose();
         }
         fetches.Clear();
         Failures.Clear();
     }
     if (GameDataManager.GameType != SoulsAssetPipeline.SoulsGames.None)
     {
         GameDataManager.LoadSystex();
     }
 }
コード例 #6
0
ファイル: TexturePool.cs プロジェクト: micvb123/DSAnimStudio
        public static void AddInterrootTPFFolder(string folderPath, bool dcx = false, bool directDdsFetches = false)
        {
            var tpfs = GameDataManager.GetInterrootFiles(folderPath, dcx ? "*.tpf.dcx" : "*.tpf");

            foreach (var t in tpfs)
            {
                string shortName = Utils.GetShortIngameFileName(t).ToLower();
                if (directDdsFetches)
                {
                    foreach (var tex in TPF.Read(t).Textures)
                    {
                        AddFetchDDS(tex.Bytes, tex.Name);
                    }
                }
                else
                {
                    AddFetchTPF(TPF.Read(File.ReadAllBytes(t)), shortName);
                }
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
        //public static bool PlayEventInFEV(string fevFilePath, string eventName)
        //{
        //    //if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
        //    //   GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
        //    //   GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
        //    //   GameDataManager.GameType == GameDataManager.GameTypes.SDT))
        //    //{
        //    //    return false;
        //    //}

        //    var foundFev = LoadFEV(fevFilePath);
        //    if (!foundFev)
        //        return false;
        //    else
        //        return PlayEvent(eventName, null, null);
        //}

        /// <summary>
        /// Example "main" will return the full path ending like "Game/sound/fdp_main.fev" in DS3.
        /// </summary>
        /// <param name="fevNameAfterPrefix"></param>
        /// <returns></returns>
        private static string GetFevPathFromInterroot(string name, bool isDs1Dlc = false)
        {
            if (GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
                GameDataManager.GameType == GameDataManager.GameTypes.DS1R)
            {
                return(GameDataManager.GetInterrootPath($@"sound\{(isDs1Dlc ? "fdlc" : "frpg")}_{name}.fev"));
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.DS3)
            {
                return(GameDataManager.GetInterrootPath($@"sound\fdp_{name}.fev"));
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.BB)
            {
                return(GameDataManager.GetInterrootPath($@"sound_win\sprj_{name}.fev"));
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.SDT)
            {
                return(GameDataManager.GetInterrootPath($@"sound\{name}.fev"));
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
        public static Model LoadCharacter(string id)
        {
            Model chr = null;

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

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

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

                    if (GameType == GameTypes.SDT)
                    {
                        if (System.IO.File.Exists(GetInterrootPath($@"chr\{id}.anibnd.dcx.2010")))
                        {
                            anibnd = BND4.Read(GetInterrootPath($@"chr\{id}.anibnd.dcx.2010"));
                        }
                    }
                    else
                    {
                        if (System.IO.File.Exists(GetInterrootPath($@"chr\{id}.anibnd.dcx")))
                        {
                            anibnd = BND4.Read(GetInterrootPath($@"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(GetInterrootPath($@"chr\{id}.chrbnd"));
                    IBinder anibnd      = null;
                    IBinder texbnd      = null;
                    IBinder extraTexbnd = null;

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

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

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

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

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

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

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

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

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

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

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

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

                    chr = new Model(progress, id, chrbnd, 0, anibnd, texbnd: null,
                                    additionalTpfNames: new List <string> {
                        GetInterrootPath($@"chr\{id}_2.tpf.dcx")
                    },
                                    possibleLooseTpfFolder: $@"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 = GameDataManager.GetInterrootFiles($@"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;

                        string anibndName = anibnds[i];

                        if ((GameType == GameTypes.SDT || GameType == GameTypes.DS1R) && System.IO.File.Exists(anibnds[i] + ".2010"))
                        {
                            anibndName = anibnds[i] + ".2010";
                        }

                        if (BND3.Is(anibndName))
                        {
                            anibnd = BND3.Read(anibndName);
                        }
                        else
                        {
                            anibnd = BND4.Read(anibndName);
                        }

                        chr.AnimContainer.LoadAdditionalANIBND(anibnd, null);

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

                    progress.Report(1);

                    Scene.EnableModelDrawing2();
                });
            }
            else
            {
                var additionalAnibnds = GameDataManager.GetInterrootFiles($@"chr", $"{id}_*.anibnd*");

                if (additionalAnibnds.Count > 0)
                {
                    LoadingTaskMan.DoLoadingTask($"{id}_ANIBNDs",
                                                 "Loading additional character ANIBNDs...", progress =>
                    {
                        for (int i = 0; i < additionalAnibnds.Count; i++)
                        {
                            IBinder anibnd = null;

                            string anibndName = additionalAnibnds[i];

                            if ((GameType == GameTypes.SDT || GameType == GameTypes.DS1R) && System.IO.File.Exists(additionalAnibnds[i] + ".2010"))
                            {
                                anibndName = additionalAnibnds[i] + ".2010";
                            }

                            if (BND3.Is(anibndName))
                            {
                                anibnd = BND3.Read(anibndName);
                            }
                            else
                            {
                                anibnd = BND4.Read(anibndName);
                            }

                            chr.AnimContainer.LoadAdditionalANIBND(anibnd, null);

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

                        Scene.EnableModelDrawing2();
                    });
                }
            }

            return(chr);
        }
コード例 #10
0
ファイル: RemoManager.cs プロジェクト: micvb123/DSAnimStudio
        private static void LoadRemoHKX(byte[] hkxBytes, string animName)
        {
            Scene.DisableModelDrawing();
            Scene.DisableModelDrawing2();

            HKX.HKAAnimationBinding          hk_binding = null;
            HKX.HKASplineCompressedAnimation hk_anim    = null;
            HKX.HKASkeleton hk_skeleton = null;

            if (remoCutsLoaded.ContainsKey(animName))
            {
                hk_binding  = remoCutsLoaded[animName].hk_binding;
                hk_anim     = remoCutsLoaded[animName].hk_anim;
                hk_skeleton = remoCutsLoaded[animName].hk_skeleton;
            }
            else
            {
                var hkx = HKX.Read(hkxBytes, HKX.HKXVariation.HKXDS1, false);

                foreach (var o in hkx.DataSection.Objects)
                {
                    if (o is HKX.HKASkeleton asSkeleton)
                    {
                        hk_skeleton = asSkeleton;
                    }
                    else if (o is HKX.HKAAnimationBinding asBinding)
                    {
                        hk_binding = asBinding;
                    }
                    else if (o is HKX.HKASplineCompressedAnimation asAnim)
                    {
                        hk_anim = asAnim;
                    }
                }

                remoCutsLoaded.Add(animName, new RemoCutCache()
                {
                    hk_binding  = hk_binding,
                    hk_anim     = hk_anim,
                    hk_skeleton = hk_skeleton,
                });
            }



            var animContainer = new NewAnimationContainer();

            AnimContainer = animContainer;

            animContainer.ClearAnimations();

            animContainer.Skeleton.LoadHKXSkeleton(hk_skeleton);

            var testIdleAnimThing = new NewHavokAnimation_SplineCompressed(animName,
                                                                           animContainer.Skeleton, null, hk_binding, hk_anim, animContainer);

            animContainer.AddNewAnimation(animName, testIdleAnimThing);

            animContainer.CurrentAnimationName = animName;

            var modelNames = animContainer.Skeleton.TopLevelHkxBoneIndices.Select(b => animContainer.Skeleton.HkxSkeleton[b].Name).ToList();

            CurrentCutHits.Clear();
            CurrentCutOtherBlocks.Clear();
            lock (Scene._lock_ModelLoad_Draw)
            {
                Scene.Models.Clear();
            }
            foreach (var name in modelNames)
            {
                Model mdl = null;

                if (!remoModelDict.ContainsKey(name))
                {
                    PauseStreamBGM();

                    if (name.StartsWith("c"))
                    {
                        string shortName = name.Substring(0, 5);
                        mdl = GameDataManager.LoadCharacter(shortName);
                        FmodManager.LoadInterrootFEV(shortName);

                        if (mdl.IS_PLAYER)
                        {
                            ViewportInteractor.InitializeCharacterModel(mdl, isRemo: true);
                        }
                    }
                    else if (name.StartsWith("o"))
                    {
                        string shortName = name.Substring(0, 5);
                        mdl = GameDataManager.LoadObject(shortName);
                        FmodManager.LoadInterrootFEV(shortName);
                    }
                    else if (name.StartsWith("m"))
                    {
                        mdl = GameDataManager.LoadMapPiece(AreaInt, BlockInt, 0, 0, int.Parse(name.Substring(1, 4)));
                    }
                    else if (name.StartsWith("A"))
                    {
                        int a = int.Parse(name.Substring(1, 2));
                        int b = int.Parse(name.Substring(4, 2));

                        if (b != BlockInt && !CurrentCutOtherBlocks.Contains(b))
                        {
                            CurrentCutOtherBlocks.Add(b);
                        }

                        mdl = GameDataManager.LoadMapPiece(a, b, 0, 0, int.Parse(name.Substring(8, 4)));
                    }
                    else if (name.StartsWith("d"))
                    {
                        // TODO
                        // Dummy entity e.g. 'd0000_0000'. Apparently just acts as a single DummyPoly?
                        mdl = GameDataManager.LoadCharacter("c1000");
                        mdl.RemoDummyTransformPrim =
                            new DebugPrimitives.DbgPrimWireArrow(name, new Transform(Microsoft.Xna.Framework.Matrix.CreateScale(0.25f)
                                                                                     * mdl.CurrentTransform.WorldMatrix), Microsoft.Xna.Framework.Color.Lime)
                        {
                            Category = DebugPrimitives.DbgPrimCategory.AlwaysDraw
                        };
                        mdl.RemoDummyTransformTextPrint = new StatusPrinter(null, Microsoft.Xna.Framework.Color.Lime);
                        mdl.RemoDummyTransformTextPrint.AppendLine(name);
                        mdl.IS_REMO_DUMMY = true;
                    }
                    else if (name.StartsWith("h"))
                    {
                        // Collision.
                        CurrentCutHits.Add(name);
                    }
                    else
                    {
                        throw new NotImplementedException($"Cannot tell what object type '{name}' is in remo HKX");
                    }

                    if (mdl != null)
                    {
                        mdl.Name = name;

                        remoModelDict.Add(name, mdl);
                    }
                }
                else
                {
                    mdl = remoModelDict[name];
                }

                if (mdl != null)
                {
                    mdl.AnimContainer = animContainer;
                    mdl.IsRemoModel   = true;
                    mdl.Name          = name;
                    mdl.SkeletonFlver.RevertToReferencePose();
                    mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true);
                    mdl.UpdateSkeleton();

                    lock (Scene._lock_ModelLoad_Draw)
                    {
                        Scene.Models.Add(mdl);
                    }
                }
            }



            var msbName = GameDataManager.GetInterrootPath($@"map\MapStudio\m{AreaInt:D2}_{BlockInt:D2}_00_00.msb");

            var msb = MSB1.Read(msbName);

            Vector3 mapOffset = msb.Events.MapOffsets.FirstOrDefault()?.Position.ToXna() ?? Vector3.Zero;



            uint dg1 = 0, dg2 = 0, dg3 = 0, dg4 = 0;

            foreach (var hitName in CurrentCutHits)
            {
                var hit = msb.Parts.Collisions.FirstOrDefault(h => h.Name == hitName);
                dg1 |= hit.DrawGroups[0];
                dg2 |= hit.DrawGroups[1];
                dg3 |= hit.DrawGroups[2];
                dg4 |= hit.DrawGroups[3];
            }

            bool IsThingVisible(uint[] drawGroups)
            {
                return(((drawGroups[0] & dg1) == dg1) &&
                       ((drawGroups[1] & dg2) == dg2) &&
                       ((drawGroups[2] & dg3) == dg3) &&
                       ((drawGroups[3] & dg4) == dg4));
            }

            foreach (var mapPiece in msb.Parts.MapPieces)
            {
                var thisEntityName = CurrentCutOtherBlocks.Count > 0 ? $"A{AreaInt:D2}B{BlockInt:D2}_{mapPiece.Name}"
                        : mapPiece.Name;



                if (IsThingVisible(mapPiece.DrawGroups))
                {
                    Model mdl = null;

                    if (remoModelDict.ContainsKey(thisEntityName))
                    {
                        mdl = remoModelDict[thisEntityName];
                        mdl.AnimContainer = animContainer;
                        mdl.IsRemoModel   = true;
                        mdl.SkeletonFlver.RevertToReferencePose();
                        mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true);
                        mdl.UpdateSkeleton();
                        lock (Scene._lock_ModelLoad_Draw)
                        {
                            Scene.Models.Add(mdl);
                        }
                        continue;
                    }

                    mdl = GameDataManager.LoadMapPiece(AreaInt, BlockInt, 0, 0, int.Parse(mapPiece.ModelName.Substring(1, 4)));
                    mdl.AnimContainer = animContainer;
                    mdl.IsRemoModel   = true;
                    mdl.Name          = thisEntityName;
                    mdl.SkeletonFlver.RevertToReferencePose();

                    mdl.StartTransform.Position = mapPiece.Position.ToXna() - mapOffset;
                    mdl.StartTransform.Rotation = Utils.EulerToQuaternion((mapPiece.Rotation * (SapMath.Pi / 180f)).ToXna());
                    mdl.StartTransform.Scale    = mapPiece.Scale.ToXna();
                    mdl.CurrentTransform        = mdl.StartTransform;

                    mdl.IS_REMO_NOTSKINNED = true;

                    mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true);
                    mdl.UpdateSkeleton();

                    lock (Scene._lock_ModelLoad_Draw)
                    {
                        Scene.Models.Add(mdl);
                    }

                    remoModelDict.Add(thisEntityName, mdl);
                }
            }

            foreach (var mapPiece in msb.Parts.Objects)
            {
                var thisEntityName = CurrentCutOtherBlocks.Count > 0 ? $"A{AreaInt:D2}B{BlockInt:D2}_{mapPiece.Name}"
                        : mapPiece.Name;

                if (IsThingVisible(mapPiece.DrawGroups))
                {
                    Model mdl = null;

                    if (remoModelDict.ContainsKey(thisEntityName))
                    {
                        mdl = remoModelDict[thisEntityName];
                        mdl.AnimContainer = animContainer;
                        mdl.IsRemoModel   = true;
                        mdl.SkeletonFlver.RevertToReferencePose();
                        mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true);
                        mdl.UpdateSkeleton();
                        lock (Scene._lock_ModelLoad_Draw)
                        {
                            Scene.Models.Add(mdl);
                        }
                        continue;
                    }

                    mdl = GameDataManager.LoadObject(mapPiece.ModelName);
                    mdl.AnimContainer = animContainer;
                    mdl.IsRemoModel   = true;
                    mdl.Name          = thisEntityName;

                    mdl.StartTransform.Position = mapPiece.Position.ToXna() - mapOffset;
                    mdl.StartTransform.Rotation = Utils.EulerToQuaternion((mapPiece.Rotation * (SapMath.Pi / 180f)).ToXna());
                    mdl.StartTransform.Scale    = mapPiece.Scale.ToXna();
                    mdl.CurrentTransform        = mdl.StartTransform;

                    mdl.IS_REMO_NOTSKINNED = true;

                    mdl.SkeletonFlver.RevertToReferencePose();
                    mdl.SkeletonFlver.MapToSkeleton(animContainer.Skeleton, isRemo: true);

                    mdl.UpdateSkeleton();

                    lock (Scene._lock_ModelLoad_Draw)
                    {
                        Scene.Models.Add(mdl);
                    }

                    remoModelDict.Add(thisEntityName, mdl);
                }
            }

            lock (Scene._lock_ModelLoad_Draw)
            {
                Scene.Models = Scene.Models.OrderBy(m => m.IS_PLAYER ? 0 : 1).ToList();
            }


            CurrentCut = animName;

            animContainer.ScrubRelative(0);

            List <Model> mdls = null;

            lock (Scene._lock_ModelLoad_Draw)
            {
                mdls = Scene.Models.ToList();
            }

            foreach (var m in mdls)
            {
                m.UpdateSkeleton();
            }

            GFX.World.Update(0);

            Scene.EnableModelDrawing();
            Scene.EnableModelDrawing2();

            ResumeStreamedBGM();

            ViewportInteractor.Graph.MainScreen.REMO_HOTFIX_REQUEST_PLAY_RESUME_NEXT_FRAME = true;

            ViewportInteractor.Graph.MainScreen.HardReset();
        }
コード例 #11
0
        public static void LoadAllFMG(bool forceReload)
        {
            if (!forceReload && GameTypeCurrentFmgsAreLoadedFrom == GameDataManager.GameType)
            {
                return;
            }

            List <FMG> weaponNameFMGs = new List <FMG>();
            List <FMG> armorNameFMGs  = new List <FMG>();

            /*
             *  [ptde]
             *  weapon 1
             *  armor 2
             *
             *  [ds1r]
             *  weapon 1, 30
             *  armor 2, 32
             *
             *  [ds3]
             *  weapon 1
             *  armor 2
             *  weapon_dlc1 18
             *  armor_dlc1 19
             *  weapon_dlc2 33
             *  armor_dlc2 34
             *
             *  [bb]
             *  weapon 1
             *  armor 2
             *
             *  [sdt]
             *  weapon 1
             *  armor 2
             */

            void TryToLoadFromMSGBND(string language, string msgbndName, int weaponNamesIdx, int armorNamesIdx)
            {
                var     msgbndRelativePath = $@"msg\{language}\{msgbndName}";
                var     fullMsgbndPath     = GameDataManager.GetInterrootPath(msgbndRelativePath);
                IBinder msgbnd             = null;

                if (File.Exists(fullMsgbndPath))
                {
                    if (BND3.Is(fullMsgbndPath))
                    {
                        msgbnd = BND3.Read(fullMsgbndPath);
                    }
                    else if (BND4.Is(fullMsgbndPath))
                    {
                        msgbnd = BND4.Read(fullMsgbndPath);
                    }

                    weaponNameFMGs.Add(FMG.Read(msgbnd.Files.First(x => x.ID == weaponNamesIdx).Bytes));
                    armorNameFMGs.Add(FMG.Read(msgbnd.Files.First(x => x.ID == armorNamesIdx).Bytes));
                }

                if (msgbnd == null)
                {
                    System.Windows.Forms.MessageBox.Show(
                        $"Unable to find text file '{msgbndRelativePath}'. Some player equipment may not show names.",
                        "Unable to find asset", System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.Warning);

                    return;
                }
            }

            if (GameDataManager.GameType == GameDataManager.GameTypes.DS1)
            {
                TryToLoadFromMSGBND("ENGLISH", "item.msgbnd", 11, 12);
                TryToLoadFromMSGBND("ENGLISH", "menu.msgbnd", 115, 117); //Patch
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.DS1R)
            {
                TryToLoadFromMSGBND("ENGLISH", "item.msgbnd.dcx", 11, 12);
                TryToLoadFromMSGBND("ENGLISH", "item.msgbnd.dcx", 115, 117); //Patch
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.DS3)
            {
                TryToLoadFromMSGBND("engus", "item_dlc1.msgbnd.dcx", 11, 12);
                TryToLoadFromMSGBND("engus", "item_dlc1.msgbnd.dcx", 211, 212); //DLC1

                TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 11, 12);
                TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 211, 212); //DLC1
                TryToLoadFromMSGBND("engus", "item_dlc2.msgbnd.dcx", 251, 252); //DLC2
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.SDT)
            {
                TryToLoadFromMSGBND("engus", "item.msgbnd.dcx", 11, 12);
            }
            else if (GameDataManager.GameType == GameDataManager.GameTypes.BB)
            {
                TryToLoadFromMSGBND("engus", "item.msgbnd.dcx", 11, 12);
            }

            WeaponNames.Clear();

            void DoWeaponEntry(FMG.Entry entry)
            {
                if (string.IsNullOrWhiteSpace(entry.Text) ||
                    !ParamManager.EquipParamWeapon.ContainsKey(entry.ID))
                {
                    return;
                }

                //if (GameDataManager.GameType == GameDataManager.GameTypes.DS3 && (entry.ID % 10000) != 0)
                //    return;
                //else if ((entry.ID % 1000) != 0)
                //    return;
                string val = entry.Text + $" <{entry.ID}>";

                if (WeaponNames.ContainsKey(entry.ID))
                {
                    WeaponNames[entry.ID] = val;
                }
                else
                {
                    WeaponNames.Add(entry.ID, val);
                }
            }

            foreach (var wpnNameFmg in weaponNameFMGs)
            {
                foreach (var entry in wpnNameFmg.Entries)
                {
                    DoWeaponEntry(entry);
                }
            }

            ProtectorNames_HD.Clear();
            ProtectorNames_BD.Clear();
            ProtectorNames_AM.Clear();
            ProtectorNames_LG.Clear();

            void DoProtectorParamEntry(FMG.Entry entry)
            {
                if (string.IsNullOrWhiteSpace(entry.Text))
                {
                    return;
                }
                //if (entry.ID < 1000000 && GameDataManager.GameType == GameDataManager.GameTypes.DS3)
                //    return;
                if (ParamManager.EquipParamProtector.ContainsKey(entry.ID))
                {
                    string val            = entry.Text + $" <{entry.ID}>";
                    var    protectorParam = ParamManager.EquipParamProtector[entry.ID];
                    if (protectorParam.HeadEquip)
                    {
                        if (ProtectorNames_HD.ContainsKey(entry.ID))
                        {
                            ProtectorNames_HD[entry.ID] = val;
                        }
                        else
                        {
                            ProtectorNames_HD.Add(entry.ID, val);
                        }
                    }
                    else if (protectorParam.BodyEquip)
                    {
                        if (ProtectorNames_BD.ContainsKey(entry.ID))
                        {
                            ProtectorNames_BD[entry.ID] = val;
                        }
                        else
                        {
                            ProtectorNames_BD.Add(entry.ID, entry.Text + $" <{entry.ID}>");
                        }
                    }
                    else if (protectorParam.ArmEquip)
                    {
                        if (ProtectorNames_AM.ContainsKey(entry.ID))
                        {
                            ProtectorNames_AM[entry.ID] = val;
                        }
                        else
                        {
                            ProtectorNames_AM.Add(entry.ID, entry.Text + $" <{entry.ID}>");
                        }
                    }
                    else if (protectorParam.LegEquip)
                    {
                        if (ProtectorNames_LG.ContainsKey(entry.ID))
                        {
                            ProtectorNames_LG[entry.ID] = val;
                        }
                        else
                        {
                            ProtectorNames_LG.Add(entry.ID, entry.Text + $" <{entry.ID}>");
                        }
                    }
                }
            }

            foreach (var armorNameFmg in armorNameFMGs)
            {
                foreach (var entry in armorNameFmg.Entries)
                {
                    DoProtectorParamEntry(entry);
                }
            }

            WeaponNames       = WeaponNames.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_HD = ProtectorNames_HD.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_BD = ProtectorNames_BD.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_AM = ProtectorNames_AM.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_LG = ProtectorNames_LG.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            foreach (var protector in ParamManager.EquipParamProtector)
            {
                if (protector.Value.HeadEquip && !ProtectorNames_HD.ContainsKey((int)protector.Key))
                {
                    ProtectorNames_HD.Add((int)protector.Key, $"<{protector.Key}>");
                }
                else if (protector.Value.BodyEquip && !ProtectorNames_BD.ContainsKey((int)protector.Key))
                {
                    ProtectorNames_BD.Add((int)protector.Key, $"<{protector.Key}>");
                }
                else if (protector.Value.ArmEquip && !ProtectorNames_AM.ContainsKey((int)protector.Key))
                {
                    ProtectorNames_AM.Add((int)protector.Key, $"<{protector.Key}>");
                }
                else if (protector.Value.LegEquip && !ProtectorNames_LG.ContainsKey((int)protector.Key))
                {
                    ProtectorNames_LG.Add((int)protector.Key, $"<{protector.Key}>");
                }
            }

            foreach (var weapon in ParamManager.EquipParamWeapon)
            {
                if (!WeaponNames.ContainsKey((int)weapon.Key))
                {
                    WeaponNames.Add((int)weapon.Key, $"<{weapon.Key}>");
                }
            }

            ProtectorNames_HD = ProtectorNames_HD.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_BD = ProtectorNames_BD.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_AM = ProtectorNames_AM.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            ProtectorNames_LG = ProtectorNames_LG.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            WeaponNames       = WeaponNames.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            GameTypeCurrentFmgsAreLoadedFrom = GameDataManager.GameType;
        }
コード例 #12
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();
        }
コード例 #13
0
 private void buttonRestoreBackups_Click(object sender, EventArgs e)
 {
     GameDataManager.RestoreCharacterModelBackup(Scene.MainModel.Name, isAsync: true);
 }