Ryuuguu
December 25, 2007, 12:53am
1
I see this function used in island demo
TerrainData.GetInterpolatedHeight
but it is not listed in my local documentation. It is in the online docs but not on the TerrainData all members page, same goes for GetSteepness . Is this just Docmentation linking error and these function are OK to use and expect to stay in future versions?
Cheers,
Grant
I see this function used in island demo
TerrainData.GetInterpolatedHeight
but it is not listed in my local documentation. It is in the online docs but not on the TerrainData all members page, same goes for GetSteepness . Is this just Docmentation linking error and these function are OK to use and expect to stay in future versions?
Cheers,
Grant
Where is this? :?: :?: :?:
Sisso
October 10, 2009, 4:11pm
3
I have the same doubt and found this post
The method is used by Island Demo in Heron.js
function Fish()
{
var height : float = terrain.GetInterpolatedHeight(myT.position.x / terrain.size.x, myT.position.z / terrain.size.z);
status = HeronStatus.Walking;
var direction : Vector3;
var randomDir : Vector3 = Random.onUnitSphere;
if(height > 40)
{
maxHeight = 40;
offsetMoveDirection = GetPathDirection(myT.position, randomDir);
yield WaitForSeconds(0.5);
if(velocity.magnitude > 0.01) direction = myT.right * (Random.value > 0.5 ? -1 : 1);
}
if(height > 38)
{
maxHeight = 38;
offsetMoveDirection = GetPathDirection(myT.position, randomDir);
yield WaitForSeconds(1);
if(velocity.magnitude > 0.01) direction = myT.right * (Random.value > 0.5 ? -1 : 1);
}
if(height > 36.5)
{
maxHeight = 36.5;
offsetMoveDirection = GetPathDirection(myT.position, randomDir);
yield WaitForSeconds(1.5);
if(velocity.magnitude > 0.01) direction = myT.right * (Random.value > 0.5 ? -1 : 1);
}
while(height > 35)
{
maxHeight = 35;
yield WaitForSeconds(0.5);
if(velocity.magnitude > 0.01) direction = myT.right * (Random.value > 0.5 ? -1 : 1);
offsetMoveDirection = GetPathDirection(myT.position, randomDir);
height = terrain.GetInterpolatedHeight(myT.position.x / terrain.size.x, myT.position.z / terrain.size.z);
}
fishing = true;
status = HeronStatus.Walking;
yield WaitForSeconds(fishingTime / 3);
status = HeronStatus.Idle;
yield WaitForSeconds(fishingTime / 6);
status = HeronStatus.Walking;
yield WaitForSeconds(fishingTime / 3);
status = HeronStatus.Idle;
yield WaitForSeconds(fishingTime / 6);
fishing = false;
maxHeight = 42;
}
Is the following right?
function GetInterpolatedHeight(x : float, z : float) : float
Get an interpolated height of the terrain at a given location.
x,z coordinates are specified as normalized coordinates between 0 … 1
Helical
December 6, 2016, 11:54am
5
@anon_62597879 Thank you for telling that its normalized values.
I actually dont understand what it returns and normalized is what?
Currently doing like so, and it seems to work
public void Flatten(Vector3 position, int width, int length){
int xBase = (int)(position.x - terrain.GetPosition().x);
int yBase = (int)(position.z - terrain.GetPosition().z);
TerrainData t = terrain.terrainData;
float height = t.GetInterpolatedHeight((position.x - terrain.GetPosition().x)/t.heightmapWidth, (position.z - terrain.GetPosition().z)/t.heightmapHeight);
float normalizedHeight = height / t.size.y;
float[,] heights = new float[width, length];
for(int i=0; i<width; ++i)
for(int j=0; j<length; ++j)
heights[i,j] = normalizedHeight;
t.SetHeights(xBase, yBase, heights);
}