// Methods public override void Load(Stream fileStream) { // Header var reader = new GensReader(fileStream, true); Header = new GensHeader(reader); // Root Node uint lightType = reader.ReadUInt32(); if (lightType < 0 || lightType > 1) { throw new InvalidDataException( $"Cannot read light - unknown light type! ({lightType})"); } // Data LightType = (LightTypes)lightType; Position = reader.ReadVector3(); Color = reader.ReadVector3(); if (LightType == LightTypes.Omni) { UnknownTotal1 = reader.ReadUInt32(); UnknownTotal2 = reader.ReadUInt32(); UnknownTotal3 = reader.ReadUInt32(); OmniInnerRange = reader.ReadSingle(); OmniOuterRange = reader.ReadSingle(); } }
// Methods public override void Load(Stream fileStream) { // Header var reader = new GensReader(fileStream); Header = new GensHeader(reader); // Root Node uint modelFileNameOffset = reader.ReadUInt32(); uint matrixOffset = reader.ReadUInt32(); uint fileNameOffset = reader.ReadUInt32(); uint instanceTotal = reader.ReadUInt32(); uint fileNameOffsetEnd = reader.ReadUInt32(); // File Name reader.JumpTo(fileNameOffset, false); FileName = reader.ReadNullTerminatedString(); // Matrix reader.JumpTo(matrixOffset, false); for (int x = 0; x < 4; ++x) { for (int y = 0; y < 4; ++y) { matrix[x, y] = reader.ReadSingle(); } } // Model File Name reader.JumpTo(modelFileNameOffset, false); ModelFileName = reader.ReadNullTerminatedString(); // Mesh "Loaders" (what?) // TODO }
// Methods public unsafe void Read(GensReader reader, float *data, float scale = 1) { switch ((DataTypes)Type) { case DataTypes.Vector2: *data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; break; case DataTypes.Vector2_Half: *data = reader.ReadHalf(); *++data = reader.ReadHalf(); break; case DataTypes.Vector3: *data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; break; case DataTypes.Vector3_360: // TODO: Read this properly reader.ReadUInt32(); break; case DataTypes.Vector3_Forces: // TODO: Read this properly reader.ReadUInt32(); break; case DataTypes.Vector4: *data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; *++data = reader.ReadSingle() * scale; break; case DataTypes.Vector4_Byte: case DataTypes.Indices: // TODO: Read this properly reader.ReadUInt32(); break; case DataTypes.Indices_Byte: // TODO: Read this properly reader.ReadUInt32(); break; } }
// Methods public override void Load(Stream fileStream) { // Header var reader = new GensReader(fileStream, true); Header = new GensHeader(reader); // Root Node uint instanceInfoCount = reader.ReadUInt32(); uint instanceInfoOffsetsOffset = reader.ReadUInt32(); uint terrainModelCount = reader.ReadUInt32(); uint terrainModelOffsetsOffset = reader.ReadUInt32(); // Instance Infos InstanceInfos = new InstanceInfoEntry[instanceInfoCount]; reader.JumpTo(instanceInfoOffsetsOffset, false); for (uint i = 0; i < instanceInfoCount; ++i) { var instanceInfo = new InstanceInfoEntry(); uint instanceInfoOffset = reader.ReadUInt32(); long curPos = reader.BaseStream.Position; reader.JumpTo(instanceInfoOffset, false); uint fileNameCount = reader.ReadUInt32(); uint fileNameOffsetsOffset = reader.ReadUInt32(); uint boundingSphereOffset = reader.ReadUInt32(); reader.JumpTo(fileNameOffsetsOffset, false); // File Names instanceInfo.FileNames = new string[fileNameCount]; for (uint i2 = 0; i2 < fileNameCount; ++i2) { instanceInfo.FileNames[i2] = reader.GetString(); } // Bounding Sphere reader.JumpTo(boundingSphereOffset, false); instanceInfo.BoundingSphereCenter = reader.ReadVector3(); instanceInfo.BoundingSphereRadius = reader.ReadSingle(); InstanceInfos[i] = instanceInfo; reader.BaseStream.Position = curPos; } // Terrain Models TerrainModels = new string[terrainModelCount]; reader.JumpTo(terrainModelOffsetsOffset, false); for (uint i = 0; i < terrainModelCount; ++i) { TerrainModels[i] = reader.GetString(); } }
// Methods public override void Load(Stream fileStream) { // Header var reader = new GensReader(fileStream); Header = new GensHeader(reader); // Root Node uint groupCount = reader.ReadUInt32(); uint groupOffsetsOffset = reader.ReadUInt32(); GroupEntries = new TerrainGroupEntry[groupCount]; // Group Offsets var groupOffsets = new uint[groupCount]; reader.JumpTo(groupOffsetsOffset, false); for (uint i = 0; i < groupCount; ++i) { groupOffsets[i] = reader.ReadUInt32(); } // Groups for (uint i = 0; i < groupCount; ++i) { var group = new TerrainGroupEntry(); reader.JumpTo(groupOffsets[i], false); // Entry uint centerPosOffset = reader.ReadUInt32(); uint fileNameOffset = reader.ReadUInt32(); group.UncompressedGroupSize = reader.ReadUInt32(); uint sphereCount = reader.ReadUInt32(); uint sphereOffsetsOffset = reader.ReadUInt32(); group.SubsetID = reader.ReadUInt32(); // Center position reader.JumpTo(centerPosOffset, false); group.CenterPosition = reader.ReadVector3(); group.CenterRadius = reader.ReadSingle(); // FileName reader.JumpTo(fileNameOffset, false); group.FileName = reader.ReadNullTerminatedString(); // Sphere Offsets var sphereOffsets = new uint[sphereCount]; reader.JumpTo(sphereOffsetsOffset, false); for (uint i2 = 0; i2 < sphereCount; ++i2) { sphereOffsets[i2] = reader.ReadUInt32(); } // Spheres var spheres = new TerrainSphere[sphereCount]; for (uint i2 = 0; i2 < sphereCount; ++i2) { reader.JumpTo(sphereOffsets[i2], false); spheres[i2] = new TerrainSphere() { Center = reader.ReadVector3(), CenterRadius = reader.ReadSingle() }; } group.Spheres = spheres; GroupEntries[i] = group; } }