I’m working on loading asc file(grid file) to Unity3D
I made a script loading asc file but I don’t know how set the value of height field
Look below please!!
float[,] fHeightValue = new float[1025, 1025];
for(int i=0; i<nRows; i++)
{
for(int j=0; j<nCols; j++)
{
// token[inCols + j] has real height of terrain from sea level
// for example
// token[inCols + j] = 24.5f; // means 24.5m from sea level
fHeightValue[i, j] = float.Parse(token[i*nCols+ j]);
}
}
// so, I load all height value from asc file but as you know, each height value of asc is not between 0 to 1.0
// if there is a 1024m x 1024m size terrain and a hill which height is 10m is in the middle of the terrain
// that 10m hill will be 0.009765625? (10m / 1024m)
// if i say there is 2048m x 2048m then the same height hill will be 0.0048828125? (10m / 2048m)
// i don’t think so…
// the height value wouldn’t be changed by terrain size, am i wrong?
// the height value only influenced by scale factor i think
// Could you tell me how can I change the real height value to float value which is between 0 to 1.0
I have no idea because of i’m not good at GIS data handling.
the height value is dependent on the Height of the terrain, not the width/depth. So use the height of the terrain (600 by default I think, you can set it in the “Set resolution” dialog.
But, What I want to know is how can I transfer the real height value such as 24.5 meter to between 0.0 to 1.0 float value.
The ArcGIS’s asc file has real height values
you should check all the values in your data file to obtain the highest point. let’s say the highest point is a 150 m, then the height of your terrain should be 150 units, and you would calc the float value by dividing the height by 150, for example 75/150 = 0.5. hope that helps!
Never worked with neighbouring terrains, but that seems like the way to go. Of course you need to know when you calculate the max heights which terrain it will later be present in, so that you get the heights correct. Good luck then!