protected override void ReadObjectData(BinaryReader reader, ExportOptions options) { // Object name. No names in TRL :( //reader.BaseStream.Position = _dataStart + 0x00000024; //reader.BaseStream.Position = _dataStart + reader.ReadUInt32(); //String strModelName = new String(reader.ReadChars(8)); //_name = Utility.CleanObjectName(strModelName); // Texture type //reader.BaseStream.Position = _dataStart + 0x44; //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 + 0x00000018; _modelCount = reader.ReadUInt16(); _modelCount = 1; // There are multiple models, but TRL might have too many. Override for now. _animCount = 0; //reader.ReadUInt16(); reader.BaseStream.Position += 0x06; _modelStart = _dataStart + reader.ReadUInt32(); _animStart = 0; //_dataStart + reader.ReadUInt32(); _models = new TRLModel[_modelCount]; for (UInt16 m = 0; m < _modelCount; m++) { _models[m] = TRLObjectModel.Load(reader, _dataStart, _modelStart, _name, _platform, m, _version, options); } }
protected override void ReadUnitData(BinaryReader reader, ExportOptions options) { // Adjacent units are seperate from portals. // There can be multiple portals to the same unit. // Portals /*UInt32 m_uConnectionData = _dataStart + reader.ReadUInt32(); // Same as m_uModelData? * reader.BaseStream.Position = m_uConnectionData + 0x10; * 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 += 0x90; * }*/ // Intros reader.BaseStream.Position = _dataStart + 0x74; _introCount = reader.ReadUInt32(); _introStart = _dataStart + reader.ReadUInt32(); _intros = new Intro[_introCount]; for (int i = 0; i < _introCount; i++) { reader.BaseStream.Position = _introStart + 0x70 * i; _intros[i].rotation.x = reader.ReadSingle(); _intros[i].rotation.y = reader.ReadSingle(); _intros[i].rotation.x = reader.ReadSingle(); reader.BaseStream.Position += 0x4; _intros[i].position.x = reader.ReadSingle(); _intros[i].position.y = reader.ReadSingle(); _intros[i].position.z = reader.ReadSingle(); reader.BaseStream.Position += 0x4; reader.BaseStream.Position += 0x30; _intros[i].objectID = reader.ReadInt16(); _intros[i].introNum = reader.ReadInt16(); _intros[i].uniqueID = reader.ReadInt32(); _intros[i].name = "Intro(" + _intros[i].objectID + ")-" + _intros[i].uniqueID; _intros[i].fileName = ""; } // Object Names reader.BaseStream.Position = _dataStart + 0x7C; _objectNameStart = _dataStart + reader.ReadUInt32(); reader.BaseStream.Position = _objectNameStart; List <Int16> objectIDs = new List <Int16>(); while (true) { Int16 objectID = reader.ReadInt16(); if (objectID == 0) { break; } objectIDs.Add(objectID); } _objectNames = new string[objectIDs.Count]; _objectIDs = objectIDs.ToArray(); // Unit name reader.BaseStream.Position = _dataStart + 0x80; reader.BaseStream.Position = _dataStart + reader.ReadUInt32(); String strModelName = new String(reader.ReadChars(32)); // 128 for Underworld. _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 _modelCount = 1; _models = new TRLModel[_modelCount]; reader.BaseStream.Position = _dataStart; UInt32 m_uModelData = _dataStart + reader.ReadUInt32(); // Material data Console.WriteLine("Debug: reading area model 0"); _models[0] = TRLUnitModel.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; //} }