loading a mesh thats the terrian but how...

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Sep 14, 2008 at 09:19

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?

1 Reply

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Sep 14, 2008 at 18:22

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.