/// <summary> /// Create HeightFields from textures /// </summary> private void GenerateHeightFields(bool force = false) { if (!force && h_top != null) { return; } Texture2D[] maps = new Texture2D[] { heightmapTop, heightmapBottom, heightmapLeft, heightmapRight, heightmapFront, heightmapBack }; for (int i = 0; i < 6; i++) { Texture2D map = maps[i]; HeightField field = new HeightField(map.width, map.height); for (int w = 0; w < map.width; w++) { for (int h = 0; h < map.height; h++) { field[w, h] = SampleColour(map.GetPixel(w, h)); } } switch (i) { case 0: h_top = field; break; case 1: h_bottom = field; break; case 2: h_left = field; break; case 3: h_right = field; break; case 4: h_front = field; break; case 5: h_back = field; break; } } }
/// <summary> /// Create HeightFields from textures /// </summary> private void GenerateHeightFields(bool force = false) { if (!force && h_top != null) { return; } h_top = new HeightField(heights.top, heightColour, heights.invertTop.invertX, heights.invertTop.invertY); h_bottom = new HeightField(heights.bottom, heightColour, heights.invertBottom.invertX, heights.invertBottom.invertY); h_left = new HeightField(heights.left, heightColour, heights.invertLeft.invertX, heights.invertLeft.invertY); h_right = new HeightField(heights.right, heightColour, heights.invertRight.invertX, heights.invertRight.invertY); h_front = new HeightField(heights.front, heightColour, heights.invertFront.invertX, heights.invertFront.invertY); h_back = new HeightField(heights.back, heightColour, heights.invertBack.invertX, heights.invertBack.invertY); }