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; } }
protected SRFile(String dataFile, Game game, ExportOptions options) { _name = Path.GetFileNameWithoutExtension(dataFile); _game = game; //String strDebugFileName = Path.GetDirectoryName(strFileName) + "\\" + Path.GetFileNameWithoutExtension(strFileName) + "-Debug.txt"; //LogFile = File.CreateText(strDebugFileName); FileStream file = new FileStream(dataFile, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(file, System.Text.Encoding.ASCII); MemoryStream stream = new MemoryStream((int)file.Length); BinaryWriter writer = new BinaryWriter(stream, System.Text.Encoding.ASCII); ResolvePointers(reader, writer); reader.Close(); reader = new BinaryReader(stream, System.Text.Encoding.ASCII); ReadData(reader, options); reader.Close(); LogFile?.Close(); }
public SR2File(String dataFile, ExportOptions options) : base(dataFile, Game.SR2, 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 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; //} }
public bool ExportToFile(String fileName, ExportOptions options) { string name = Utility.CleanName(Name).TrimEnd(new char[] { '_' }); //Assimp.Node rootNode = new Assimp.Node(name); //List<Assimp.Material> materials = new List<Assimp.Material>(); //List<Assimp.Mesh> meshes = new List<Assimp.Mesh>(); string perModelFilename = fileName; for (int modelIndex = 0; modelIndex < ModelCount; modelIndex++) { Assimp.Node rootNode = new Assimp.Node(name); List <Assimp.Material> materials = new List <Assimp.Material>(); List <Assimp.Mesh> meshes = new List <Assimp.Mesh>(); SRModel model = Models[modelIndex]; string modelName = name + "-" + modelIndex; Console.WriteLine(string.Format("Debug: exporting model {0} / {1} ('{2}')", modelIndex, (ModelCount - 1), modelName)); perModelFilename = fileName; if (ModelCount > 1) { string extension = Path.GetExtension(fileName); if ((extension.StartsWith(".")) && (extension.Length > 1)) { extension = extension.Substring(1); } perModelFilename = string.Format("{0}{1}{2}-model_{3:D4}.{4}", Path.GetDirectoryName(fileName), Path.DirectorySeparatorChar, Path.GetFileNameWithoutExtension(fileName), modelIndex, extension); } Assimp.Node modelNode = new Assimp.Node(modelName); for (int groupIndex = 0; groupIndex < model.GroupCount; groupIndex++) { Tree group = model.Groups[groupIndex]; if (group == null) { continue; } //if (options.DiscardPortalPolygons && (groupIndex == (model.GroupCount - 1))) //{ // continue; //} string groupName = name + "-" + modelIndex + "-" + groupIndex; Console.WriteLine(string.Format("\tDebug: exporting group {0} / {1} ('{2}'), mesh flags {3}", groupIndex, (model.GroupCount - 1), groupName, Convert.ToString(group.mesh.sr1BSPTreeFlags, 2).PadLeft(8, '0'))); if (group.mesh.sr1BSPNodeFlags.Count > 0) { //Console.WriteLine(string.Format("\t\t\tDebug: BSP node flags for this mesh:")); for (int flagNum = 0; flagNum < group.mesh.sr1BSPNodeFlags.Count; flagNum++) { //Console.WriteLine(string.Format("\t\t\t\tBSP node flags {0}", Convert.ToString(group.mesh.sr1BSPNodeFlags[flagNum], 2).PadLeft(8, '0'))); } } else { // Console.WriteLine(string.Format("\t\t\tDebug: No BSP node flags for this mesh")); } if (group.mesh.sr1BSPLeafFlags.Count > 0) { //Console.WriteLine(string.Format("\t\t\tDebug: BSP leaf flags for this mesh:")); for (int flagNum = 0; flagNum < group.mesh.sr1BSPLeafFlags.Count; flagNum++) { //Console.WriteLine(string.Format("\t\t\t\tBSP leaf flags {0}", Convert.ToString(group.mesh.sr1BSPLeafFlags[flagNum], 2).PadLeft(8, '0'))); } } else { //Console.WriteLine(string.Format("\t\t\tDebug: No BSP leaf flags for this mesh")); } Assimp.Node groupNode = new Assimp.Node(groupName); for (int materialIndex = 0; materialIndex < model.MaterialCount; materialIndex++) { Console.WriteLine(string.Format("\t\tDebug: exporting material {0} / {1}", materialIndex, (model.MaterialCount - 1))); int totalPolygonCount = (int)group.mesh.polygonCount; List <int> polygonList = new List <int>(); for (int p = 0; p < totalPolygonCount; p++) { if (group.mesh.polygons[p].material.ID == materialIndex) { polygonList.Add(p); } } int polygonCount = polygonList.Count; if (polygonCount > 0) { #region Mesh string meshName = name + "-" + modelIndex + "-" + groupIndex + "-" + materialIndex; //string materialNamePrefix = string.Format("{0}-{1}", name, materialIndex); string materialNamePrefix = meshName; Assimp.Mesh mesh = new Assimp.Mesh(meshName); bool addMesh = true; // this is a hack :\ int numNonZeroFlagsForMesh = 0; //bool isTranslucent = false; //float materialOpacity = 1.0f; mesh.PrimitiveType = Assimp.PrimitiveType.Triangle; Console.WriteLine(string.Format("\t\t\tDebug: exporting mesh '{0}'", meshName)); ref Polygon[] polygons = ref group.mesh.polygons; int i = 0; for (int p = 0; p < polygonCount; p++) { ref Polygon polygon = ref polygons[polygonList[p]]; if (polygon.material.polygonFlags != 0) { numNonZeroFlagsForMesh++; } //uint mAlpha = (polygon.material.colour & 0xFF000000) >> 24; //if ((mAlpha != 0xFF) && (mAlpha != 0x00)) //{ // isTranslucent = true; // materialOpacity = (float)(mAlpha) / 255.0f; //} if ((polygon.material.visible) || (!options.DiscardNonVisible)) { //Console.WriteLine(string.Format("\t\t\t\tDebug: exporting polygon {0} / {1} - flags: {2}, texture attributes 0x{3:X4}", p, (polygonCount - 1), Convert.ToString(polygon.sr1Flags, 2).PadLeft(8, '0'), polygon.sr1TextureFT3Attributes)); Vertex[] vertices = { polygon.v1, polygon.v2, polygon.v3 }; for (int v = 0; v < vertices.Length; v++) { ref Vertex vert = ref vertices[v]; Geometry geometry = vert.isExtraGeometry ? model.ExtraGeometry : model.Geometry; ref Vector[] positions = ref geometry.PositionsPhys; ref Vector[] normals = ref geometry.Normals; ref UInt32[] colors = ref geometry.Colours; ref UV[] uvs = ref geometry.UVs; if (options.ExportSpectral) { positions = model.Geometry.PositionsAltPhys; colors = model.Geometry.ColoursAlt; } ref Vector pos = ref positions[vert.positionID];
public static SRFile Create(string dataFile, string objectListFile, Game game, ExportOptions options, int childIndex = -1) { SRFile srFile; try { if (game == Game.Gex) { GexFile gexFile = new GexFile(dataFile, options); if (gexFile.Asset == Asset.Unit && childIndex >= 0) { srFile = gexFile.Objects[childIndex]; } else { srFile = gexFile; } } else if (game == Game.SR1) { srFile = new SR1File(dataFile, options); } else if (game == Game.SR2) { srFile = new SR2File(dataFile, options); } else if (game == Game.Defiance) { srFile = new DefianceFile(dataFile, objectListFile, options); } else if (game == Game.TRL) { srFile = new TRLFile(dataFile, objectListFile, options); } else { srFile = null; } } catch (Exception) { srFile = null; } return(srFile); }
protected abstract void ReadUnitData(BinaryReader reader, ExportOptions options);
protected override void ReadObjectData(BinaryReader reader, ExportOptions options) { // Object name reader.BaseStream.Position = _dataStart + 0x00000024; reader.BaseStream.Position = _dataStart + reader.ReadUInt32(); String strModelName = new String(reader.ReadChars(8)); _name = Utility.CleanObjectName(strModelName); // Hack to check for lighthouse demo. // The only way the name can be at 0x0000003C is if the Level structure is smaller. Hence it's the demo. reader.BaseStream.Position = _dataStart + 0x00000024; if (reader.ReadUInt32() == 0x0000003C) { _version = PROTO_19981025_VERSION; } else { // Assume retail for now. There might be other checks needed. _version = RETAIL_VERSION; } // Texture type if (options.ForcedPlatform == CDC.Platform.None) { reader.BaseStream.Position = _dataStart + 0x44; if (_version == PROTO_19981025_VERSION || reader.ReadUInt64() != 0xFFFFFFFFFFFFFFFF) { _platform = Platform.PSX; } else { _platform = Platform.PC; } } else { _platform = options.ForcedPlatform; } // Model data reader.BaseStream.Position = _dataStart + 0x00000008; _modelCount = reader.ReadUInt16(); _animCount = reader.ReadUInt16(); _modelStart = _dataStart + reader.ReadUInt32(); _animStart = _dataStart + reader.ReadUInt32(); _models = new SR1Model[_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] = SR1ObjectModel.Load(reader, _dataStart, _modelStart, _name, _platform, m, _version, options); if ((options.ForcedPlatform == CDC.Platform.None) && (_models[m].Platform == Platform.Dreamcast)) { ePlatform = _models[m].Platform; } } if (options.ForcedPlatform == CDC.Platform.None) { _platform = ePlatform; } /*reader.BaseStream.Position = _dataStart + 0x1C; * UInt32 objectDataStart = reader.ReadUInt32(); * reader.BaseStream.Position = _dataStart + 0x2C; * Int32 oflags2 = reader.ReadInt32(); * * // MonsterAttributes * if ((oflags2 & 0x00080000) != 0 && objectDataStart != 0) * { * _monsterAttributes = new MonsterAttributes(); * * reader.BaseStream.Position = objectDataStart + 0x24; * if (Version <= BETA_19990512_VERSION) * { * reader.BaseStream.Position += 0x03; * } * if (Version == BETA_19990512_VERSION) * { * reader.BaseStream.Position += 0x01; * } * * _monsterAttributes.numSubAttributes = reader.ReadSByte(); * _monsterAttributes.subAttributes = new MonsterSubAttributes[_monsterAttributes.numSubAttributes]; * reader.BaseStream.Position += 0x07; * * for (int s = 0; s < _monsterAttributes.numSubAttributes; s++) * { * _monsterAttributes.subAttributes[s].dataStart = reader.ReadUInt32(); * } * * for (int s = 0; s < _monsterAttributes.numSubAttributes; s++) * { * reader.BaseStream.Position = _monsterAttributes.subAttributes[s].dataStart + 0x26; * _monsterAttributes.subAttributes[s].modelNum = reader.ReadByte(); * } * }*/ }
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 + 0xF0; _version = reader.ReadUInt32(); if (_version == RETAIL_VERSION) { validVersion = true; } else if (_version == BETA_19990512_VERSION) { validVersion = true; } } if (!validVersion) { reader.BaseStream.Position = _dataStart + 0xE4; _version = reader.ReadUInt32(); if (_version == ALPHA_19990216_VERSION_3) { validVersion = true; } } if (!validVersion) { reader.BaseStream.Position = _dataStart + 0xE0; _version = reader.ReadUInt32(); if (_version == ALPHA_19990204_VERSION_2) { validVersion = true; } if (_version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1) { validVersion = true; } } if (!validVersion) { // Lighthouse _version = PROTO_19981025_VERSION; validVersion = true; } if (!validVersion) { throw new Exception("Wrong version number for level x"); } // 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? if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position = m_uConnectionData + 0x3C; } else { reader.BaseStream.Position = m_uConnectionData + 0x30; } reader.BaseStream.Position = _dataStart + reader.ReadUInt32(); portalCount = reader.ReadUInt32(); _portalNames = new String[portalCount]; for (int i = 0; i < portalCount; i++) { String strUnitName = new String(reader.ReadChars(12)); _portalNames[i] = Utility.CleanName(strUnitName); if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position += 0x4C; } else { reader.BaseStream.Position += 0x50; } } // Intros if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position = _dataStart + 0x84; } else if (_version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1 || _version == ALPHA_19990204_VERSION_2) { reader.BaseStream.Position = _dataStart + 0x70; } else if (_version == ALPHA_19990216_VERSION_3) { reader.BaseStream.Position = _dataStart + 0x74; } else { reader.BaseStream.Position = _dataStart + 0x78; } _introCount = reader.ReadUInt32(); _introStart = _dataStart + reader.ReadUInt32(); _intros = new Intro[_introCount]; for (int i = 0; i < _introCount; i++) { if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position = _introStart + 0x48 * i; } else if (_version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1 || _version == ALPHA_19990204_VERSION_2) { reader.BaseStream.Position = _introStart + 0x50 * i; } else { reader.BaseStream.Position = _introStart + 0x4C * i; } String introName = new String(reader.ReadChars(8)); reader.BaseStream.Position += 0x08; _intros[i].introNum = reader.ReadInt32(); _intros[i].uniqueID = reader.ReadInt32(); _intros[i].rotation.x = (float)(Math.PI * 2 / 4096) * reader.ReadInt16(); _intros[i].rotation.y = (float)(Math.PI * 2 / 4096) * reader.ReadInt16(); _intros[i].rotation.z = (float)(Math.PI * 2 / 4096) * reader.ReadInt16(); reader.BaseStream.Position += 0x02; _intros[i].position.x = (float)reader.ReadInt16(); _intros[i].position.y = (float)reader.ReadInt16(); _intros[i].position.z = (float)reader.ReadInt16(); _intros[i].name = Utility.CleanObjectName(introName) + "-" + _intros[i].uniqueID; _intros[i].fileName = Utility.CleanObjectName(introName); reader.BaseStream.Position += 0x0A; UInt32 iniCommand = reader.ReadUInt32(); if (iniCommand != 0) { reader.BaseStream.Position = iniCommand; while (true) { UInt16 command = reader.ReadUInt16(); if (command == 0) { break; } UInt16 numParameters = reader.ReadUInt16(); if (command == 6) { _intros[i].monsterAge = reader.ReadInt32(); } else if (command == 18) { _intros[i].modelIndex = reader.ReadInt32(); } iniCommand += 4u + (4u * numParameters); } } } // Object Names if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position = _dataStart + 0x98; } else if (_version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1 || _version == ALPHA_19990204_VERSION_2) { reader.BaseStream.Position = _dataStart + 0x84; } else if (_version == ALPHA_19990216_VERSION_3) { reader.BaseStream.Position = _dataStart + 0x88; } else { reader.BaseStream.Position = _dataStart + 0x8C; } _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 if (_version == PROTO_19981025_VERSION) { reader.BaseStream.Position = _dataStart + 0xA4; } else if (_version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1 || _version == ALPHA_19990204_VERSION_2) { reader.BaseStream.Position = _dataStart + 0x90; } else if (_version == ALPHA_19990216_VERSION_3) { reader.BaseStream.Position = _dataStart + 0x94; } else { reader.BaseStream.Position = _dataStart + 0x98; } reader.BaseStream.Position = _dataStart + reader.ReadUInt32(); String strModelName = new String(reader.ReadChars(8)); _name = Utility.CleanName(strModelName); // Texture type bool handledSpecificVersion = false; if (_version == PROTO_19981025_VERSION || _version == ALPHA_19990123_VERSION_1_X || _version == ALPHA_19990123_VERSION_1 || _version == ALPHA_19990204_VERSION_2 || _version == ALPHA_19990216_VERSION_3) { if (options.ForcedPlatform == CDC.Platform.None) { _platform = Platform.PSX; } handledSpecificVersion = true; } if (!handledSpecificVersion) { reader.BaseStream.Position = _dataStart + 0x9C; UInt64 checkVal = reader.ReadUInt64(); if (options.ForcedPlatform == CDC.Platform.None) { if (checkVal != 0xFFFFFFFFFFFFFFFF) { _platform = Platform.PSX; } else { _platform = Platform.PC; } } else { _platform = options.ForcedPlatform; } } // Connected unit list. (unreferenced?) //reader.BaseStream.Position = _dataStart + 0xC0; //m_uConnectedUnitsStart = _dataStart + reader.ReadUInt32() + 0x08; //reader.BaseStream.Position = m_uConnectedUnitsStart; //reader.BaseStream.Position += 0x18; //String strUnitName0 = new String(reader.ReadChars(16)); //strUnitName0 = strUnitName0.Substring(0, strUnitName0.IndexOf(',')); //reader.BaseStream.Position += 0x18; //String strUnitName1 = new String(reader.ReadChars(16)); //strUnitName1 = strUnitName1.Substring(0, strUnitName1.IndexOf(',')); //reader.BaseStream.Position += 0x18; //String strUnitName2 = new String(reader.ReadChars(16)); //strUnitName2 = strUnitName2.Substring(0, strUnitName2.IndexOf(',')); // Model data reader.BaseStream.Position = _dataStart; _modelCount = 1; _modelStart = _dataStart; _models = new SR1Model[_modelCount]; reader.BaseStream.Position = _modelStart; UInt32 m_uModelData = _dataStart + reader.ReadUInt32(); // Material data Console.WriteLine("Debug: reading area model 0"); _models[0] = SR1UnitModel.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; //} }
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; //} }
protected override void ReadData(BinaryReader reader, ExportOptions options) { base.ReadData(reader, options); }
public TRLFile(String dataFile, String objectListFile, ExportOptions options) : base(dataFile, Game.Defiance, options) { LoadObjectList(objectListFile); }
public TRLFile(String dataFile, ExportOptions options) : base(dataFile, Game.TRL, options) { }
public DefianceFile(String dataFile, ExportOptions options) : base(dataFile, Game.Defiance, options) { }
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); }
public GexFile(String dataFile, ExportOptions options) : base(dataFile, Game.Gex, options) { }