public bool Load(Stream stream) { Chunks = new List <Chunk>(); using (BinaryReader reader = new BinaryReader(stream)) { if (!ReadHeader(reader)) { FastConsole.Flush(); return(false); } ChunkType chunkType = ChunkUtils.PeekNextChunk(reader); while (chunkType != ChunkType.None) { Chunk masterChunk = ChunkUtils.Instance(chunkType); if (!masterChunk.Load(reader)) { FastConsole.Flush(); return(false); } Chunks.Add(masterChunk); chunkType = ChunkUtils.PeekNextChunk(reader); } } FastConsole.Flush(); return(true); }
public override bool Load(BinaryReader reader) { Start(reader); Chunk child = new assIDChunk(); // inception ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); switch (nextChunk) { case ChunkType.assIDNone: child = new INONChunk(); if (!child.Load(reader)) { return(false); } break; case ChunkType.assIDInteger: child = new IINTChunk(); if (!child.Load(reader)) { return(false); } ID1 = (child as IINTChunk).ID; break; case ChunkType.assIDString: child = new ISTRChunk(); if (!child.Load(reader)) { return(false); } ID2 = (child as ISTRChunk).ID; break; default: Debugger.Break(); break; } Header = child.Header; End(reader); return(true); }
public override bool Load(BinaryReader reader) { parms = new List <PARMChunk>(); Start(reader); if (!ReadHeader(reader) || !IsValidVersion(2, 3)) { return(false); } if (Header.Version == 2) { string id = reader.ReadCString(); } else if (Header.Version == 3) { assID = new assIDChunk(); if (!assID.Load(reader)) { return(false); } } ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); while (nextChunk == ChunkType.pfxParameter) { PARMChunk parm = new PARMChunk(); if (!parm.Load(reader)) { return(false); } parms.Add(parm); nextChunk = ChunkUtils.PeekNextChunk(reader); } End(reader); return(true); }
public override bool Load(BinaryReader reader) { BoundingVolume = null; Start(reader); if (!ReadHeader(reader) || !IsValidVersion(1, 2)) { return(false); } BoneName = reader.ReadCString(); Unknown1 = reader.ReadFloatArray(4); Unknown2 = reader.ReadFloatArray(3); if (Header.Version == 2) { Unknown3 = reader.ReadFloatArray(3); } BoneMatrix = reader.ReadMatrix(4, 4); LogInfo("name: " + BoneName); ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); switch (nextChunk) { case ChunkType.phyBone: break; case ChunkType.phyBVSphere: BoundingVolume = new BVSPChunk(); break; case ChunkType.phyBVBox: BoundingVolume = new BVBXChunk(); break; case ChunkType.phyBVAlignedCylinder: BoundingVolume = new BVACChunk(); break; case ChunkType.phyBVCapsule: BoundingVolume = new BVCPChunk(); break; case ChunkType.phyBVSurface: BoundingVolume = new BVSFChunk(); break; case ChunkType.phyBVWalkableSurface: BoundingVolume = new BVWSChunk(); break; default: //Debugger.Break(); break; } if (BoundingVolume != null) { if (!BoundingVolume.Load(reader)) { return(false); } } End(reader); return(true); }
public override bool Load(BinaryReader reader) { Children = new List <Chunk>(); Start(reader); if (!ReadHeader(reader) || !IsValidVersion(1, 2, 3)) { return(false); } if (Header.Version == 3) { Unknown1 = reader.ReadSingle(); FastConsole.WriteLine("unk1" + Unknown1); } // Auto Assault hack { ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); if (nextChunk == ChunkType.None) { //UInt32 blockSize = reader.ReadUInt32(); UInt32 count = reader.ReadUInt32(); for (UInt32 i = 0; i < count; i++) { string shaderName = reader.ReadCString(); } } } // bounding box BoundingBox = new BBOXChunk(); Debug.Assert(BoundingBox.Load(reader)); //cp definitions CPDefinitions = new CPDGChunk(); Debug.Assert(CPDefinitions.Load(reader)); // R&D // Seems RTTI stuff //if ( ChunkUtils.PeekNextChunk( reader ) == ChunkType.None ) { UInt32 entryCount = reader.ReadUInt32(); LogInfo("rtti count: " + entryCount); for (UInt32 i = 0; i < entryCount; i++) { Int32 entryID = reader.ReadInt32(); // not sure UInt32 subCount = reader.ReadUInt32(); LogInfo("rtti entry: id " + entryID + " subentries " + subCount); for (UInt32 j = 0; j < subCount; j++) { string key = reader.ReadCString(); string value = reader.ReadCString(); LogInfo("rtti entry: " + key + " : " + value); } } } // skeleton Skeleton = new PSKEChunk(); Debug.Assert(Skeleton.Load(reader)); Int32 morphCount = reader.ReadInt32(); for (Int32 i = 0; i < morphCount; i++) { // TODO gfxMorphWeightArray return(false); //throw new NotImplementedException(); } Int32 piecesCount = reader.ReadInt32(); Children = new List <Chunk>(); for (Int32 i = 0; i < piecesCount; i++) { ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); Chunk chunk = ChunkUtils.Instance(nextChunk); Debug.Assert(chunk.Load(reader)); Children.Add(chunk); } Int32 shadowsCount = reader.ReadInt32(); Shadows = new List <Chunk>(); for (Int32 i = 0; i < shadowsCount; i++) { ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); Chunk chunk = ChunkUtils.Instance(nextChunk); Debug.Assert(chunk.Load(reader)); Shadows.Add(chunk); } if (Header.Version >= 2) { // some kind of flag bool hasLODHandler = reader.ReadBoolean(); if (hasLODHandler) { // gfxLODHandler // LDAA LDSD ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); Skip(reader); } } End(reader); return(true); }
public override bool Load(BinaryReader reader) { Start(reader); if (!ReadHeader(reader) || !IsValidVersion(8, 9, 10, 11, 12)) { return(false); } if (Header.Version >= 9) { bool hasMaterial = reader.ReadBoolean(); } Effect = new EFCTChunk(); if (!Effect.Load(reader)) { return(false); } // indices IndexBuffer = new INDXChunk(); if (!IndexBuffer.Load(reader)) { return(false); } // vertices if (Header.Version >= 10) { VertexBuffer = new VERTChunk(); if (!VertexBuffer.Load(reader)) { return(false); } } else { // wtf Int32 unk0 = reader.ReadInt32(); if (unk0 == 2) { Debugger.Break(); VertexBuffer = new VERTChunk(); if (!VertexBuffer.Load(reader)) { return(false); } VERTChunk vertexBuffer2 = new VERTChunk(); if (!vertexBuffer2.Load(reader)) { return(false); } } else { VertexBuffer = new VERTChunk(); if (!VertexBuffer.Load(reader)) { return(false); } } } // bounding box BoundingBox = new BBOXChunk(); if (!BoundingBox.Load(reader)) { return(false); } string unk1 = reader.ReadCString(); UInt32 unk2 = reader.ReadUInt32(); Int32 unk3 = reader.ReadInt32(); string unk4 = reader.ReadCString(); string unk5 = reader.ReadCString(); ChunkType nextChunk = ChunkUtils.PeekNextChunk(reader); if (nextChunk == ChunkType.gfxUSDA) { USDA = new USDAChunk(); if (!USDA.Load(reader)) { return(false); } } Int32 unk6 = reader.ReadInt32(); UInt32 unk7 = reader.ReadUInt32(); Int32 unk8 = reader.ReadInt32(); if (Header.Version == 12) { Int32 unk9 = reader.ReadInt32(); } if (Header.Version >= 11) { Int32 count = reader.ReadInt32(); for (Int32 i = 0; i < count; i++) { //Debugger.Break(); // index buffer INDXChunk indices = new INDXChunk(); if (!indices.Load(reader)) { return(false); } } } End(reader); return(true); }