... it jumps now and then
Perhaps those "jumps" appear when the x and z positions of the matrix have to be adjusted at the same time. In your code, for a given time, a change in the x position will restore the z position to mz even if it has to become mz +or- tsize.
Maybe the following code will solve it:
+ Code Snippetsync on: sync rate 0
msize = 5000
msize2 = msize / 2
tiles# = 10
tsize = msize/tiles#
make matrix 1,msize,msize,tiles#,tiles#
`If you got an image for the texture put it here...
`load image "a.bmp",1
`prepare matrix texture 1,1,1,1
randomize matrix 1,100
`set matrix 1,1,1,1,1,1,1,1
position matrix 1,0,0,0
update matrix 1
position camera 0-msize2,80,0-msize2
rotate camera 0,0,0
hide mouse
do
`simple camera rotation and movement with cursor keys
if upkey() then move camera 2
if downkey() then move camera -2
if rightkey() then yrotate camera wrapvalue(camera angle y()+2)
if leftkey() then yrotate camera wrapvalue(camera angle y()-2)
ScrollMatrix(1,0,msize,tsize)
`scrollmatrix2(1,msize2,tiles#)
`this takes care of the matrix
x# = camera position x()
z#=camera position z()
y# = get ground height(1,x#-matrix position x(1),z#-matrix position z(1))
position camera x#,y#+20,z#
sync
loop
function ScrollMatrix(matnum as integer, maincam as integer,_
msize as integer,tsize as float)
cx = camera position x(maincam)
cz = camera position z(maincam)
mx = matrix position x(matnum)
my = matrix position y(matnum)
mz = matrix position z(matnum)
dx=(mx+msize/2)-cx
dz=(mz+msize/2)-cz
offsetx=0
offsetz=0
if dz > tsize
shift matrix down matnum
offsetz=-tsize
endif
if dz < -tsize
shift matrix up matnum
offsetz=tsize
endif
if dx > tsize
shift matrix right matnum
offsetx=-tsize
endif
if dx < -tsize
shift matrix left matnum
offsetx=tsize
endif
position matrix matnum,mx+offsetx,my,mz+offsetz
endfunction
I get a problem when I try to use the code with a waving matrix (see attached code). I don't know whether it is the one you're referring as "tiling problem" or not, but I haven't found a solution for it yet. Any ideas?