public CHeightmap Generate() { CHeightmap dest = new CHeightmap(m_iResolution); for (int j = 0; j < m_iResolution; j++) { for (int i = 0; i < m_iResolution; i++) { dest.m_aaValues[j][i] = cast(j, i); } } dest.CalculateMax(); return(dest); }
//for debugging public void GenerateAndPrint() { CHeightmap map = Generate(); string txt = ""; for (int j = 0; j < m_iResolution; j++) { for (int i = 0; i < m_iResolution; i++) { txt += map.GetPixelAsFloat(j, i); } txt += "\n"; } Debug.Log(txt); }
/** * Returns a heightmap texture in R8 format. */ Texture2D ToTexture() { CHeightmap hmap = this.Generate(); Texture2D image = new Texture2D(m_iResolution, m_iResolution, TextureFormat.R8, false); for (int i = 0; i < m_iResolution; i++) { for (int j = 0; j < m_iResolution; j++) { int c = hmap.m_aaValues[i][j]; image.SetPixel(i, j, new Color(c, c, c)); } } return(image); }
//Generates a new heightmap and returns the max height, IN WORLD UNITS. public float MeasureMaxWorldUnits() { CHeightmap map = Generate(); return(m_flHeight * map.GetMaxAsFloat()); }