public ModelRoot(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.Version = br.ReadIFFChunk <TerrainVersion>(); this.Header = br.ReadIFFChunk <ModelRootHeader>(); this.Textures = br.ReadIFFChunk <ModelTextures>(); this.Materials = br.ReadIFFChunk <ModelMaterials>(); this.GroupNames = br.ReadIFFChunk <ModelGroupNames>(); this.GroupInformation = br.ReadIFFChunk <ModelGroupInformation>(); this.Skybox = br.ReadIFFChunk <ModelSkybox>(); this.PortalVertices = br.ReadIFFChunk <ModelPortalVertices>(); this.Portals = br.ReadIFFChunk <ModelPortals>(); this.PortalReferences = br.ReadIFFChunk <ModelPortalReferences>(); this.VisibleVertices = br.ReadIFFChunk <ModelVisibleVertices>(); this.VisibleBlocks = br.ReadIFFChunk <ModelVisibleBlocks>(); this.StaticLighting = br.ReadIFFChunk <ModelStaticLighting>(); this.DoodadSets = br.ReadIFFChunk <ModelDoodadSets>(); this.DoodadPaths = br.ReadIFFChunk <ModelDoodadPaths>(); this.DoodadInstances = br.ReadIFFChunk <ModelDoodadInstances>(); this.Fog = br.ReadIFFChunk <ModelFog>(); // Optional chunk if ((br.BaseStream.Position != br.BaseStream.Length) && br.PeekChunkSignature() == ModelConvexPlanes.Signature) { this.ConvexPlanes = br.ReadIFFChunk <ModelConvexPlanes>(); } // Version-dependent chunk if ((br.BaseStream.Position != br.BaseStream.Length) && br.PeekChunkSignature() == ModelGameObjectFileID.Signature) { this.GameObjectFileID = br.ReadIFFChunk <ModelGameObjectFileID>(); } } } }
public ModelRoot(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.Version = br.ReadIFFChunk<TerrainVersion>(); this.Header = br.ReadIFFChunk<ModelRootHeader>(); this.Textures = br.ReadIFFChunk<ModelTextures>(); this.Materials = br.ReadIFFChunk<ModelMaterials>(); this.GroupNames = br.ReadIFFChunk<ModelGroupNames>(); this.GroupInformation = br.ReadIFFChunk<ModelGroupInformation>(); this.Skybox = br.ReadIFFChunk<ModelSkybox>(); this.PortalVertices = br.ReadIFFChunk<ModelPortalVertices>(); this.Portals = br.ReadIFFChunk<ModelPortals>(); this.PortalReferences = br.ReadIFFChunk<ModelPortalReferences>(); this.VisibleVertices = br.ReadIFFChunk<ModelVisibleVertices>(); this.VisibleBlocks = br.ReadIFFChunk<ModelVisibleBlocks>(); this.StaticLighting = br.ReadIFFChunk<ModelStaticLighting>(); this.DoodadSets = br.ReadIFFChunk<ModelDoodadSets>(); this.DoodadPaths = br.ReadIFFChunk<ModelDoodadPaths>(); this.DoodadInstances = br.ReadIFFChunk<ModelDoodadInstances>(); this.Fog = br.ReadIFFChunk<ModelFog>(); // Optional chunk if ((br.BaseStream.Position != br.BaseStream.Length) && br.PeekChunkSignature() == ModelConvexPlanes.Signature) { this.ConvexPlanes = br.ReadIFFChunk<ModelConvexPlanes>(); } // Version-dependent chunk if ((br.BaseStream.Position != br.BaseStream.Length) && br.PeekChunkSignature() == ModelGameObjectFileID.Signature) { this.GameObjectFileID = br.ReadIFFChunk<ModelGameObjectFileID>(); } } } }