Jump to content


- - - - -

loading a mesh thats the terrian but how...


1 reply to this topic

#1 Anddos

    Valued Member

  • Members
  • PipPipPip
  • 177 posts

Posted 14 September 2008 - 09:19 AM

i am stuck with thinking how to make the .x player animation move up a terrain that is not flat but has bumps and hills , would it be something todo with the vertexbuffer and the player translation current postion?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationBellevue, WA

Posted 14 September 2008 - 06:22 PM

If your terrain is stored as a heightfield, then what you need to do is:

- use the player's x and y coordinates to find the grid square of terrain they are currently in
- look up the heights of the four corners of that grid square in the heightfield
- use bilinear interpolation to calculate the height of the terrain at the player's exact x and y coordinates
- translate the player so that the feet are at that height (z).

Later on you'll probably want to implement some physics so that the player can't climb up slopes that are too steep. But this should get you started.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users