View Full Version : let an object follow a heightmap
How can I let an object follow a heightmap? The object have constant speed.
An easy way of doing it is moving it as usual along the X/Z-plane, and give it a Y-coordinate from the heightmap. Unless the heightmap has very steep hills, it's a fairly acurate method.
For something to follow a heightmap smoothly, you need to interpolate the heightmap values.
Here's some pseudo code:
Function GetInterpolatedHeight#( x#,z# )
ix=Floor(x) ;integer parts of x,z
fx#=x-ix ;fractional remainders
y00#=GetHeight( ix,iz )
y10#=GetHeight( ix+1,iz )
y11#=GetHeight( ix+1,iz+1 )
y01#=GetHeight( ix,iz+1 )
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.