This was easier than I thought. Set's the matrix tile heights based on a grayscale image. The image must at least match in width and height to the matrix' number of segments, or larger.
make matrix 1, 2000,2000, 40, 40
Image must be at least 40x40 or larger.
"fog.bmp" was my heightmap image.
REM ===================
REM heightmap to matrix
REM coded by: Phaelax
REM ===================
sync on
autocam off
load image "grass.jpg", 1
load image "fog.bmp", 2
rem number of matrix tiles
xsegs = 50
zsegs = 50
rem create a matrix
make matrix 1, 1000,1000,xsegs, zsegs
prepare matrix texture 1,1,1,1
rem create an image memblock from the heightmap
make memblock from image 256, 2
rem get the image's dimensions
width = memblock dword(256, 0)
height = memblock dword(256, 4)
rem convert integer variables to floats
xsegs# = xsegs+1
zsegs# = zsegs+1
rem pixel offset for configuring match between pixel and tile number
ox# = width/xsegs#
oz# = height/zsegs#
rem max height of matrix
max# = 1000
rem get pixel color from image location matching corresponding tile coordinates
for z = 0 to zsegs-1
for x = 0 to xsegs-1
location = (int(z*oz#)*width + int(x*ox#))*4 + 12
c = memblock byte(256, location)
rem convert color value into height value
h# = (c*max#)/255.0
set matrix height 1,x,z,h#
next x
next z
delete memblock 256
update matrix 1
DO
gosub camera_stuff
set cursor 0,0
print cy#
print c
sync
LOOP
camera_stuff:
oldcx#=cx#
oldcz#=cz#
speed# = 5
if upkey()=1
cx#=newxvalue(cx#,a#,speed#)
cz#=newzvalue(cz#,a#,speed#)
endif
if downkey()=1
cx#=newxvalue(cx#,a#,-speed#)
cz#=newzvalue(cz#,a#,-speed#)
endif
if leftkey()=1
cx#=newxvalue(cx#,wrapvalue(a#-90.0),speed#)
cz#=newzvalue(cz#,wrapvalue(a#-90.0),speed#)
endif
if rightkey()=1
cx#=newxvalue(cx#,wrapvalue(a#+90.0),speed#)
cz#=newzvalue(cz#,wrapvalue(a#+90.0),speed#)
endif
if shiftkey() then inc cy#, 2
if controlkey() then dec cy#, 2
a#=wrapvalue(a#+(mousemovex()/3.0))
cxa#=cxa#+(mousemovey()/3.0)
if cxa#<-90.0 then cxa#=-90.0
if cxa#>90.0 then cxa#=90.0
cy# = get ground height(1,cx#,cz#)
position camera cx#,cy#+50,cz#
rotate camera wrapvalue(cxa#),a#,0
RETURN
[EDIT]
Actually, after thinking about it a little, the code should work on ANY size heightmap, whether its bigger or smaller than the matrix. I just tested it, and it will work with smaller images.
"eureka" - Archimedes