Example #1
0
        public World_000B Read(BinaryReader binaryReader)
        {
            sectionIdentifier = Section.World;
            sectionSize       = binaryReader.ReadInt32();
            renderWareVersion = binaryReader.ReadInt32();

            long startSectionPosition = binaryReader.BaseStream.Position;

            Section worldStructSection = (Section)binaryReader.ReadInt32();

            if (worldStructSection != Section.Struct)
            {
                throw new Exception(binaryReader.BaseStream.Position.ToString());
            }
            worldStruct = new WorldStruct_0001().Read(binaryReader);

            Section materialListSection = (Section)binaryReader.ReadInt32();

            if (materialListSection != Section.MaterialList)
            {
                throw new Exception();
            }
            materialList = new MaterialList_0008().Read(binaryReader);

            Section firstWorldChunkSection = (Section)binaryReader.ReadInt32();

            if (firstWorldChunkSection == Section.AtomicSector)
            {
                firstWorldChunk = new AtomicSector_0009().Read(binaryReader);
            }
            else if (firstWorldChunkSection == Section.PlaneSector)
            {
                firstWorldChunk = new PlaneSector_000A().Read(binaryReader);
            }
            else
            {
                throw new Exception();
            }

            Section worldExtensionSection = (Section)binaryReader.ReadInt32();

            if (worldExtensionSection == Section.Extension)
            {
                worldExtension = new Extension_0003().Read(binaryReader);
            }

            binaryReader.BaseStream.Position = startSectionPosition + sectionSize;

            return(this);
        }
Example #2
0
        public Geometry_000F Read(BinaryReader binaryReader)
        {
            sectionIdentifier = Section.Geometry;
            sectionSize       = binaryReader.ReadInt32();
            renderWareVersion = binaryReader.ReadInt32();

            long startSectionPosition = binaryReader.BaseStream.Position;

            Section geometryStructSection = (Section)binaryReader.ReadInt32();

            if (geometryStructSection != Section.Struct)
            {
                throw new Exception(binaryReader.BaseStream.Position.ToString());
            }
            geometryStruct = new GeometryStruct_0001().Read(binaryReader);

            Section materialListSection = (Section)binaryReader.ReadInt32();

            if (materialListSection != Section.MaterialList)
            {
                throw new Exception(binaryReader.BaseStream.Position.ToString());
            }
            materialList = new MaterialList_0008().Read(binaryReader);

            Section geometryExtensionSection = (Section)binaryReader.ReadInt32();

            if (geometryExtensionSection != Section.Extension)
            {
                throw new Exception(binaryReader.BaseStream.Position.ToString());
            }
            geometryExtension = new Extension_0003().Read(binaryReader);

            binaryReader.BaseStream.Position = startSectionPosition + sectionSize;

            return(this);
        }