public TerrainGeometryFile(byte[] file) { var stream = new MemoryStream(file); var reader = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN); var blockID = reader.ReadUInt32(); var versionNumber = reader.ReadUInt32(); xSize = reader.ReadInt32(); ySize = reader.ReadInt32(); waterElevation = reader.ReadFloat(); var terrainTypeLength = reader.ReadUInt32(); terrainType = reader.ReadCString((int)terrainTypeLength); tType = Neighborhood.TerrainTypes[terrainType]; tType.Load(); Debug.Log(terrainType); var blockID2 = reader.ReadUInt32(); var versionNumber2 = reader.ReadUInt32(); var sectionTypeLength = reader.ReadInt32(); var sectionType = reader.ReadCString(sectionTypeLength); var xRange = reader.ReadInt32(); var yRange = reader.ReadInt32(); for (var i = 0; i < xRange; i++) { for (var j = 0; j < yRange; j++) { var height = reader.ReadFloat(); terrainElevation[new Tuple <int, int>(i, j)] = height; //terrainElevation.Add(height); } } var blockID3 = reader.ReadUInt32(); var versionNumber3 = reader.ReadUInt32(); sectionTypeLength = reader.ReadInt32(); sectionType = reader.ReadCString(sectionTypeLength); xRange = reader.ReadInt32(); yRange = reader.ReadInt32(); for (var i = 0; i < xRange; i++) { for (var j = 0; j < yRange; j++) { var uselessByte = reader.ReadByte(); } } reader.Dispose(); stream.Dispose(); terrainMesh = CreatePlane(xSize, xSize, terrainElevation); waterMesh = CreateFlatPlane(1, xSize); }