protected override void ReadUnitData(BinaryReader xReader)
        {
            // Adjacent units are seperate from portals.
            // There can be multiple portals to the same unit.
            // Portals
            xReader.BaseStream.Position = _dataStart;
            UInt32 m_uConnectionData = _dataStart + xReader.ReadUInt32(); // Same as m_uModelData?

            xReader.BaseStream.Position = m_uConnectionData + 0x24;
            portalCount = xReader.ReadUInt32();
            xReader.BaseStream.Position = _dataStart + xReader.ReadUInt32();
            _portalNames = new String[portalCount];
            for (int i = 0; i < portalCount; i++)
            {
                String strUnitName = new String(xReader.ReadChars(16));
                _portalNames[i]              = Utility.CleanName(strUnitName);
                xReader.BaseStream.Position += 0x80;
            }

            // Instances
            xReader.BaseStream.Position = _dataStart + 0x44;
            _instanceCount = xReader.ReadUInt32();
            _instanceStart = _dataStart + xReader.ReadUInt32();
            _instanceNames = new String[_instanceCount];
            for (int i = 0; i < _instanceCount; i++)
            {
                xReader.BaseStream.Position = _instanceStart + 0x60 * i;
                String strInstanceName = new String(xReader.ReadChars(8));
                _instanceNames[i] = Utility.CleanName(strInstanceName);
            }

            // Instance types
            xReader.BaseStream.Position = _dataStart + 0x4C;
            _instanceTypeStart          = _dataStart + xReader.ReadUInt32();
            xReader.BaseStream.Position = _instanceTypeStart;
            List <String> xInstanceList = new List <String>();

            while (xReader.ReadByte() != 0xFF)
            {
                xReader.BaseStream.Position--;
                String strInstanceTypeName = new String(xReader.ReadChars(8));
                xInstanceList.Add(Utility.CleanName(strInstanceTypeName));
                xReader.BaseStream.Position += 0x08;
            }
            _instanceTypeNames = xInstanceList.ToArray();

            // Unit name
            xReader.BaseStream.Position = _dataStart + 0x50;
            xReader.BaseStream.Position = _dataStart + xReader.ReadUInt32();
            String strModelName = new String(xReader.ReadChars(10)); // Need to check

            _name = Utility.CleanName(strModelName);

            // Texture type
            //xReader.BaseStream.Position = m_uDataStart + 0x9C;
            //if (xReader.ReadUInt64() != 0xFFFFFFFFFFFFFFFF)
            //{
            //    m_ePlatform = Platform.PSX;
            //}
            //else
            //{
            _platform = Platform.PC;
            //}

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

            // Material data
            _models[0] = SR2UnitModel.Load(xReader, _dataStart, m_uModelData, _name, _platform, _version);

            //if (m_axModels[0].Platform == Platform.Dreamcast ||
            //    m_axModels[1].Platform == Platform.Dreamcast)
            //{
            //    m_ePlatform = Platform.Dreamcast;
            //}
        }
Beispiel #2
0
        protected override void ReadUnitData(BinaryReader reader, ExportOptions options)
        {
            // Adjacent units are seperate from portals.
            // There can be multiple portals to the same unit.
            // Portals
            reader.BaseStream.Position = _dataStart;
            UInt32 m_uConnectionData = _dataStart + reader.ReadUInt32();             // Same as m_uModelData?

            reader.BaseStream.Position = m_uConnectionData + 0x24;
            portalCount = reader.ReadUInt32();
            reader.BaseStream.Position = _dataStart + reader.ReadUInt32();
            _portalNames = new String[portalCount];
            for (int i = 0; i < portalCount; i++)
            {
                String strUnitName = new String(reader.ReadChars(16));
                _portalNames[i]             = Utility.CleanName(strUnitName);
                reader.BaseStream.Position += 0x80;
            }

            // Intros
            reader.BaseStream.Position = _dataStart + 0x44;
            _introCount = reader.ReadUInt32();
            _introStart = _dataStart + reader.ReadUInt32();
            _intros     = new Intro[_introCount];
            for (int i = 0; i < _introCount; i++)
            {
                reader.BaseStream.Position = _introStart + 0x60 * i;
                String introName = new String(reader.ReadChars(16));
                _intros[i].rotation.x       = reader.ReadSingle();
                _intros[i].rotation.y       = reader.ReadSingle();
                _intros[i].rotation.z       = reader.ReadSingle();
                reader.BaseStream.Position += 0x04;
                _intros[i].position.x       = reader.ReadSingle();
                _intros[i].position.y       = reader.ReadSingle();
                _intros[i].position.z       = reader.ReadSingle();
                reader.BaseStream.Position += 0x04;
                reader.BaseStream.Position += 0x10;
                _intros[i].introNum         = reader.ReadInt32();
                _intros[i].uniqueID         = reader.ReadInt32();
                _intros[i].name             = Utility.CleanObjectName(introName) + "-" + _intros[i].uniqueID;
                _intros[i].fileName         = Utility.CleanObjectName(introName);
            }

            // Object Names
            reader.BaseStream.Position = _dataStart + 0x4C;
            _objectNameStart           = _dataStart + reader.ReadUInt32();
            reader.BaseStream.Position = _objectNameStart;
            List <String> objectNames = new List <String>();

            while (reader.ReadByte() != 0xFF)
            {
                reader.BaseStream.Position--;
                String strObjectName = new String(reader.ReadChars(8));
                objectNames.Add(Utility.CleanObjectName(strObjectName));
                reader.BaseStream.Position += 0x08;
            }
            _objectNames = objectNames.ToArray();

            // Unit name
            reader.BaseStream.Position = _dataStart + 0x50;
            reader.BaseStream.Position = _dataStart + reader.ReadUInt32();
            String strModelName = new String(reader.ReadChars(10));             // Need to check

            _name = Utility.CleanName(strModelName);

            // Texture type
            //reader.BaseStream.Position = _dataStart + 0x9C;
            //if (reader.ReadUInt64() != 0xFFFFFFFFFFFFFFFF)
            //{
            //    _platform = Platform.PSX;
            //}
            //else
            //{
            if (options.ForcedPlatform == CDC.Platform.None)
            {
                _platform = Platform.PC;
            }
            else
            {
                _platform = options.ForcedPlatform;
            }
            //}

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

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

            //if (m_axModels[0].Platform == Platform.Dreamcast ||
            //    m_axModels[1].Platform == Platform.Dreamcast)
            //{
            //    _platform = Platform.Dreamcast;
            //}
        }