private void Read_Chunks(BinaryReader reader) { foreach (ChunkHeader chkHdr in this._chunks) { this.ChunkMap[chkHdr.ID] = Chunk.New(chkHdr.ChunkType, chkHdr.Version); this.ChunkMap[chkHdr.ID].Load(this, chkHdr); this.ChunkMap[chkHdr.ID].Read(reader); // Ensure we read to end of structure this.ChunkMap[chkHdr.ID].SkipBytes(reader); // TODO: Change this to detect node with ~0 (0xFFFFFFFF) parent ID // Assume first node read in Model[0] is root node. This may be bad if they aren't in order! if (chkHdr.ChunkType == ChunkTypeEnum.Node && this.RootNode == null) { this.RootNode = this.ChunkMap[chkHdr.ID] as ChunkNode; } // Add Bones to the model. We are assuming there is only one CompiledBones chunk per file. if (chkHdr.ChunkType == ChunkTypeEnum.CompiledBones || chkHdr.ChunkType == ChunkTypeEnum.CompiledBonesSC) { this.Bones = this.ChunkMap[chkHdr.ID] as ChunkCompiledBones; SkinningInfo.HasSkinningInfo = true; } } }
private void Read_ChunkHeaders(BinaryReader b) { // need to seek to the start of the table here. foffset points to the start of the table b.BaseStream.Seek(this.ChunkTableOffset, SeekOrigin.Begin); for (Int32 i = 0; i < this.NumChunks; i++) { ChunkHeader header = Chunk.New <ChunkHeader>((uint)this.FileVersion); header.Read(b); this._chunks.Add(header); } }
public static Chunk New(ChunkTypeEnum chunkType, UInt32 version) { switch (chunkType) { case ChunkTypeEnum.SourceInfo: return(Chunk.New <ChunkSourceInfo>(version)); case ChunkTypeEnum.Timing: return(Chunk.New <ChunkTimingFormat>(version)); case ChunkTypeEnum.ExportFlags: return(Chunk.New <ChunkExportFlags>(version)); case ChunkTypeEnum.MtlName: return(Chunk.New <ChunkMtlName>(version)); case ChunkTypeEnum.DataStream: return(Chunk.New <ChunkDataStream>(version)); case ChunkTypeEnum.Mesh: return(Chunk.New <ChunkMesh>(version)); case ChunkTypeEnum.MeshSubsets: return(Chunk.New <ChunkMeshSubsets>(version)); case ChunkTypeEnum.Node: return(Chunk.New <ChunkNode>(version)); case ChunkTypeEnum.Helper: return(Chunk.New <ChunkHelper>(version)); case ChunkTypeEnum.Controller: return(Chunk.New <ChunkController>(version)); case ChunkTypeEnum.SceneProps: return(Chunk.New <ChunkSceneProp>(version)); case ChunkTypeEnum.MeshPhysicsData: return(Chunk.New <ChunkMeshPhysicsData>(version)); case ChunkTypeEnum.BoneAnim: return(Chunk.New <ChunkBoneAnim>(version)); // Compiled chunks case ChunkTypeEnum.CompiledBones: return(Chunk.New <ChunkCompiledBones>(version)); case ChunkTypeEnum.CompiledPhysicalProxies: return(Chunk.New <ChunkCompiledPhysicalProxies>(version)); case ChunkTypeEnum.CompiledPhysicalBones: return(Chunk.New <ChunkCompiledPhysicalBones>(version)); case ChunkTypeEnum.CompiledIntSkinVertices: return(Chunk.New <ChunkCompiledIntSkinVertices>(version)); case ChunkTypeEnum.CompiledMorphTargets: return(Chunk.New <ChunkCompiledMorphTargets>(version)); case ChunkTypeEnum.CompiledExt2IntMap: return(Chunk.New <ChunkCompiledExtToIntMap>(version)); case ChunkTypeEnum.CompiledIntFaces: return(Chunk.New <ChunkCompiledIntFaces>(version)); // Star Citizen equivalents case ChunkTypeEnum.CompiledBonesSC: return(Chunk.New <ChunkCompiledBones>(version)); case ChunkTypeEnum.CompiledPhysicalBonesSC: return(Chunk.New <ChunkCompiledPhysicalBones>(version)); case ChunkTypeEnum.CompiledExt2IntMapSC: return(Chunk.New <ChunkCompiledExtToIntMap>(version)); case ChunkTypeEnum.CompiledIntFacesSC: return(Chunk.New <ChunkCompiledIntFaces>(version)); case ChunkTypeEnum.CompiledIntSkinVerticesSC: return(Chunk.New <ChunkCompiledIntSkinVertices>(version)); case ChunkTypeEnum.CompiledMorphTargetsSC: return(Chunk.New <ChunkCompiledMorphTargets>(version)); case ChunkTypeEnum.CompiledPhysicalProxiesSC: return(Chunk.New <ChunkCompiledPhysicalProxies>(version)); // Old chunks case ChunkTypeEnum.BoneNameList: return(Chunk.New <ChunkBoneNameList>(version)); case ChunkTypeEnum.MeshMorphTarget: return(Chunk.New <ChunkMeshMorphTargets>(version)); case ChunkTypeEnum.Mtl: //Utils.Log(LogLevelEnum.Debug, "Mtl Chunk here"); // Obsolete. Not used default: return(new ChunkUnknown()); } }