I was tying to make an "endless" terrain using the Scroll Matrix ~ commands and a height map. After hours of trying to figure out why the map wasn't lining up with the texture, I discovered that the texture was "slipping", even though the help says this:
Quote: "The shift ensures that the height and tile data
that represent the matrix contents are wrapped around to allow continuous shifting of the landscape."
Here's the code and attached media. It has to cycle through the matrix about twice before the texture slipping becomes noticable.
Global ht as Dword
Global wt as Dword
dvd=100
Dim h(dvd,dvd) as Integer
Sync On: Sync Rate 60: Autocam Off
Set Camera Range 10,7000
Load Image "background3.jpg",1,1
Make Memblock From Image 1,1
wt=Memblock Dword(1,0)
ht=Memblock Dword(1,4)
Create Bitmap 1,wt,ht
Set Current Bitmap 1
Paste Image 1,0,0
For i# = 0.0 to dvd-1.0
For j# = 0.0 to dvd-1.0
x=(j#+1.0)/dvd*wt
y=(i#+1.0)/dvd*ht
i=i#:j=j#
h(j,i)=(Rgbr(Point(x,y))+Rgbg(Point(x,y))+rgbb(Point(x,y)))/3
Next j#
Next i#
Set Current Bitmap 0
Position Camera 1000,100,500
Make Matrix 1,10000,10000,dvd,dvd
SET MATRIX TEXTURE 1, 1, 0
Prepare Matrix Texture 1,1,dvd,dvd
t=1
For i=0 to dvd-1
For j = 0 to dvd-1
Set Matrix Tile 1,j,(dvd-1)-i,t
Set Matrix Height 1,(dvd-1)-j,(dvd-1)-i,h(j,i)
t=t+1
Next j
Next i
Update Matrix 1
Sprite 1,1,1,1
Scale Sprite 1,25
Make Object Sphere 2,1,1,1
Hide Object 2
Make Object Box 3,20,20,40
f#=1
fs#=20
counter=0
height=0
Do
Set Cursor 200,0:Print "Up/Down arrows to change speed: ";41-Int(fs#)
fs#=fs#+downkey()*(fs#<(dvd-10))-upkey()*(fs#>2)
fm#=10000.0/dvd/fs#
f#=f#+1
counter=counter+1
If counter>5000
if counter<7000
height=height+2
Else
height=height-2
if counter=9000 then counter=0
Endif
Endif
If f#>fs#
Shift Matrix Right 1
f#=1
Endif
Update Matrix 1
Position Object 2,5000.0-f#*fm#,300,5000
Turn Object Right 2,.05
Move Object 2,4000
Position Object 3,Object Position X(2),Get Ground Height(1,Object Position X(2),Object Position Z(2))+10,Object Position Z(2)
Point Object 3,Object Position X(3)-2,Get Ground Height(1,Object Position X(3)-2,Object Position Z(3))+10,Object Position Z(3)
Move Object 2,400
Position Camera Object Position X(2),Object Position Y(2)+height,Object Position Z(2)
Point Camera Object Position X(3),100,Object Position Z(3)
Sync
Loop
"Droids don't rip your arms off when they lose." -H. Solo
REALITY II