public static void Init(GameTypes gameType, string interroot, bool forceReload = false) { GameType = gameType; InterrootPath = interroot; if (gameType != lastGameType || forceReload) { ParamManager.LoadParamBND(forceReload); FmgManager.LoadAllFMG(forceReload); LoadSystex(); LoadMTDBND(); FmodManager.Purge(); //FmodManager.UpdateInterrootForFile(null); FmodManager.LoadFloorMaterialNamesFromInterroot(); } lastGameType = GameType; }
public static void StartFullPreview() { if (StreamedBGM != null && !StreamedBGM.EventIsOver) { StreamedBGM.Stop(true); } FmodManager.StopAllSounds(); ViewportInteractor.Graph.MainScreen.SelectNewAnimRef(ViewportInteractor.Graph.MainScreen.SelectedTae, ViewportInteractor.Graph.MainScreen.SelectedTae.Animations.First()); ViewportInteractor.Graph.MainScreen.HardReset(); ViewportInteractor.Graph.PlaybackCursor.Scrubbing = false; ViewportInteractor.Graph.PlaybackCursor.IsPlaying = true; ViewportInteractor.Graph.PlaybackCursor.IsStepping = false; StartStreamedBGM(); ViewportInteractor?.Graph?.PlaybackCursor?.SetRemoState(); }
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(); }
public static void StartStreamedBGM() { StreamedBGM = FmodManager.PlaySE(4, (int.Parse(RemoName.Substring(3, 6)) * 1000) + 1, () => GFX.World.CameraLocationInWorld.Position, null); }