public override ShapeChunkType ReadChunkHeader(out string chunkName) { if (m_remainingLeafChunkByteCount == 0) { chunkName = ""; return(ShapeChunkType.EndOfChunk); } ShapeChunkType chunkType = (ShapeChunkType)m_binaryReader.ReadUInt16(); m_binaryReader.ReadUInt16(); // Skip chunk flags int chunkContentSize = (int)m_binaryReader.ReadUInt32(); int chunkNameLength = m_binaryReader.ReadByte(); if (chunkNameLength == 0) { chunkName = ""; } else { byte[] buffer = m_binaryReader.ReadBytes(chunkNameLength * 2); chunkName = Encoding.Unicode.GetString(buffer, 0, chunkNameLength * 2); } m_remainingChunkByteCounts.Push(m_remainingLeafChunkByteCount - chunkContentSize - 8); m_remainingLeafChunkByteCount = chunkContentSize - 1 - 2 * chunkNameLength; return(chunkType); }
private bool LoadChunk() { string chunkName; ShapeChunkType chunkType = m_chunkReader.ReadChunkHeader(out chunkName); if (chunkType == ShapeChunkType.EndOfChunk) { return(false); } if (m_chunkReader.EndOfStream) { return(false); } bool readChunkEnd; switch (chunkType) { case ShapeChunkType.shape: readChunkEnd = LoadShapeChunk(); break; case ShapeChunkType.points: readChunkEnd = LoadPointsChunk(); break; case ShapeChunkType.point: readChunkEnd = LoadPointChunk(); break; case ShapeChunkType.uv_points: readChunkEnd = LoadUVPointsChunk(); break; case ShapeChunkType.uv_point: readChunkEnd = LoadUVPointChunk(); break; case ShapeChunkType.normals: readChunkEnd = LoadNormalsChunk(); break; case ShapeChunkType.vector: readChunkEnd = LoadVectorChunk(); break; case ShapeChunkType.matrices: readChunkEnd = LoadMatricesChunk(); break; case ShapeChunkType.matrix: readChunkEnd = LoadMatrixChunk(chunkName); break; case ShapeChunkType.lod_controls: readChunkEnd = LoadLODControlsChunk(); break; case ShapeChunkType.lod_control: readChunkEnd = LoadLODControlChunk(); break; case ShapeChunkType.distance_levels: readChunkEnd = LoadDistanceLevelsChunk(); break; case ShapeChunkType.distance_level: readChunkEnd = LoadDistanceLevelChunk(); break; case ShapeChunkType.distance_level_header: readChunkEnd = LoadDistanceLevelHeaderChunk(); break; case ShapeChunkType.hierarchy: if (m_currentDistanceLevelIndex == 0) { readChunkEnd = LoadHierarchyChunk(); break; } goto default; case ShapeChunkType.sub_objects: readChunkEnd = LoadSubObjectsChunk(); break; case ShapeChunkType.sub_object: readChunkEnd = LoadSubObjectChunk(); break; case ShapeChunkType.vertices: readChunkEnd = LoadVerticesChunk(); break; case ShapeChunkType.vertex: readChunkEnd = LoadVertexChunk(); break; case ShapeChunkType.vertex_uvs: readChunkEnd = LoadVertexUVsChunk(); break; case ShapeChunkType.primitives: readChunkEnd = LoadPrimitivesChunk(); break; case ShapeChunkType.indexed_trilist: readChunkEnd = LoadIndexedTrilistChunk(); break; case ShapeChunkType.vertex_idxs: readChunkEnd = LoadVertexIndicesChunk(); break; case ShapeChunkType.images: readChunkEnd = LoadImagesChunk(); break; case ShapeChunkType.image: readChunkEnd = LoadImageChunk(); break; case ShapeChunkType.textures: readChunkEnd = LoadTexturesChunk(); break; case ShapeChunkType.texture: readChunkEnd = LoadTextureChunk(); break; case ShapeChunkType.shader_names: readChunkEnd = LoadShaderNamesChunk(); break; case ShapeChunkType.vtx_states: readChunkEnd = LoadVertexStatesChunk(); break; case ShapeChunkType.vtx_state: readChunkEnd = LoadVertexStateChunk(); break; case ShapeChunkType.prim_states: readChunkEnd = LoadPrimitiveStatesChunk(); break; case ShapeChunkType.prim_state: readChunkEnd = LoadPrimitiveStateChunk(); break; case ShapeChunkType.prim_state_idx: readChunkEnd = LoadPrimitiveStateIndexChunk(); break; case ShapeChunkType.tex_idxs: readChunkEnd = LoadTextureIndicesChunk(); break; case ShapeChunkType.animations: readChunkEnd = LoadAnimationsChunk(); break; case ShapeChunkType.animation: readChunkEnd = LoadAnimationChunk(); break; case ShapeChunkType.anim_nodes: readChunkEnd = LoadAnimationNodesChunk(); break; case ShapeChunkType.anim_node: readChunkEnd = LoadAnimationNodeChunk(chunkName); break; case ShapeChunkType.controllers: readChunkEnd = LoadAnimationControllersChunk(); break; case ShapeChunkType.tcb_rot: readChunkEnd = LoadTCBRotControllerChunk(); break; case ShapeChunkType.tcb_key: readChunkEnd = LoadTCBKeyChunk(); break; case ShapeChunkType.slerp_rot: readChunkEnd = LoadSlerpKeyChunk(); break; case ShapeChunkType.linear_pos: readChunkEnd = LoadLinearPosControllerChunk(); break; case ShapeChunkType.linear_key: readChunkEnd = LoadLinearKeyChunk(); break; default: m_chunkReader.SkipRemainingChunk(); readChunkEnd = false; break; } m_chunkReader.EndChunk(readChunkEnd); return(true); }