I dunno about heightmaps (I usually use matrix or .X models).
But for the gravity:
Most people use a variable named YSpeed#. Which is, obviously, the speed upwards. When negative, it goes down, when positive, it goes up.
Now, the gravity is a vector that pulls our object down, when the object goes up, it slows down and edventually will accelerate downwards. This means our calculations would be something like this: dec YSpeed#, gravity#.
(Usually gravity is a constant)
If the object hits the ground, a new force works on the object, normal force, which is always -ForceDownwards (-Fz). In other words, the yspeed gets increased by itself, which gives 0.
To effect the gravity on the player, you have to increase the players position y with the YSpeed#.
You get something like this:
posy# = object position y(id)
`effect gravity
dec YSpeed#, Gravity#
`Check for collision with ground
if posy# <= get ground height(id, X, Z) + (object size y(id)/2)
YSpeed# = 0.0
endif
`effect position
inc posy#, YSpeed#
`update
position object id, X, posy#, Z
To jump, the only thing you have to do is increasing the YSpeed (in other words, make a vector upwards)