OK, do you have a
single image for each complete track (which is mapped onto the matrix) or are the tracks built from a series of track pieces (tiled)?
There are no commands to get the colour of the matrix at any given X/Z location, but I have something you could try. If the tracks are single images then you have a chance. If not, then you would need to create images of each track.
Essentially, you texture the matrix with the image and also place it on a hidden screen. As you move over the matrix, you test the colour of the pixel on the hidden image at the equivalent position of the hidden image. It works, but there is a performance hit.
I've knocked together a
very basic code snippet just to show the idea, but it needs working on and would probably be a lot better if you adapted it to use memblocks.
Gosub Setup
Do
Gosub MoveCar
Gosub CheckColour
Sync
Text 0,0,"Matrix Colour: "+Str$(Colour)+" "
Loop
End
CheckColour:
Set Current Bitmap 1
Rem Matrix is 4096x4096 And Image is 512x512 So 1 Pixel On The Image = 8 Matrix Units
Rem So, We Divide Actual Matrix Co-ordinates By 8 To Get Image Pixel X and Y
XPosOnImage = Px#/8.0: YPosOnImage = (4096-Pz#)/8.0
Colour = Point(XPosOnImage,YPosOnImage)
Rem 8421504 is the track colour. If the colour returned is more than 32 different to this then end.
If 8421504-Colour > 32 Then Speed# = 0.0: Move Object 1,-1
Set Current Bitmap 0
Return
MoveCar:
If Leftkey()=1 Then YRotate Object 1,WrapValue(Object Angle Y(1)-1)
If Rightkey()=1 Then YRotate Object 1,WrapValue(Object Angle Y(1)+1)
If Upkey()=0 And Downkey()=0 And Speed#>0.0 Then Dec Speed#,Accel#: If Speed#<0.0 Then Speed#=0.0
If Upkey()=1 Then Inc Speed#,Accel#: If Speed#>15.0 Then Speed#=15.0
If Downkey()=1 Then Dec Speed#,Accel#: If Speed#<0.0 Then Speed#=0.0
Move Object 1,Speed#
Gh#=Get Ground Height(1,Object Position X(1),Object Position Z(1))
Position Object 1,Object Position X(1),Gh#+1.5,Object Position Z(1)
Px#=Object Position X(1): Pz#=Object Position Z(1)
Set Camera To Follow Px#,Gh#,Pz#,Object Angle Y(1),50,Gh#+30,5,0
Point Camera Object Position X(1),Object Position Y(1)+30,Object Position Z(1)
Return
Setup:
Set Display Mode 1024,768,32
Hide Mouse
Sync On: Sync Rate 0: CLS 0
AutoCam Off
Randomize Timer()
Backdrop On
Color Backdrop 0
True=1: False=0
Speed#=0.0: Accel#=0.1
MakeTDKWorld(1,4096,4096,50,50,512,1)
Rem Paste Image For This Track Onto Bitmap 1
Create Bitmap 1,800,600
Paste Image 10000,0,0
Rem And Switch Back To Bitmap 0
Set Current Bitmap 0
Rem Make A Car
Make Object Box 1,6,3,8
YRotate Object 1,90
Color Object 1,RGB(0,0,255)
Px#=2048.0: Pz#=800.0
Gh#=Get Ground Height(1,Px#,Pz#)
Position Object 1,Px#,Gh#+1.5,Pz#
Position Camera 0.0,Get Ground Height(1,0.0,0.0)+20.0,0.0
Ink RGB(255,255,255),0
Return
MouseLook:
CX#=CAMERA ANGLE X(): CY#=CAMERA ANGLE Y(): CZ#=CAMERA ANGLE Z()
CX#=Wrapvalue(CX#+mousemovey())
CY#=Wrapvalue(CY#+mousemovex())
Rotate Camera CX#,CY#,CZ#
Return
Function MakeTDKWorld(MatNum,MatWid,MatHig,TilesX,TilesZ,TextureSize,Hilly)
Set Camera Range 1.0,500000
Create Bitmap 1,800,600
Rem Matrix Texture
CLS 0
Ink RGB(0,128,0),0
Box 0,0,511,511
For N=1 To 3000
Ink RGB(0,Rnd(200),0),0
Dot Rnd(512),Rnd(512)
Next N
Set Text Font "arial"
Set Text Size 400
Set Text To Bold
Ink RGB(128,0,0),0
Text 96,-40,"8"
Text 104,-40,"8"
Text 100,-36,"8"
Text 100,-44,"8"
Blur Bitmap 1,6
For N=1 To 3000
Ink RGB(0,Rnd(200),0),0
Dot Rnd(512),Rnd(512)
Next N
Sync
Ink RGB(128,128,128),0
Text 100,-40,"8"
Blur Bitmap 1,4
Get Image 10000,0,0,TextureSize,TextureSize
Rem SkySphere Texture
CLS 0
For N=0 To 128
Ink RGB(N,N,255-N),0
Line 0,N,256,N
Next N
Get Image 10001,0,0,256,256: Rem Sides
Set Current Bitmap 0
Delete Bitmap 1
Make Matrix MatNum,MatWid,MatHig,TilesX,TilesZ
Prepare Matrix Texture MatNum,10000,TilesX,TilesZ
TileNum=1
For Z=TilesZ-1 to 0 Step -1
For X=0 to TilesX-1
Set Matrix Tile 1,X,Z,TileNum
Inc TileNum
Next X
Next Z
If Hilly=1
For N=1 To 100
X=Rnd(46)+2: Z=Rnd(46)+2
Set Matrix Height MatNum,X,Z,2000.0
Next N
For N=0 To TilesX
Set Matrix Height MatNum,0,N,Rnd(100)+400
Set Matrix Height MatNum,50,N,Rnd(100)+400
Set Matrix Height MatNum,N,0,Rnd(100)+400
Set Matrix Height MatNum,N,50,Rnd(100)+400
Next N
For N=1 To 20
For Z=0 to TilesZ
For X=0 to TilesX
P0#=Get Matrix Height(MatNum,X,Z)
If Z-1>=0
P1#=Get Matrix Height(MatNum,X,Z-1)
Else
P1#=P0#
Endif
If X+1<=TilesX
P2#=Get Matrix Height(MatNum,X+1,Z)
Else
P2#=P0#
Endif
If Z+1<=TilesZ
P3#=Get Matrix Height(MatNum,X,Z+1)
Else
P3#=P0#
Endif
If X-1>=0
P4#=Get Matrix Height(MatNum,X-1,Z)
Else
P4#=P0#
Endif
Average#=(P0#+P1#+P2#+P3#+P4#)/5.0
RHeight#=Average#
Set Matrix Height MatNum,X,Z,RHeight#
Next X
Next Z
Next N
Endif
For Z=1 to TilesZ
For X=1 to TilesX
h8#=get matrix height(MatNum,x,z-1)*5
h4#=get matrix height(MatNum,x-1,z)*5
h#=get matrix height(MatNum,x,z)*5
h2#=get matrix height(MatNum,x,z)*5
x1#=(x-1)*25.0
y1#=h#
x2#=(x+0)*25.0
y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
z1#=(z-1)*25.0
y1#=h2#
z2#=(z+0)*25.0
y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
Set Matrix Normal MatNum,x,z,nx#,ny#,nz#
next X
next Z
Update Matrix MatNum
Rem SkySphere
Make Object Sphere 10500,0.0-(MatWid*9.0)
ZRotate Object 10500,180
Fix Object Pivot 10500
Set Object 10500,1,1,1,0,1,0,1
Texture Object 10500,10001
Position Object 10500,MatWid/2,-1000,MatHig/2
Set Text Font "Tahoma"
Set Text Size 15
Set Text To Normal
EndFunction
TDK_Man