Ejemplo n.º 1
0
        private void ReadFamFile(string filename)
        {
            filename = Path.Combine(GameConfig.CdDataPath, filename);
            BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));

            _root = new HeaderChunk();
            _root.Read(reader, false);  //we want to load everything up front
            reader.Close();
        }
Ejemplo n.º 2
0
        private void ReadChunk(BinaryReader reader, bool readHeaderOnly)
        {
            string identifier = new string(reader.ReadChars(4));

            if (identifier == "ORIP")
            {
                MeshChunk meshChunk = new MeshChunk();
                if (readHeaderOnly)
                {
                    meshChunk.Offset = reader.BaseStream.Position;
                }
                else
                {
                    meshChunk.Read(reader);
                }
                _meshChunks.Add(meshChunk);
            }
            else if (identifier == "SHPI")
            {
                BitmapChunk bitmapChunk = new BitmapChunk();
                bitmapChunk.Index = _index++;
                if (readHeaderOnly)
                {
                    bitmapChunk.Offset = reader.BaseStream.Position;
                }
                else
                {
                    bitmapChunk.Read(reader);
                }
                _bitmapChunks.Add(bitmapChunk);
            }
            else if (identifier == "wwww")
            {
                HeaderChunk header = new HeaderChunk();
                if (readHeaderOnly)
                {
                    header.Offset = reader.BaseStream.Position;
                }
                else
                {
                    header.Read(reader, false, false);
                }
                _headerChunks.Add(header);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 3
0
        private void Parse(string filename)
        {
            string carFile = Path.Combine(GameConfig.CdDataPath, filename);
            BinaryReader br = new BinaryReader(File.Open(carFile, FileMode.Open));
            HeaderChunk rootChunk = new HeaderChunk();
            rootChunk.Read(br, true);

            // Cfm files contain a high-res model + bitmaps at index 0, and a low-res model + bitmaps at index 1.  We only use the high-res resources.
            rootChunk.MeshChunks[0].Load(br);
            rootChunk.BitmapChunks[0].TextureGenerated += CfmFile_TextureGenerated;
            rootChunk.BitmapChunks[0].Load(br);

            br.Close();

            Mesh = new CarMesh(rootChunk.MeshChunks[0], rootChunk.BitmapChunks[0], _brakeColor);
        }
Ejemplo n.º 4
0
        private void Parse(string filename)
        {
            string       carFile   = Path.Combine(GameConfig.CdDataPath, filename);
            BinaryReader br        = new BinaryReader(File.Open(carFile, FileMode.Open));
            HeaderChunk  rootChunk = new HeaderChunk();

            rootChunk.Read(br, true);

            // Cfm files contain a high-res model + bitmaps at index 0, and a low-res model + bitmaps at index 1.  We only use the high-res resources.
            rootChunk.MeshChunks[0].Load(br);
            rootChunk.BitmapChunks[0].TextureGenerated += CfmFile_TextureGenerated;
            rootChunk.BitmapChunks[0].Load(br);

            br.Close();

            Mesh = new CarMesh(rootChunk.MeshChunks[0], rootChunk.BitmapChunks[0], _brakeColor);
        }
Ejemplo n.º 5
0
        private void ReadChunk(BinaryReader reader, bool readHeaderOnly)
        {
            string identifier = new string(reader.ReadChars(4));

            if (identifier == "ORIP")
            {
                MeshChunk meshChunk = new MeshChunk();
                if (readHeaderOnly)
                    meshChunk.Offset = reader.BaseStream.Position;
                else
                {
                    meshChunk.Read(reader);
                }
                _meshChunks.Add(meshChunk);
            }
            else if (identifier == "SHPI")
            {
                BitmapChunk bitmapChunk = new BitmapChunk();
                bitmapChunk.Index = _index++;
                if (readHeaderOnly)
                    bitmapChunk.Offset = reader.BaseStream.Position;
                else
                    bitmapChunk.Read(reader);
                _bitmapChunks.Add(bitmapChunk);
            }
            else if (identifier == "wwww")
            {
                HeaderChunk header = new HeaderChunk();
                if (readHeaderOnly)
                    header.Offset = reader.BaseStream.Position;
                else
                    header.Read(reader, false, false);
                _headerChunks.Add(header);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 6
0
 private void ReadFamFile(string filename)
 {
     filename = Path.Combine(GameConfig.CdDataPath, filename);
     BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));
     _root = new HeaderChunk();
     _root.Read(reader, false);  //we want to load everything up front
     reader.Close();
 }