Hi guys, I’m having a bit of an issue here and have spent days trying different things but nothing seems to work. I have done extensive goggling and nothing has come up. Maybe somebody has run into this problem and wants to share some light on this matter? Thanks in advance for your help.
Please note that the second terrain is exactly like the first with the exception of the first row and column.
For testing purposes, I tried to set the first row and column values before SetHeights to their neighbor value which is correct but the result is exactly the same.
I have tried the script posted at http://wiki.unity3d.com/index.php?title=TerrainImporter and the result is the same as my code.
private void GetHeights(){
heights = new float[65536];
for(int i=0; i<heights.Length; i++)
heights[i] = i / 65536.0f;
}
... Relevant Code
if(heights == null)
GetHeights();
using (System.IO.FileStream f = System.IO.File.OpenRead(heighmapFile)) {
using (System.IO.BinaryReader br = new System.IO.BinaryReader(f)) {
res = Mathf.CeilToInt (Mathf.Sqrt (f.Length / 2));
tdata.heightmapResolution = res + 1;
tdata.size = new Vector3 (res, res / 3, res);
tdata.baseMapResolution = res;
tdata.SetDetailResolution (res, 8);
float[,] heightData = new float[res,res];
for (int x=0; x<res; x++) {
for (int y=0; y<res; y++) {
heightData [x, y] = heights[br.ReadUInt16()];
}
}
tdata.SetHeights (0, 0, heightData);
}
}