-=-=-=-=-=-=-=-=-=-=-=-=
New version Sept 5, 2013
-=-=-=-=-=-=-=-=-=-=-=-=
Replaced the POINT 'pixel finder' with Memblock version
Be sure to play with the 'Hscale#' and 'Scale' numbers.
'Hscale#' is the overall Height scaling, 'Scale' is the X/Z size.
This code works best with a small heightmap and a very large terrain/texture map, as the matrix segments are numbered according to the heightmap's pixels, and the texture is not tiled, but rather treated as one painted terrain spread across the whole matrix.
I will probably be horrible at fixing any bugs.
TM$="YOUR DETAIL MAP PATH":HM$="YOUR HEIGHTMAP PATH":backdrop on:sync on:sync rate 25:color backdrop rgb(0,100,200)
Scale=20:Hscale#=Scale:Land=1:HM=2:load image TM$,Land,1:load image HM$,HM,1
imageW=image width(HM):imageH=image height(HM):make matrix 1,imageW*scale,imageH*scale,imageW,imageH:prepare matrix texture Land,Land,imageW,imageH
make memblock from image Land,HM:MemCount=get memblock size(Land)-3:Tx=imageW-1
for TL=(imageW*imageH) to 1 step -1
r=memblock byte(Land,MemCount+2)
g=memblock byte(Land,MemCount+1)
b=memblock byte(Land,MemCount)
Height#=(r*Hscale#+(g*(Hscale#*2))+(b*Hscale#*4))*.01:dec MemCount,4
set matrix tile Land,Tx,Tz,TL:set matrix height Land,Tx,Tz,Height#
if Tx=imageW-1 then set matrix height Land,Tx+1,Tz,Height#
If Tz=imageH-1 then set matrix height Land,Tx,Tz+1,Height#
dec Tx:if Tx<0 then inc Tz:Tx=imageW-1
NEXT
update matrix 1:set camera range 1,Scale*1000
do
control camera using arrowkeys 0,10,4:x#=camera position x():z#=camera position z()
position camera x#,(get ground height(Land,x#,z#))+(Scale*3),z#
sync
LOOP
[EDITED 10/10/13: camera control/height placement]