#### Archived

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

# Heightmap height

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

## Recommended Posts

hey, i''m sure that this question has been asked many times before, but i too lazy to go search for it. Ü anyways... i''m working off of NeHe''s heightmap tutorial. i want the camera to move along the ground instead of floating above it. i try to get the height of my current possion by setting my Y position equal to the Height function: ypos = Height(g_HeightMap, xpos, ypos ); it seems to work in the begining, but it seems like when you reach a slope that is too steep, you go under the surface of the heightmap. did that make any sence? it would be great if anyone could help me. by the way... i am using NeHe''s Height function: int Height(BYTE *pHeightMap, int X, int Y) // This Returns The Height From A Height Map Index { int x = X % MAP_SIZE; // Error Check Our x Value int y = Y % MAP_SIZE; // Error Check Our y Value if(!pHeightMap) return 0; // Make Sure Our Data Is Valid return pHeightMap[x + (y * MAP_SIZE)]; // Index Into Our Height Array And Return The Height } -PmanC

##### Share on other sites
you probably can''t see the terrain as it''s being clipped by the near clip plane. bump the height up by a few units and that should solve your problem.

##### Share on other sites
by bumping my height up do you mean:

ypos = Height(g_HeightMap, xpos, ypos ) + 5.0f;

increasing the height by five?

##### Share on other sites
i tryed what you suggested and i still go under the heightmap. here is a picture of my problem:

http://www.pmanc.0catch.com/HeightMapProblem.html

##### Share on other sites
nevermind... i figured it out on my own. i had to replace a ypos with a zpos! thatks for your help anways. -PmanC

##### Share on other sites
now i have another problem... the movement is jerky because of the "big" step size(16). the only way i could think to solve this problem is the put an very small step size to make it smother, but at the same time, it would become insainly slow! does anyone have any ideas? -PmanC

##### Share on other sites
Implement framerate-independent motion.

##### Share on other sites
many ways to do what you ask. an easy one is to average out the 4 verticies around you, relative to how close you are to them... or simply to not ''blur'' between different height values...
ie, have two values for height, 1 the calculated height, on the value used as your height, then do:

usedHeight=usedHeight*0.95f+realHeight*0.05f;

this is a really rough way. it wouldn''t be frame rate independant, but until you get the first method working, this would do.

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 17
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632962
• Total Posts
3009506
• ### Who's Online (See full list)

There are no registered users currently online

×