PDA

View Full Version : Walking up the hill..



cadaver_nl
04-17-2005, 04:03 AM
I have a terrain made of a heightmap and a md2 character that walks on the terrain. I get the height of the terrain and set this as the y value of the character.
(ymodel = GetHeight(-zmodel , xmodel )+30;)

Know the problem is that when the model walks up the hill, his feet go through the hill.
Raising the +30 (standard height on flat terrain) does help but then the character "fly's" above the terrain.

Is their something i am missing or have i do some other calculations (angles, normals etc).

Can someone explain this to me or point me in the right directions.

Thanks

CrazyButcher
04-17-2005, 06:28 AM
when the terrain grid is not very dense, you would need to interpolate the height between "heightmap pixels" yourself.
so you would lerp between the height of the current grid pixel and the next one.
your heightmap is "discrete" ie you have little steps (pixels stand for a height).
while your triangle takes those pixels as vertices the surface between pixels doesnt make "steps"

so when your character moves between grid's steps, you need to interpolate yourself