Jump to content
  • Advertisement

Archived

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

PmanC

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!