OK so i managed to do this now and as said i would put the code up here is the link to the thread i used to do this
http://forum.thegamecreators.com/?m=forum_view&t=194598&b=1
And here is an application of it with Dark Physics
color backdrop rgb(0,0,0)
phy start
make matrix 1,64,64,64,64
set matrix height 1,5,5,10
//randomize matrix 1,64
makeobjectfrommatrix(1,1,64,64,64,64,64,64)
delete matrix 1
position object 1,0,0.1,0
PHY MAKE RIGID BODY STATIC box 1
position camera camera position x(),3,camera position z()-3
do
set window title str$(screen fps())
phy update
sync
Loop
function makeobjectfrommatrix(objectnumber,matrixnumber,xsize,zsize,numtilesx,numtilesz,imgx,imgz)
`this command works perfectly
local vertcnt = 0
local indexcnt = 0
local sizeofx# = 0.0
local sizeofz# = 0.0
local imgsizex# = 0.0
local imgsizez# = 0.0
local strtx# = 0.0
local strtz# = 0.0
local endx#=0.0
local endz#=0.0
if object exist(objectnumber)=1 then exitfunction
if matrix exist(matrixnumber)=0 then exitfunction
vertcnt=(numtilesx*numtilesz)*4
indexcnt=(numtilesx*numtilesz)*6
make object new objectnumber,vertcnt,indexcnt,338
lock vertexdata for limb objectnumber, 0
sizeofx#=(xsize/numtilesx)
sizeofz#=(zsize/numtilesz)
`get image tile sizes
imgsizex#=(1.0/(imgx+0.0))
imgsizez#=(1.0/(imgz+0.0))
usingvert=0
usingindex=0
for x=1 to numtilesx step 1
for y=1 to numtilesz step 1
`front face tris
set vertexdata position usingvert,(sizeofx#*x),get matrix height(matrixnumber,x,y),(sizeofz#*y):set vertexdata normals usingvert,0,1,0
set vertexdata position usingvert+1,(sizeofx#*x)-sizeofx#,get matrix height(matrixnumber,x-1,y),(sizeofz#*y):set vertexdata normals usingvert+1,0,1,0
set vertexdata position usingvert+2,(sizeofx#*x),get matrix height(matrixnumber,x,y-1),(sizeofz#*y)-sizeofz#:set vertexdata normals usingvert+2,0,1,0
set vertexdata position usingvert+3,(sizeofx#*x)-sizeofx#,get matrix height(matrixnumber,x-1,y-1),(sizeofz#*y)-sizeofz#:set vertexdata normals usingvert+3,0,1,0
//tileis=getmatrixtile(x,y)
count=0
strtx#=0.0
strtz#=0.0
for g1=1 to imgx step 1
for g2=1 to imgz step 1
count=count+1
if count=tileis then strtx#=((imgsizex#*g1+0.0)-imgsizex#):strtz#=((imgsizez#*g2+0.0)-imgsizez#)
next g2
next g1
endx#=strtx#+imgsizex#+0.0
endz#=strtz#+imgsizez#+0.0
set vertexdata uv usingvert,strtx#,strtz#
set vertexdata uv usingvert+1,endx#,strtz#
set vertexdata uv usingvert+2,strtx#,endz#
set vertexdata uv usingvert+3,endx#,endz#
`set indexdata usingindex,usingvert+3
`set indexdata usingindex+1,usingvert+1
`set indexdata usingindex+2,usingvert+2
set indexdata usingindex,usingvert+3
set indexdata usingindex+1,usingvert+0
set indexdata usingindex+2,usingvert+2
`set indexdata usingindex+3,usingvert+2
`set indexdata usingindex+4,usingvert+1
`set indexdata usingindex+5,usingvert
set indexdata usingindex+3,usingvert+1
set indexdata usingindex+4,usingvert+0
set indexdata usingindex+5,usingvert+3
usingindex=usingindex+6
usingvert=usingvert+4
next y
next x
unlock vertexdata
set object normals objectnumber
set object ambient objectnumber,1
endfunction
codaing at night alway and forever