Archived

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

Walking on a terrain

This topic is 5981 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

I am using a 32x32 grayscale bitmap to generate a landscape by determing height of a certain point on the terrain with the bitmap''s color values (the whiter the pixel on the bitmap, the higher to the terrain will be at that point). But now I want to move around on it. I''m reading OpenGL Game Programming right now (very good book by the way), but I''m having trouble with Astle''s GetHeight() function...I was wondering if this is the traditional way to determine the user''s position on the y axis...can it be done another way? with collision detection maybe? If anyone knows of some other techniques, please respond to this post & if you know where I can read up on them, I''d really like to know thanks everyone

Share this post


Link to post
Share on other sites
I don''t have that book in front of me (...its up a flight of stairs) but if I remember right that function returns y from one of the classes, meaning that function is specific to that engine.

Read the code to figure out how they determine user pos on the y axis, which includes using the sin function for the bouncing movement effect.

Share this post


Link to post
Share on other sites
I assume you''re talking about the GetHeight() function from the end of the book? CTerrain::GetHeight() I think..

If so, this function takes the heights of the four surrounding vertices on the terrain from your input location and interpolates the four heights (y-values) to determine your height. If I had the code in front of me I could be of more help, but I know that''s what it does in a nutshell since I did that. From my understanding, that is the "normal" approach to calculating the height, and also the best that I''ve seen so far. I would also be interested in seeing if there were other approaches out there.

Kevin

Share this post


Link to post
Share on other sites