How to get min/max terrain height for a mission area?
by Markus Nuebel · in Torque Game Engine · 02/02/2005 (2:55 pm) · 2 replies
I want to get the minimum and maximum terrain height inside the mission region.
I checked out the CommandMap resource, which seems to do this with the following code:
There are three things, that are unclear to me.
1. The findSquare() method is indexed with TerrainBlock::BlockShift. Does this access a kind of LOD level 0 where the whole level is just one terrain block with the shape of a pyramid?
(Otherwise I do not see, why the min and max heights for this level should be the overall min and max values)
2. Why are the values divided by 10?
3. Isn't it necessary to take the terrain scale into account here?
Thanks a lot.
-- Markus
I checked out the CommandMap resource, which seems to do this with the following code:
F32 maxHi = gClientSceneGraph->getCurrentTerrain()->findSquare(TerrainBlock::BlockShift, 0,0)->maxHeight / 10; F32 minHi = gClientSceneGraph->getCurrentTerrain()->findSquare(TerrainBlock::BlockShift, 0,0)->minHeight / 10;
There are three things, that are unclear to me.
1. The findSquare() method is indexed with TerrainBlock::BlockShift. Does this access a kind of LOD level 0 where the whole level is just one terrain block with the shape of a pyramid?
(Otherwise I do not see, why the min and max heights for this level should be the overall min and max values)
2. Why are the values divided by 10?
3. Isn't it necessary to take the terrain scale into account here?
Thanks a lot.
-- Markus
About the author
#2
This clears things up.
I haven't looked at the terrain code so far and was not aware of the fixed point usage.
One thing however:
Quickly searched the code and it looks like you are using an 11.5 fixed point format.
That means for the exact height I have to use 32 instead of 10 in the division, right?
-- Markus
02/02/2005 (11:22 pm)
Thanks Ben.This clears things up.
I haven't looked at the terrain code so far and was not aware of the fixed point usage.
One thing however:
Quickly searched the code and it looks like you are using an 11.5 fixed point format.
That means for the exact height I have to use 32 instead of 10 in the division, right?
-- Markus
Associate Kyle Carter
2. Because the values stored in the GridSquares are stored as fixedpoint 16 bit integers. They have to be converted to floats; the conversion factor is probably a bit conservative so that the camera's bounds will cover stuff like people flying overhead and tall buildings and such.
3. Terrains aren't scaled vertically often. But yeah, I imagine you're probably right.