Esempio n. 1
0
        protected override void ReadObjectData(BinaryReader reader, ExportOptions options)
        {
            // Object name
            reader.BaseStream.Position = _dataStart + 0x00000024;
            reader.BaseStream.Position = reader.ReadUInt32();
            String strModelName = new String(reader.ReadChars(8));

            _name = Utility.CleanObjectName(strModelName);

            // Texture type
            if (options.ForcedPlatform == CDC.Platform.None)
            {
                _platform = Platform.PSX;
            }
            else
            {
                _platform = options.ForcedPlatform;
            }

            // Model data
            reader.BaseStream.Position = _dataStart + 0x00000008;
            _modelCount = reader.ReadUInt16();
            _animCount  = reader.ReadUInt16();
            _modelStart = reader.ReadUInt32();
            _animStart  = reader.ReadUInt32();

            _models = new GexModel[_modelCount];
            Platform ePlatform = _platform;

            for (UInt16 m = 0; m < _modelCount; m++)
            {
                Console.WriteLine(string.Format("Debug: reading object model {0} / {1}", m, (_modelCount - 1)));
                _models[m] = GexObjectModel.Load(reader, _dataStart, _modelStart, _name, _platform, m, _version, _tPages, options);
            }
            if (options.ForcedPlatform == CDC.Platform.None)
            {
                _platform = ePlatform;
            }
        }
Esempio n. 2
0
        protected override void ReadUnitData(BinaryReader reader, ExportOptions options)
        {
            bool validVersion = false;

            if (options.ForcedPlatform != Platform.None)
            {
                _platform = options.ForcedPlatform;
            }

            if (!validVersion)
            {
                reader.BaseStream.Position = _dataStart + 0x08;
                _version = reader.ReadUInt32();
                if (_version == RETAIL_VERSION)
                {
                    validVersion = true;
                }
            }

            if (!validVersion)
            {
                throw new Exception("Wrong version number for level x");
            }

            // Object Names
            reader.BaseStream.Position = _dataStart + 0x3C;
            _objectNameStart           = reader.ReadUInt32();
            reader.BaseStream.Position = _objectNameStart;
            List <string> objectNames = new List <string>();
            List <SRFile> objectList  = new List <SRFile>();

            while (true)
            {
                UInt32 objectAddress = reader.ReadUInt32();
                if (objectAddress == _objectNameStart)
                {
                    break;
                }

                long oldPos = reader.BaseStream.Position;

                reader.BaseStream.Position = objectAddress + 0x00000024;
                reader.BaseStream.Position = reader.ReadUInt32();
                string objectName = new string(reader.ReadChars(8));
                objectName = Utility.CleanObjectName(objectName);

                reader.BaseStream.Position = objectAddress;
                GexFile gexObject = new GexFile(objectName, options, reader);

                objectNames.Add(objectName);
                objectList.Add(gexObject);

                reader.BaseStream.Position = oldPos;
            }
            _objectNames = objectNames.ToArray();
            _objects     = objectList.ToArray();

            // Intros
            reader.BaseStream.Position = _dataStart + 0x7C;
            _introCount = reader.ReadUInt32();
            _introStart = reader.ReadUInt32();
            _intros     = new Intro[_introCount];
            for (int i = 0; i < _introCount; i++)
            {
                reader.BaseStream.Position = _introStart + 0x34 * i;

                UInt32 objectStart = reader.ReadUInt32();
                if (objectStart == 0)
                {
                    _intros[i].name     = "Intro(0)-" + _intros[i].uniqueID;
                    _intros[i].fileName = "";
                }
                else
                {
                    reader.BaseStream.Position = objectStart + 0x00000024;
                    reader.BaseStream.Position = reader.ReadUInt32();
                    String introName = new String(reader.ReadChars(8));
                    _intros[i].name     = Utility.CleanObjectName(introName) + "-" + _intros[i].uniqueID;
                    _intros[i].fileName = Utility.CleanObjectName(introName);
                }
            }

            // Unit name. No names in Gex :(
            //reader.BaseStream.Position = _dataStart + 0x98;
            //reader.BaseStream.Position = reader.ReadUInt32();
            //String strModelName = new String(reader.ReadChars(8));
            //_name = Utility.CleanName(strModelName);

            // Texture type
            if (options.ForcedPlatform == CDC.Platform.None)
            {
                _platform = Platform.PSX;
            }

            // Model data
            reader.BaseStream.Position = _dataStart;
            _modelCount = 1;
            _modelStart = _dataStart;
            _models     = new GexModel[_modelCount];
            reader.BaseStream.Position = _modelStart;
            UInt32 m_uModelData = reader.ReadUInt32();

            // Material data
            Console.WriteLine("Debug: reading area model 0");
            _models[0] = GexUnitModel.Load(reader, _dataStart, m_uModelData, _name, _platform, _version, _tPages, options);
        }