Heightmap height

Started by
6 comments, last by PmanC 21 years, 10 months ago
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
Advertisement
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.
by bumping my height up do you mean:

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

increasing the height by five?
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
nevermind... i figured it out on my own. i had to replace a ypos with a zpos! thatks for your help anways. -PmanC
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
Implement framerate-independent motion.
---visit #directxdev on afternet <- not just for directx, despite the name
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.

This topic is closed to new replies.

Advertisement