コード例 #1
0
        private List <BiowareModel> readTerrainModels()
        {
            BinaryReader file = headerFile.openReader();

            int  numSectors, reference;
            long startOfList;

            //Seek to the reference to the terrain chunk list and get it
            file.BaseStream.Seek(headerFile.dataOffset + headerFile.structs[TOP_LEVEL_STRUCT_INDEX].fields[TERRAIN_CHUNK_LIST_INDEX].index, SeekOrigin.Begin);
            reference = file.ReadInt32();
            //Seek to the list
            file.BaseStream.Seek(headerFile.dataOffset + reference, SeekOrigin.Begin);
            //Get the lenght of the list
            numSectors = file.ReadInt32();

            //Make a list for the terrain meshes
            List <BiowareModel> terrainModels = new List <BiowareModel>(numSectors);

            int         currentSectorFileIndex, currentSectorID = 0;
            uint        currentSectorModelID = 1;
            GFF         currentSectorFile;
            TerrainMesh currentTerrainMesh;

            startOfList = file.BaseStream.Position;
            for (int i = 0; i < numSectors; i++)
            {
                //Seek to the next struct in the list and get the model id and sector id
                file.BaseStream.Seek(startOfList + (i * terrainChunkStruct.structSize), SeekOrigin.Begin);
                //THIS IS UNSAFE ACCESS TO STRUCT FIELDS!!!!!
                currentSectorModelID = file.ReadUInt32();
                currentSectorID      = file.ReadInt32();

                //Get the index of the next sector file
                currentSectorFileIndex = diskFile.indexOf(String.Format("sector{0:0000}.tmsh", currentSectorID));
                //If its not there something is wrong
                if (currentSectorFileIndex < 0)
                {
                    Console.WriteLine("Could not find file \"sector00" + i + ".tmsh\" :(");
                }
                //Otherwise read it in
                else
                {
                    currentSectorFile  = new GFF(diskFile.path, diskFile.resourceOffsets[currentSectorFileIndex]);
                    currentTerrainMesh = new TerrainMesh(currentSectorFile);
                    terrainModels.Add(currentTerrainMesh.toModel(currentSectorModelID));
                }
            }


            return(terrainModels);
        }
コード例 #2
0
        private List<BiowareModel> readTerrainModels()
        {

            BinaryReader file = headerFile.openReader();

            int numSectors, reference;
            long startOfList;

            //Seek to the reference to the terrain chunk list and get it
            file.BaseStream.Seek(headerFile.dataOffset + headerFile.structs[TOP_LEVEL_STRUCT_INDEX].fields[TERRAIN_CHUNK_LIST_INDEX].index, SeekOrigin.Begin);
            reference = file.ReadInt32();
            //Seek to the list
            file.BaseStream.Seek(headerFile.dataOffset + reference, SeekOrigin.Begin);
            //Get the lenght of the list
            numSectors = file.ReadInt32();

            //Make a list for the terrain meshes
            List<BiowareModel> terrainModels = new List<BiowareModel>(numSectors);

            int currentSectorFileIndex,currentSectorID = 0;
            uint currentSectorModelID = 1;
            GFF currentSectorFile;
            TerrainMesh currentTerrainMesh;

            startOfList = file.BaseStream.Position;
            for (int i = 0; i < numSectors; i++)
            {
                //Seek to the next struct in the list and get the model id and sector id
                file.BaseStream.Seek(startOfList + (i * terrainChunkStruct.structSize), SeekOrigin.Begin);
                //THIS IS UNSAFE ACCESS TO STRUCT FIELDS!!!!!
                currentSectorModelID = file.ReadUInt32();
                currentSectorID = file.ReadInt32();

                //Get the index of the next sector file
                currentSectorFileIndex = diskFile.indexOf(String.Format("sector{0:0000}.tmsh",currentSectorID));
                //If its not there something is wrong
                if(currentSectorFileIndex < 0)
                {
                    Console.WriteLine("Could not find file \"sector00"+i+".tmsh\" :(");
                }
                //Otherwise read it in
                else
                {
                    currentSectorFile = new GFF(diskFile.path, diskFile.resourceOffsets[currentSectorFileIndex]);
                    currentTerrainMesh = new TerrainMesh(currentSectorFile);
                    terrainModels.Add(currentTerrainMesh.toModel(currentSectorModelID));
                }
            }


            return terrainModels;
        }