#### Archived

This topic is now archived and is closed to further replies.

# collision with the heightmapped terrain is driving me INSANE!

This topic is 5902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i''ve been spending a week trying to make this planar-poitn collision work with all this vector junk, and it doesn''t work. then i see this ominous 4e3 entry with hegihtmaps. i load it up, and its got perfect heightmap collision. so i look in the code trying to find it, and i get this(very sorry to the author, but i CANNOT figure this out):
float CTerrain::GetHeight(float x, float z)
{
float tilex, tilez;

tilex = (float)(x / Scale);
tilez = (float)(z / Scale);

int col0 = int(tilex);
int row0 = int(tilez);
int col1 = col0 + 1;
int row1 = row0 + 1;

if (col1 > Width*Scale)
col1 = 0;
if (row1 > Depth*Scale)
row1 = 0;

float h00 = Terrain[col0*Width+row0].y;
float h01 = Terrain[col1*Width+row0].y;
float h11 = Terrain[col1*Width+row1].y;
float h10 = Terrain[col0*Width+row1].y;

float tx = tilex - float(col0);
float ty = tilez - float(row0);
float txty = tx * ty;

float final_height = h00 * (1.0f - ty - tx + txty)
+ h01 * (tx - txty)
+ h11 * txty
+ h10 * (ty - txty);

return final_height;
}

all i want is an explanation of the last part and what each of those variables is.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632651
• Total Posts
3007657
• ### Who's Online (See full list)

There are no registered users currently online

×