private void DeinitPS1Stream() { foreach (GameObject gao in allNTTO) { Destroy(gao); } allNTTO.Clear(); currentNTTO.Clear(); objectPool.Clear(); R2PS1Loader l = MapLoader.Loader as R2PS1Loader; l.gao_dynamicWorld.SetActive(true); }
public void Init() { controller = MapLoader.Loader.controller; if (MapLoader.Loader is R2PS1Loader) { R2PS1Loader l = MapLoader.Loader as R2PS1Loader; ps1Streams = l.streams; string[] cinematicNames = CinematicNames; Array.Resize(ref cinematicNames, ps1Streams.Length + 1); CinematicNames = cinematicNames; for (int i = 0; i < ps1Streams.Length; i++) { CinematicNames[i + 1] = "Stream " + i; PS1GameInfo game = PS1GameInfo.Games[Settings.s.mode]; if (game != null && game.cines != null && game.cines.ContainsKey(l.lvlName)) { if (game.cines[l.lvlName].Length > i) { CinematicNames[i + 1] += ": " + game.cines[l.lvlName][i]; } } if (l.levelHeader.initialStreamID == i) { CinematicNames[i + 1] += " (intro)"; } } } else { cinematicsManager = MapLoader.Loader.cinematicsManager; string[] cinematicNames = CinematicNames; Array.Resize(ref cinematicNames, cinematicsManager.cinematics.Count + 1); CinematicNames = cinematicNames; Array.Copy(cinematicsManager.cinematics.Select(c => (c == null ? "Null" : c.name)).ToArray(), 0, CinematicNames, 1, cinematicsManager.cinematics.Count); } if (currentCinematic == -1) { currentCinematic = 0; } CinematicIndex = currentCinematic; loaded = true; }
public void Init() { R2PS1Loader l = MapLoader.Loader as R2PS1Loader; h = l.levelHeader; a1h = l.actor1Header; a2h = l.actor2Header; if (perso != null && perso.p3dData != null && perso.p3dData.family != null) { Family fam = perso.p3dData.family; if (fam.animations != null) { PointerList <State> statePtrs = l.GetStates(perso.p3dData); State[] tempStates = statePtrs.pointers.Select(s => s.Value).ToArray(); int ind = (int)perso.p3dData.stateIndex; if (ind >= tempStates.Length) { ind = 0; } int stateInd = ind; states = fam.states; stateNames = new string[states.Length + 1 + fam.animations.Length]; stateNames[0] = "Null"; for (int i = 0; i < states.Length; i++) { State s = states[i]; stateNames[i + 1] = (s.anim == null || s.anim.index >= fam.animations.Length) ? "Null" : $"State {Array.IndexOf(tempStates, s)}: {fam.animations[s.anim.index].name}"; } for (int i = 0; i < fam.animations.Length; i++) { stateNames[i + 1 + states.Length] = $"(Animation {i}) {fam.animations[i].name}"; } hasStates = true; stateIndex = stateInd - (int)fam.startState; stateIndex++; // After null currentState = stateIndex; SetState(stateIndex); } } IsLoaded = true; }
protected override void ReadInternal(Reader reader) { v0 = reader.ReadUInt16(); v1 = reader.ReadUInt16(); v2 = reader.ReadUInt16(); v3 = reader.ReadUInt16(); materialFlags = reader.ReadByte(); scroll = reader.ReadByte(); ushort_0A = reader.ReadUInt16(); x0 = reader.ReadByte(); y0 = reader.ReadByte(); paletteInfo = reader.ReadUInt16(); // palette info? x1 = reader.ReadByte(); y1 = reader.ReadByte(); pageInfo = reader.ReadUInt16(); // page info? x2 = reader.ReadByte(); y2 = reader.ReadByte(); x3 = reader.ReadByte(); y3 = reader.ReadByte(); byte[] x = new[] { x0, x1, x2, x3 }; byte[] y = new[] { y0, y1, y2, y3 }; int xMin = x.Min(); int xMax = x.Max() + 1; int yMin = y.Min(); int yMax = y.Max() + 1; int w = xMax - xMin; int h = yMax - yMin; R2PS1Loader l = Load as R2PS1Loader; l.RegisterTexture(pageInfo, paletteInfo, xMin, xMax, yMin, yMax); /* * R2PS1Loader l = Load as R2PS1Loader; * PS1VRAM vram = l.vram; * Texture2D tex = vram.GetTexture((ushort)w, (ushort)h, pageInfo, paletteInfo, PS1VRAM.PixelMode.Byte, xMin, yMin); * Util.ByteArrayToFile(l.gameDataBinFolder + "test_tex/" + Offset.StringFileOffset + $"_{w}_{h}" + ".png", tex.EncodeToPNG()); */ }
public override StateTransition[] GetStateTransitions(int index) { if (index < 1 || index >= 1 + states.Length) { return(null); } State state = states[index - 1]; if (state != null && state.transitions != null && state.transitions.Length > 0) { R2PS1Loader l = MapLoader.Loader as R2PS1Loader; PointerList <State> statePtrs = l.GetStates(perso.p3dData); State[] states = statePtrs.pointers.Select(s => s.Value).ToArray(); List <StateTransition> tr = new List <StateTransition>(); foreach (OpenSpace.PS1.StateTransition t in state.transitions) { State stateToGo = t.stateToGo.Value; State targetState = t.targetState.Value; if (stateToGo == null || targetState == null) { continue; } string targetStateName = GetStateName(targetState); string stateToGoName = GetStateName(stateToGo); if (targetStateName != null && stateToGoName != null) { tr.Add(new StateTransition() { StateToGoName = stateToGoName, StateToGoIndex = GetStateIndex(stateToGo), TargetStateName = targetStateName, TargetStateIndex = GetStateIndex(targetState), LinkingType = 0 }); } } return(tr.ToArray()); } return(null); }
protected override void ReadInternal(Reader reader) { R2PS1Loader l = Load as R2PS1Loader; if (Settings.s.game == Settings.Game.RRush) { off_superObject = Pointer.Read(reader); } else if (Settings.s.game == Settings.Game.JungleBook) { reader.ReadBytes(0x98); } copiedActorData = reader.ReadBytes(0x18); off_states = Pointer.Read(reader); num_states = reader.ReadUInt16(); ushort_22 = reader.ReadUInt16(); off_animPositions = Pointer.Read(reader); // 0x6 size off_animRotations = Pointer.Read(reader); // big array of structs of 0x8 size. 4 ushorts per struct off_animScales = Pointer.Read(reader); off_geometricObjects_dynamic = Pointer.Read(reader); num_geometricObjects_dynamic = reader.ReadUInt32(); if (Settings.s.game == Settings.Game.RRush) { ushort_38 = reader.ReadUInt16(); ushort_3A = reader.ReadUInt16(); off_state_indices = Pointer.Read(reader); } // Parse states = Load.FromOffsetOrRead <PointerList <State> >(reader, off_states, s => s.length = num_states); geometricObjectsDynamic = Load.FromOffsetOrRead <ObjectsTable>(reader, off_geometricObjects_dynamic, onPreRead: t => t.length = num_geometricObjects_dynamic - 2); animPositions = Load.ReadArray <PS1AnimationVector>((off_animRotations.offset - off_animPositions.offset) / 6, reader, off_animPositions); animRotations = Load.ReadArray <PS1AnimationQuaternion>((off_animScales.offset - off_animRotations.offset) / 8, reader, off_animRotations); animScales = Load.ReadArray <PS1AnimationVector>(l.maxScaleVector[file_index] + 1, reader, off_animScales); //Load.print(off_geometricObjects_dynamic + " - " + num_geometricObjects_dynamic); }
public void ParseAGOTextures(Reader reader) { if (!Load.exportTextures) { return; } Load.print("Num AGO Textures: " + num_ago_textures); UITexture[] textures = new UITexture[num_ago_textures]; for (int i = 0; i < textures.Length; i++) { textures[i] = new UITexture(); } for (int i = 0; i < textures.Length; i++) { textures[i].name = "Tex_" + i; } Pointer.DoAt(ref reader, off_ago_textures_pageInfo, () => { for (int i = 0; i < textures.Length; i++) { textures[i].pageInfo = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ago_textures_palette, () => { for (int i = 0; i < textures.Length; i++) { textures[i].palette = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ago_textures_xInPage, () => { for (int i = 0; i < textures.Length; i++) { textures[i].xInPage = reader.ReadByte(); } }); Pointer.DoAt(ref reader, off_ago_textures_yInPage, () => { for (int i = 0; i < textures.Length; i++) { textures[i].yInPage = reader.ReadByte(); } }); Pointer.DoAt(ref reader, off_ago_textures_globalX, () => { for (int i = 0; i < textures.Length; i++) { textures[i].globalX = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ago_textures_globalY, () => { for (int i = 0; i < textures.Length; i++) { textures[i].globalY = reader.ReadUInt16(); } }); if (Settings.s.game == Settings.Game.RRush) { Pointer.DoAt(ref reader, off_ago_textures_width, () => { for (int i = 0; i < textures.Length; i++) { textures[i].width = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ago_textures_height, () => { for (int i = 0; i < textures.Length; i++) { textures[i].height = reader.ReadUInt16(); } }); } R2PS1Loader l = Load as R2PS1Loader; PS1VRAM vram = l.vram; for (int i = 0; i < textures.Length; i++) { UITexture t = textures[i]; if (t.width != 0) { //Load.print(t.name + " - " + t.width + " - " + t.height + " - " + t.xInPage + " - " + t.yInPage); t.texture = vram.GetTexture(t.width, t.height, t.pageInfo, t.palette, t.xInPage, t.yInPage); Util.ByteArrayToFile(l.gameDataBinFolder + "textures/ago/" + Load.lvlName + "/" + $"{t.name}.png", t.texture.EncodeToPNG()); } else { // Uncomment to extract AGO textures with hardcoded width & height /*int tp = Util.ExtractBits(t.pageInfo, 2, 7); // 0: 4-bit, 1: 8-bit, 2: 15-bit direct * int pageW = 64; * if (tp == 1) { * pageW = 128; * } else if (tp == 0) { * pageW = 256; * } * int maxW = pageW - t.xInPage; * int maxH = 256 - t.yInPage; * for (int x = 0; x < 5; x++) { * ushort w = (ushort)(0x10 << x); * if (w > maxW) continue; * for (int y = 0; y < 5; y++) { * ushort h = (ushort)(0x10 << y); * if (h > maxH) continue; * try { * t.texture = vram.GetTexture(w, h, t.pageInfo, t.palette, t.xInPage, t.yInPage); * Util.ByteArrayToFile(l.gameDataBinFolder + "textures/ago/" + Load.lvlName + "/" + $"{t.name}_{w}x{h}.png", t.texture.EncodeToPNG()); + } catch { } + } + }*/ } } }
public void ParseUITextures(Reader reader) { if (!Load.exportTextures) { return; } Load.print("Num UI Textures: " + num_ui_textures); UITexture[] textures = new UITexture[num_ui_textures]; for (int i = 0; i < textures.Length; i++) { textures[i] = new UITexture(); } Pointer.DoAt(ref reader, off_ui_textures_names, () => { for (int i = 0; i < textures.Length; i++) { Pointer p = Pointer.Read(reader); Pointer.DoAt(ref reader, p, () => { textures[i].name = reader.ReadString(0x1C); }); } }); Pointer.DoAt(ref reader, off_ui_textures_width, () => { for (int i = 0; i < textures.Length; i++) { textures[i].width = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ui_textures_height, () => { for (int i = 0; i < textures.Length; i++) { textures[i].height = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ui_textures_pageInfo, () => { for (int i = 0; i < textures.Length; i++) { textures[i].pageInfo = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ui_textures_palette, () => { for (int i = 0; i < textures.Length; i++) { textures[i].palette = reader.ReadUInt16(); } }); Pointer.DoAt(ref reader, off_ui_textures_xInPage, () => { for (int i = 0; i < textures.Length; i++) { textures[i].xInPage = reader.ReadByte(); } }); Pointer.DoAt(ref reader, off_ui_textures_yInPage, () => { for (int i = 0; i < textures.Length; i++) { textures[i].yInPage = reader.ReadByte(); } }); R2PS1Loader l = Load as R2PS1Loader; PS1VRAM vram = l.vram; for (int i = 0; i < textures.Length; i++) { UITexture t = textures[i]; //Load.print(t.name + " - " + t.width + " - " + t.height + " - " + t.xInPage + " - " + t.yInPage); t.texture = vram.GetTexture(t.width, t.height, t.pageInfo, t.palette, t.xInPage, t.yInPage); Util.ByteArrayToFile(l.gameDataBinFolder + "textures/ui/" + t.name + ".png", t.texture.EncodeToPNG()); } }
protected override void ReadInternal(Reader reader) { R2PS1Loader l = Load as R2PS1Loader; if (Settings.s.game == Settings.Game.RRush) { reader.ReadBytes(0x40); } else if (Settings.s.game == Settings.Game.DD) { reader.ReadBytes(0x58); } else if (Settings.s.game == Settings.Game.VIP) { reader.ReadBytes(0x28); } else if (Settings.s.game == Settings.Game.JungleBook) { reader.ReadBytes(0xEC); } else { reader.ReadBytes(0xCC); num_geometricObjectsDynamic_cine = reader.ReadUInt32(); reader.ReadBytes(0x20); // after this we're at 0xf0 } off_dynamicWorld = Pointer.Read(reader); off_fatherSector = Pointer.Read(reader); off_inactiveDynamicWorld = Pointer.Read(reader); num_always = reader.ReadUInt32(); off_always = Pointer.Read(reader); // num_wayPoints = reader.ReadUInt32(); // x num_graphs = reader.ReadUInt32(); off_wayPoints = Pointer.Read(reader); // x structs of 0x14 waypoints off_graphs = Pointer.Read(reader); // graphs. structs of 0x68 num_persos = reader.ReadUInt16(); ushort_116 = reader.ReadUInt16(); off_persos = Pointer.Read(reader); Load.print(off_dynamicWorld + " - " + off_fatherSector + " - " + off_inactiveDynamicWorld + " - " + off_always + " - " + off_wayPoints + " - " + off_graphs + " - " + off_persos); off_states = Pointer.Read(reader); num_states = reader.ReadUInt16(); ushort_122 = reader.ReadUInt16(); uint_124 = reader.ReadUInt32(); uint_128 = reader.ReadUInt32(); off_12C = Pointer.Read(reader); // this + 0x10 = main character off_130 = Pointer.Read(reader); uint_134 = reader.ReadUInt32(); uint_138 = reader.ReadUInt32(); uint_13C = reader.ReadUInt32(); // same as mainChar_states count uint_140 = reader.ReadUInt32(); uint_144 = reader.ReadUInt32(); initialStreamID = reader.ReadInt32(); // -1 Load.print(Pointer.Current(reader)); off_animPositions = Pointer.Read(reader); // 0x6 size off_animRotations = Pointer.Read(reader); // big array of structs of 0x8 size. 4 ushorts per struct off_animScales = Pointer.Read(reader); Load.print(off_12C + " - " + off_130 + " - " + off_animPositions + " - " + off_animRotations + " - " + off_animScales); //Load.print(Pointer.Current(reader)); if (Settings.s.game == Settings.Game.DD) { // Also stuff for big textures, but names and amount is stored in exe Pointer.Read(reader); Pointer.Read(reader); Pointer.Read(reader); Pointer.Read(reader); Pointer.Read(reader); reader.ReadUInt32(); reader.ReadUInt32(); Pointer.Read(reader); off_geometricObjects_dynamic = Pointer.Read(reader); num_skinnableObjects = reader.ReadUInt32(); int num_skins = 5; off_skins = new Pointer[num_skins]; skins = new SkinnableGeometricObjectList[num_skins]; for (int i = 0; i < num_skins; i++) { off_skins[i] = Pointer.Read(reader); skins[i] = Load.FromOffsetOrRead <SkinnableGeometricObjectList>(reader, off_skins[i], onPreRead: s => s.length = num_skinnableObjects); } off_current_skin_memory = Pointer.Read(reader); reader.ReadUInt32(); // total skin memory size? off_geometricObjects_static = Pointer.Read(reader); num_geometricObjects_dynamic = reader.ReadUInt32(); } else if (Settings.s.game == Settings.Game.VIP || Settings.s.game == Settings.Game.JungleBook) { reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); off_geometricObjects_dynamic = Pointer.Read(reader); off_geometricObjects_static = Pointer.Read(reader); num_geometricObjects_dynamic = reader.ReadUInt32(); } else { // Vignette stuff, big textures num_ui_textures = reader.ReadByte(); byte_159 = reader.ReadByte(); ushort_15A = reader.ReadUInt16(); off_ui_textures_names = Pointer.Read(reader); off_ui_textures_width = Pointer.Read(reader); // num_vignettes * ushort off_ui_textures_height = Pointer.Read(reader); // num_vignettes * ushort off_ui_textures_pageInfo = Pointer.Read(reader); // num_vignettes * ushort off_ui_textures_palette = Pointer.Read(reader); off_ui_textures_xInPage = Pointer.Read(reader); off_ui_textures_yInPage = Pointer.Read(reader); // still related to the vignette stuff ParseUITextures(reader); // Something else off_178 = Pointer.Read(reader); int_17C = reader.ReadInt32(); // -1 off_geometricObjects_dynamic = Pointer.Read(reader); off_geometricObjects_static = Pointer.Read(reader); num_geometricObjects_dynamic = reader.ReadUInt32(); } if (Settings.s.game != Settings.Game.VIP) { ushort_18C = reader.ReadUInt16(); ushort_18E = reader.ReadUInt16(); short_190 = reader.ReadInt16(); ushort_192 = reader.ReadUInt16(); num_ipoCollision = reader.ReadUInt32(); // y off_ipoCollision = Pointer.Read(reader); // y structs of 0x3c //Load.print(off_ipoCollision + " - " + num_ipoCollision); num_meshCollision = reader.ReadUInt32(); /*if (num_meshCollision > 0) { * Load.print(num_meshCollision); * off_meshCollision = Pointer.Read(reader); * } else {*/ off_meshCollision_ = reader.ReadUInt32(); //} } else { ushort_18C = reader.ReadUInt16(); ushort_18E = reader.ReadUInt16(); short_190 = reader.ReadInt16(); ushort_192 = reader.ReadUInt16(); reader.ReadUInt32(); // y reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); //Pointer.Read(reader); } off_sectors = Pointer.Read(reader); // num_1A8 structs of 0x54 num_sectors = reader.ReadUInt16(); // actual sectors //Load.print(off_sector_minus_one_things + " - " + bad_off_1A0 + " - " + off_sectors); ushort_1AA = reader.ReadUInt16(); Load.print(Pointer.Current(reader)); if (Settings.s.game != Settings.Game.DD) { num_cameraModifiers = reader.ReadUInt32(); uint_1B0 = reader.ReadUInt32(); uint_1B4 = reader.ReadUInt32(); uint_1B8 = reader.ReadUInt32(); if (Settings.s.game != Settings.Game.VIP) { off_cameraModifiers_volumes = Pointer.Read(reader); // uint_1B4 * 0x70 off_cameraModifiers = Pointer.Read(reader); // uint_1ac * 0x68. lights? first with type (first byte) = 9 is camera related? position is at 0x14, 0x18, 0x1c? } else { reader.ReadUInt32(); reader.ReadUInt32(); } if (Settings.s.game == Settings.Game.RRush) { off_rush_114 = Pointer.Read(reader); ushort_rush_118 = reader.ReadUInt16(); ushort_rush_11A = reader.ReadUInt16(); } } off_gameMaterials = Pointer.Read(reader); num_gameMaterials = reader.ReadUInt32(); uint_1CC = reader.ReadUInt32(); ushort_1D0 = reader.ReadUInt16(); ushort_1D2 = reader.ReadUInt16(); off_1D4 = Pointer.Read(reader); num_ago_textures = reader.ReadUInt32(); off_ago_textures_pageInfo = Pointer.Read(reader); off_ago_textures_palette = Pointer.Read(reader); off_ago_textures_xInPage = Pointer.Read(reader); off_ago_textures_yInPage = Pointer.Read(reader); off_ago_textures_globalX = Pointer.Read(reader); off_ago_textures_globalY = Pointer.Read(reader); if (Settings.s.game == Settings.Game.RRush) { off_ago_textures_width = Pointer.Read(reader); off_ago_textures_height = Pointer.Read(reader); //Load.print(Pointer.Current(reader)); ParseAGOTextures(reader); } else if (Settings.s.game == Settings.Game.R2) { uint_1F4 = reader.ReadUInt32(); uint_1F8 = reader.ReadUInt32(); uint_1FC = reader.ReadUInt32(); ParseAGOTextures(reader); } // Parse states = Load.FromOffsetOrRead <PointerList <State> >(reader, off_states, s => s.length = num_states); persos = Load.ReadArray <Perso>(num_persos, reader, off_persos); geometricObjectsDynamic = Load.FromOffsetOrRead <ObjectsTable>(reader, off_geometricObjects_dynamic, onPreRead: t => t.length = num_geometricObjects_dynamic - 2); geometricObjectsStatic = Load.FromOffsetOrRead <ObjectsTable>(reader, off_geometricObjects_static, onPreRead: t => { if (Settings.s.game == Settings.Game.R2) { t.length = num_ipoCollision; } }); ipoCollision = Load.ReadArray <GeometricObjectCollide>(num_ipoCollision, reader, off_ipoCollision); meshCollision = Load.ReadArray <GeometricObjectCollide>(num_meshCollision, reader, off_meshCollision); gameMaterials = Load.ReadArray <GameMaterial>(num_gameMaterials, reader, off_gameMaterials); wayPoints = Load.ReadArray <WayPoint>(num_wayPoints, reader, off_wayPoints); graphs = Load.ReadArray <Graph>(num_graphs, reader, off_graphs); cameraModifiers = Load.ReadArray <CameraModifier>(num_cameraModifiers, reader, off_cameraModifiers); cameraModifierVolumes = Load.ReadArray <CameraModifierVolume>(num_cameraModifiers, reader, off_cameraModifiers_volumes); always = Load.ReadArray <AlwaysList>(num_always, reader, off_always); sectors = Load.ReadArray <Sector>(num_sectors, reader, off_sectors); animPositions = Load.ReadArray <PS1AnimationVector>((off_animRotations.offset - off_animPositions.offset) / 6, reader, off_animPositions); animRotations = Load.ReadArray <PS1AnimationQuaternion>((off_animScales.offset - off_animRotations.offset) / 8, reader, off_animRotations); animScales = Load.ReadArray <PS1AnimationVector>(l.maxScaleVector[0] + 1, reader, off_animScales); }
protected override void ReadInternal(Reader reader) { //Load.print("Anim " + Pointer.Current(reader)); if (Settings.s.game == Settings.Game.R2) { speed = reader.ReadUInt32(); off_channels = Pointer.Read(reader); num_channels = reader.ReadUInt32(); num_frames = reader.ReadUInt16(); ushort_0E = reader.ReadUInt16(); num_hierarchies = reader.ReadUInt32(); off_hierarchies = Pointer.Read(reader); uint_18 = reader.ReadUInt32(); } else if (Settings.s.game == Settings.Game.RRush) { off_channels = Pointer.Read(reader); off_hierarchies = Pointer.Read(reader); num_hierarchies = reader.ReadUInt16(); file_index = reader.ReadUInt16(); speed = reader.ReadByte(); num_channels = reader.ReadByte(); num_frames = reader.ReadUInt16(); } else { flags = reader.ReadUInt32(); off_channels = Pointer.Read(reader); num_channels = reader.ReadUInt32(); num_frames = reader.ReadUInt16(); //Load.print("Anim " + Offset + " - " + num_frames); ushort_0E = reader.ReadUInt16(); num_hierarchies = reader.ReadUInt32(); if (Settings.s.game == Settings.Game.VIP || Settings.s.game == Settings.Game.JungleBook) { off_hierarchies = Pointer.Read(reader); ushort_18 = reader.ReadUInt16(); num_bones = reader.ReadUInt16(); off_bones = Pointer.Read(reader); /*Load.print("Animation: " + Offset + " - " + num_channels + " - " + num_bones + " - " + off_bones);*/ file_index = (ushort)reader.ReadUInt32(); speed = 30; } else { speed = reader.ReadUInt16(); ushort_1A = reader.ReadUInt16(); off_hierarchies = Pointer.Read(reader); uint_18 = reader.ReadUInt32(); uint_18 = reader.ReadUInt32(); uint_18 = reader.ReadUInt32(); } } channels = Load.ReadArray <PS1AnimationChannel>(num_channels, reader, off_channels); hierarchies = Load.ReadArray <PS1AnimationHierarchy>(num_hierarchies, reader, off_hierarchies); //Load.print(channels.Max(c => c.frames.Length == 0 ? 0 : c.frames.Max(f => f.ntto >= 1 ? f.frameNumber.GetValueOrDefault(0) : 0)) + " - " + num_frames + " - " + num_channels); if (off_hierarchies != null) { Pointer.DoAt(ref reader, off_hierarchies - (Settings.s.game == Settings.Game.DD ? 0x14 : 0x10), () => { name = reader.ReadString(0x10); //Load.print(Offset + " - " + name); }); } bones = Load.ReadArray <PS1AnimationBoneChannelLinks>(num_bones, reader, off_bones); R2PS1Loader l = Load as R2PS1Loader; foreach (PS1AnimationChannel c in channels) { foreach (PS1AnimationKeyframe f in c.frames) { if (f.scl.HasValue) { if (f.scl.Value > l.maxScaleVector[file_index]) { l.maxScaleVector[file_index] = f.scl.Value; } } } } /*if (transitions != null) { * name = transitions.name; * Load.print(Offset + " - " + name); * }*/ }
private List <string> FindFiles() { // Create the output var output = new List <string>(); // If the directory does not exist, return the empty list if (!Directory.Exists(directory)) { return(output); } // Add the found files containing the correct file extension string extension = null; string[] levels; switch (Settings.s.platform) { case Settings.Platform.PC: case Settings.Platform.iOS: case Settings.Platform.GC: case Settings.Platform.Xbox: case Settings.Platform.Xbox360: case Settings.Platform.PS3: case Settings.Platform.MacOS: if (Settings.s.engineVersion < Settings.EngineVersion.R3) { extension = "*.sna"; } else { extension = "*.lvl"; } break; case Settings.Platform.DC: extension = "*.DAT"; break; case Settings.Platform.PS2: if (Settings.s.engineVersion < Settings.EngineVersion.R3) { if (Settings.s.engineVersion < Settings.EngineVersion.R2) { extension = "*.sna"; } else { extension = "*.lv2"; } } else { extension = "*.lvl"; } break; case Settings.Platform.PS1: MapLoader.Reset(); R2PS1Loader l1 = MapLoader.Loader as R2PS1Loader; l1.gameDataBinFolder = directory; levels = l1.LoadLevelList(); MapLoader.Reset(); output.AddRange(levels); break; case Settings.Platform.DS: case Settings.Platform.N64: case Settings.Platform._3DS: MapLoader.Reset(); R2ROMLoader lr = MapLoader.Loader as R2ROMLoader; lr.gameDataBinFolder = directory; levels = lr.LoadLevelList(); MapLoader.Reset(); output.AddRange(levels); break; } if (extension != null) { output.AddRange( from file in Directory.EnumerateFiles(directory, extension, SearchOption.AllDirectories) let filename = Path.GetFileNameWithoutExtension(file) let dirname = new DirectoryInfo(file).Parent.Name where ((!filterPaths.Contains(filename.ToLower())) && dirname.ToLower() == filename.ToLower()) select dirname ); } //Debug.Log(string.Join("\n",output)); // Return the output return(output); }
public void UpdatePS1StreamFrame() { ClearCurrentNTTO(); if (Camera.main.orthographic) { CinematicIndex = 0; return; } if (ps1Streams != null && currentCinematic > 0) { OpenSpace.PS1.PS1Stream s = ps1Streams[currentCinematic - 1]; OpenSpace.PS1.PS1StreamFrame f = s.frames.FirstOrDefault(fr => fr.num_frame == currentFrame); if (f != null) { Dictionary <int, int> nttoForFrame = new Dictionary <int, int>(); R2PS1Loader l = MapLoader.Loader as R2PS1Loader; Camera cam = Camera.main; for (int i = 0; i < f.channels.Length; i++) { OpenSpace.PS1.PS1StreamFrameChannel c = f.channels[i]; if (c.HasFlag(OpenSpace.PS1.PS1StreamFrameChannel.StreamFlags.Camera)) { cam.transform.position = c.GetPosition(); cam.transform.rotation = c.quaternion * Quaternion.Euler(0, 180, 0); } else { GameObject gao = null; int ntto = c.NTTO; if (ntto >= 0) { if (!nttoForFrame.ContainsKey(ntto)) { nttoForFrame[ntto] = 0; } if (objectPool.ContainsKey(ntto)) { gao = objectPool[ntto][nttoForFrame[ntto]]; } if (gao != null) { gao.SetActive(true); currentNTTO.Add(gao); nttoForFrame[ntto]++; } } /*if (c.NTTO > 0) { * gao = l.levelHeader.geometricObjectsDynamic.GetGameObject(c.NTTO); * if (gao == null) gao = new GameObject("Empty 2"); * } else { * gao = new GameObject("Empty"); * }*/ /*if (c.HasFlag(PS1StreamFrameChannel.StreamFlags.Parent)) { * Debug.Log(string.Format("{0:X4}", c.flags)); * }*/ if (gao != null) { Vector3 scale = new Vector3(1f, 1f, 1f); gao.transform.localPosition = cam.transform.localPosition + c.GetPosition(); gao.transform.localRotation = c.quaternion; if (c.HasFlag(OpenSpace.PS1.PS1StreamFrameChannel.StreamFlags.Scale)) { scale = c.GetScale(0x1000); //gao.name = string.Format("{0:X4}", c.sx) + string.Format("{0:X4}", c.sy) + string.Format("{0:X4}", c.sz) + " - " + gao.name; } if (c.HasFlag(OpenSpace.PS1.PS1StreamFrameChannel.StreamFlags.FlipX)) { gao.transform.localScale = new Vector3(-scale.x, scale.y, scale.z); } else { gao.transform.localScale = scale; } //gao.transform.localScale = c.GetScale(); currentNTTO.Add(gao); } } } } } }
public void InitPS1Stream() { DeinitPS1Stream(); currentFrame = 0; if (currentCinematic > 0 && ps1Streams != null) { Camera cam = Camera.main; if (cam.orthographic) { controller.SetCameraPosition(WebJSON.CameraPos.Initial); } OpenSpace.PS1.PS1Stream s = ps1Streams[currentCinematic - 1]; R2PS1Loader l = MapLoader.Loader as R2PS1Loader; l.gao_dynamicWorld.SetActive(false); foreach (PS1StreamFrame f in s.frames) { Dictionary <int, int> nttoForFrame = new Dictionary <int, int>(); for (int i = 0; i < f.num_channels; i++) { PS1StreamFrameChannel c = f.channels[i]; int ntto = c.NTTO; /*if (c.HasFlag(PS1StreamFrameChannel.StreamFlags.Parent)) { * Debug.Log(string.Format("{0:X4}", c.flags)); * }*/ if (ntto >= 0) { /*if (nttoPerChannel[i] == null) nttoPerChannel[i] = new Dictionary<int, GameObject>(); * * if (!nttoPerChannel[i].ContainsKey(ntto)) { * GameObject gao = l.levelHeader.geometricObjectsDynamic.GetGameObject(ntto); * if (gao == null) gao = new GameObject("Empty 2"); * gao.name = string.Format("{0:X4}", c.flags) + " - " + gao.name; * gao.transform.SetParent(transform); * gao.SetActive(false); * }*/ if (!nttoForFrame.ContainsKey(ntto)) { nttoForFrame[ntto] = 0; } nttoForFrame[ntto]++; if (!objectPool.ContainsKey(ntto) || objectPool[ntto].Count < nttoForFrame[ntto]) { GameObject gao = l.levelHeader.geometricObjectsDynamic.GetGameObject(ntto, null, out _); //if (gao == null) gao = new GameObject("Empty 2"); if (gao != null) { gao.name = string.Format("{0:X4}", c.flags) + " - " + gao.name; gao.transform.SetParent(transform); gao.SetActive(false); allNTTO.Add(gao); if (!objectPool.ContainsKey(ntto)) { objectPool[ntto] = new List <GameObject>(); } objectPool[ntto].Add(gao); } } } } } } }