/// <summary> /// Processes a <see cref="LODTerrain"/> in a <see cref="MAPTerrainMoHAA"/>. /// For MoHAA forks only. /// </summary> /// <param name="lodTerrain">The <see cref="LODTerrain"/> object to process.</param> /// <returns>A <see cref="MAPTerrainMoHAA"/> object to be added to a <see cref="MAPBrush"/> object.</returns> private MAPTerrainMoHAA ProcessTerrainMoHAA(LODTerrain lodTerrain) { string shader = _bsp.textures[lodTerrain.texture].name; MAPTerrainMoHAA.Partition partition = new MAPTerrainMoHAA.Partition() { shader = shader, textureScale = new double[] { 1, 1 }, }; MAPTerrainMoHAA terrain = new MAPTerrainMoHAA() { size = new Vector2d(9, 9), flags = ((lodTerrain.flags & (1 << 6)) > 0) ? 1 : 0, origin = new Vector3d(lodTerrain.x * 64, lodTerrain.y * 64, lodTerrain.baseZ), }; terrain.partitions.Add(partition); terrain.partitions.Add(partition); terrain.partitions.Add(partition); terrain.partitions.Add(partition); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { MAPTerrainMoHAA.Vertex vertex = new MAPTerrainMoHAA.Vertex() { height = lodTerrain.heightmap[i, j] * 2, }; terrain.vertices.Add(vertex); } } return(terrain); }
/// <summary> /// Converts the passed <see cref="MAPTerrainMoHAA"/> into a <see cref="MAPTerrainEF2"/> /// with the same heightmap. /// </summary> /// <param name="mohTerrain">The <see cref="MAPTerrainMoHAA"/> to convert.</param> /// <returns><see cref="MAPTerrainEF2"/> with the same shader and heightmap as <paramref name="mohTerrain"/>.</returns> private MAPTerrainEF2 ConvertToEF2Terrain(MAPTerrainMoHAA mohTerrain) { if (mohTerrain.size == new Vector2(9, 9)) { MAPTerrainMoHAA.Partition partition = mohTerrain.partitions[0]; MAPTerrainEF2 ef2Terrain = new MAPTerrainEF2() { side = 9, texture = partition.shader, textureShiftS = partition.textureShift[0], textureShiftT = partition.textureShift[1], texRot = (float)partition.rotation, texScaleX = partition.textureScale[0], texScaleY = partition.textureScale[1], flags = 1024, // maybe don't hardcode this? sideLength = 512, start = new Vector3(mohTerrain.origin.X, mohTerrain.origin.Y, 0), IF = Vector4.Zero, LF = Vector4.Zero, heightMap = new float[9, 9], alphaMap = new float[9, 9] }; for (int y = 0; y < ef2Terrain.heightMap.GetLength(0); ++y) { for (int x = 0; x < ef2Terrain.heightMap.GetLength(1); ++x) { ef2Terrain.heightMap[y, x] = mohTerrain.vertices[(y * (int)mohTerrain.size.Y) + x].height + (float)mohTerrain.origin.Z; } } return(ef2Terrain); } return(null); }
/// <summary> /// Processes a <see cref="LODTerrain"/> in a <see cref="MAPTerrainMoHAA"/>. /// For MoHAA forks only. /// </summary> /// <param name="lodTerrain">The <see cref="LODTerrain"/> object to process.</param> /// <returns>A <see cref="MAPTerrainMoHAA"/> object to be added to a <see cref="MAPBrush"/> object.</returns> private MAPTerrainMoHAA ProcessTerrainMoHAA(LODTerrain lodTerrain) { string shader = _bsp.textures[lodTerrain.TextureIndex].Name; MAPTerrainMoHAA.Partition partition = new MAPTerrainMoHAA.Partition() { shader = shader, textureScale = new float[] { 1, 1 }, }; MAPTerrainMoHAA terrain = new MAPTerrainMoHAA() { size = new Vector2(9, 9), flags = ((lodTerrain.Flags & (1 << 6)) > 0) ? 1 : 0, origin = new Vector3(lodTerrain.X * 64, lodTerrain.Y * 64, lodTerrain.BaseZ), }; terrain.partitions.Add(partition); terrain.partitions.Add(partition); terrain.partitions.Add(partition); terrain.partitions.Add(partition); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { MAPTerrainMoHAA.Vertex vertex = new MAPTerrainMoHAA.Vertex() { height = lodTerrain.Heightmap[i, j] * 2, }; terrain.vertices.Add(vertex); } } return(terrain); }