i've been using DBC for about 6 months now (an 'extended time limit' demo version ;) ), but then found out about blitz 3 days ago and bought it today after a bit of playing.
from the demos, and playing with meshes, i feel i made the right choice by far (i WAS tossing up whether or not to buy db pro until i found blitz and converted some of my code to it). i wish i'd found about about blitz before db, because i've spent a hell of alot of time on this game, only to find out it will never work quick enough, or have good gfx on darkbasic. if anyone could help me, it would be highly appreciated.
my problem is with matrices(in db) or terrains(in blitz). my game physics work independant of the terrain/matrix, but the terrain/matrix has to look the same as the array that the physics work from, or the cars will be flying around no-where near the track :)
this is the darkbasic code (it's a bit messy, but it works, so you can use it in darkbasic classic demo or retail, or possibly db pro (i havent tried) it needs 2 bitmaps, matrixtexture2.bmp, and roadtexture1.bmp (these can be any size or whatever, but a small bitmap will be faster).
here it is:
[CODE]
sync on
tracklength# = 1000
`roadtexture$ = "roadtexture1.bmp"
`groundtexture$ = "matrixtexture1.bmp"
trackfilename$ = "testing" + "_road.map"
open to write 1,trackfilename$
write float 1,tracklength#
write float 1,100
write float 1,100
write float 1,100
write float 1,100
write string 1,roadtexture$
write string 1,roadtexture$
rem load textures
load image "roadtexture1.bmp",1
`load image "reflectred.bmp",2
`load image "reflectgrey.bmp",3
load image "matrixtexture2.bmp",4
preparematrixs(tracklength#, 100.0, 100.0, 100.0, 100.0, 4.0)
cam_z# = 0
cam_y# = 0
cam_x# = 500
rem set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
rem the amount of tiles we've travelled past
matrix_z# = 1 : rem hopefully
rem check if moving forward to make the track smoother
moving# = 0
rem when this is 10, a reflector is placed
reflectcounter# = 0
rem reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
rem set matrix wireframe off 1
rem 1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
while spacekey() = 0 and matrix_z# < tracklength# * 10
if moving# = 1
rem store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
endif
rem set moving if upkey is pressed, and move to next z joint in matrix.
if upkey()=1
cam_z#=cam_z# + 10
moving# = 1
else
moving# = 0
endif
if moving# = 1
if leftkey()=1 and corner# > maxcorner# * -1 then dec corner#
if rightkey()=1 and corner# < maxcorner# then inc corner#
if leftkey() = 0 and rightkey() = 0 and corner# < 0 then corner# = corner# + .5
if leftkey() = 0 and rightkey() = 0 and corner# > 0 then corner# = corner# - .5
if shiftkey() = 1 and slope# < maxslope# then inc slope#
if controlkey() = 1 and slope# > maxslope# * -1 then dec slope#
if shiftkey() = 0 and controlkey() = 0 and slope# < 0 then slope# = slope# + .5
if shiftkey() = 0 and controlkey() = 0 and slope# > 0 then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
inc matrix_z#
section = setheight(matrix_z#, cam_y#, 100.0, 100.0)
write float 1, matrix_z#
write float 1, cam_x#
write float 1, cam_y#
rem set triangle variables for road creation
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
rem create triangle polygons for road, texture them, and make them static
rem | POINT ONE | POINT TWO | POINT THREE |
MAKE OBJECT TRIANGLE roadtri#, frontright#, fronttriy#, fronttriz#, backleft#, backtriy#, backtriz#, frontleft#, fronttriy#, fronttriz#
make static object roadtri#,1
texture object roadtri#, 1
rem delete object roadtri#
inc roadtri#
MAKE OBJECT TRIANGLE roadtri#, backleft#, backtriy#, backtriz#, frontright#, fronttriy#, fronttriz#, backright#, backtriy#, backtriz#
make static object roadtri#,1
texture object roadtri#, 1
inc roadtri#
endif
update matrix section
update matrix section + 1
update matrix section + 2
position camera cam_x#, cam_y# + 30, cam_z# - 100
set cursor 0,0
print " frame " ; frame#
print " zposition" ;matrix_z#
print " real Z position#" ; cam_z#
inc frame#
sync
endwhile
FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
make object box number#,1,10,.1
position object number#, x# - (trackwidth# * .7), y# + 5, z#
make static object number#,1
texture object number#,2
inc number#
make object box number#,1,10,.1
position object number#,x# + (trackwidth# * .7), y# + 5, z#
make static object number#,1
texture object number#,3
ENDFUNCTION
FUNCTION setheight(z#, y#, leftheight#, rightheight#)
section = round(z#, 100.0)
sectiongroup = section
section = section * 3 + 1
oldz# = z#
if section > 3 then oldy# = get ground height( (sectiongroup * 3 + 1) - 3, 500.0, ABS(oldz# - (sectiongroup +.1)) * 10 )
z# = (z# - (((section -1) / 3)*100))
set cursor 0,50
print "setheight Z : " ; z#
print "setheight matrix : " ; section
print "section : " ; sectiongroup
print "setheight Y : " ; y#
print "setheight oldy : " ; oldy#
print "setheight oldz : " ; (oldz# - (((section -1) / 3)+.1)) *10
rem sync
rem set center matrix height
counter# = 10
while counter# > -1
if z# = 1 and section > 3 then SET MATRIX HEIGHT section, counter#, 0, oldy#
SET MATRIX HEIGHT section, counter#, z#, y#
dec counter#
endwhile
rem set matrix height for left side
counter# = 10
while counter# > -1
SET MATRIX HEIGHT section + 1, 10 - counter#, z#, y# + (((counter# * .01) * counter#) * leftheight#)
dec counter#
endwhile
rem set matrix height for right side
counter# = 0
while counter# < 11
SET MATRIX HEIGHT section + 2, counter#, z#, y# + (((counter# * .01) * counter#) * rightheight#)
inc counter#
endwhile
ENDFUNCTION section
FUNCTION preparematrixs(tracklength#, leftheight#, leftwidth#, rightheight#, rightwidth#, groundtex#)
remaindinglength# = tracklength#
while remaindinglength# > 10
dec remaindinglength#,10
inc sections#
endwhile
matrixnumber# = 1
currentsection# = 0
while sections# > currentsection# - 1
rem create center for current section
creatematrix(matrixnumber#, 1000.0, 1000.0, 10.0 , 100.0, 0.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, leftwidth#, 1000.0, 10.0, 100.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, rightwidth#, 1000.0, 10.0, 100.0, 1000.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
inc currentsection#
set cursor 0,0
print "creating matrix"; matrixnumber#
sync
endwhile
rem create matrix from the remainder
remaindinglength# = int(remaindinglength#)
creatematrix(matrixnumber#, 1000.0, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, 0.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, leftwidth#, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, rightwidth#, remaindinglength# * 100.0, 10.0, remaindinglength#* 10.0, 1000.0, currentsection# * 1000.0, groundtex#)
ENDFUNCTION
FUNCTION creatematrix(matrixnumber#, width#, length#, xsections#, zsections#, xpos#, zpos#, texture#)
make matrix matrixnumber#, width#, length# ,xsections#,zsections#
position matrix matrixnumber#,xpos#,0,zpos#
prepare matrix texture matrixnumber#,texture#,1,1
set matrix texture matrixnumber#,1,0
fill matrix matrixnumber#,0,1
rem set matrix wireframe on matrixnumber#
ENDFUNCTION
FUNCTION round(num#, tonearest#)
ret# = 0
while num# > 0
dec num#, tonearest#
if num# > 0 then inc ret#
endwhile
ENDFUNCTION ret#
[/CODE]
ok, so that's what i want to make. it might be a pretty stupid track editor, but it works perfect for the type of game i'm making, i just need to add functions like addscenery() after it.
ok now i've tried 2 methods to convert it to blitz, the first that i'll show is using "matrix.bb", which is in <blitzfolder>\samples\si\matrix\matrix.bb < this file needs to be in the same folder, im guessing ill get kicked/sued if i include it here, so i wont :). for me, this seems to create the matrices, but then does nothing. this one needs matrixtexture2.bmp (again, any bmp, but preferably a small one, and not pitch black :) )
[CODE]
Graphics3D 640,480,16,0
SetBuffer BackBuffer()
Include "matrix.bb"
Global camera = CreateCamera()
; gonna be for saving (hopefully)
;Type trackstat
; Field x#[100]
; Field y#
;End Type
;was gonna be for the road, but doest work yet
;Global road = CreateMesh()
;Dim roadpoints(5)
;roadtexture$ = "roadtexture1.bmp"
groundtexture$ = "matrixtexture2.bmp"
;trackfilename$ = "testing" + "_road.map"
;Global roadtex = LoadTexture("roadtexture1.bmp")
;Global flectred = LoadTexture("reflectred.bmp")
;Global flectgrey = LoadTexture("reflectgrey.bmp")
;Global terraintex = LoadTexture("matrixtexture2.bmp")
DB_LoadImage( groundtexture, 4 )
tracklength# = 101
;Dim track.trackstat(tracklength)
;For i = 1 To tracklength
; track(i) = New trackstat
;Next
noofterrains = roundint(tracklength, 100)
Dim terrainentitys(noofterrains)
preparematrixs(tracklength#, 100.0, 100.0, 100.0, 100.0, 4.0)
cam_z# = 0
cam_y# = 0
cam_x# = 500
;set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
;the amount of tiles we've travelled past
matrix_z# = 1 ;: hopefully
;check if moving forward to make the track smoother
moving# = 0
;when this is 10, a reflector is placed
reflectcounter# = 0
;reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
;set matrix wireframe off 1
;1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
While matrix_z# < tracklength
If moving# = 1
; store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
EndIf
; set moving If up key is pressed, And move To Next z joint in matrix.
If KeyDown(200)=1
cam_z#=cam_z# + 10
moving# = 1
Else
moving# = 0
EndIf
If KeyDown(108) Then cam_z# = cam_z# - 1
If moving# = 1
If KeyDown(203)=1 And corner# > maxcorner# * -1 Then corner# = corner - 1
If KeyDown(205)=1 And corner# < maxcorner# Then corner# = corner + 1
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# < 0 Then corner# = corner# + .5
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# > 0 Then corner# = corner# - .5
If KeyDown(54) = 1 And slope# < maxslope# Then slope# = slope + 1
If KeyDown(157) = 1 And slope# > maxslope# * -1 Then slope# = slope# - 1
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# < 0 Then slope# = slope# + .5
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# > 0 Then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
matrix_z# = matrix_z# + 1
setheight(matrix_z#, cam_y#, 100, 100)
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
;ERROR - MEMORY ACCESS VIOLATION, i'm leaving this for later :)
;roadpoints(0) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(1) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(2) = AddVertex(road, frontleft#, fronttriy#, fronttriz#)
;roadpoints(3) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(4) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(5) = AddVertex(road, backright#, backtriy#, backtriz#)
;create triangle polygons For road, texture them, And make them static
;AddTriangle(road, roadpoints(0), roadpoints(1), roadpoints(2))
;AddTriangle(road, roadpoints(3), roadpoints(4), roadpoints(5))
EndIf
PositionEntity camera,cam_x#, cam_y# + 30, cam_z# - 100
; PositionEntity camera,cam_x#, 60,0
Locate 0,0
Print " frame " + frame#
Print " zposition" + matrix_z#
Print " real Z position#" + cam_z#
frame# = frame# + 1
UpdateWorld
RenderWorld
Flip
Wend
;not worried about this yet.
;FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
; make object box number#,1,10,.1
; position object number#, x# - (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,2
; inc number#
;; make object box number#,1,10,.1
; position object number#,x# + (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,3
;ENDFUNCTION
FUNCTION setheight(z#, y#, leftheight#, rightheight#)
section = round(z#, 100.0)
sectiongroup = section
section = section * 3 + 1
oldz# = z#
If section > 3 Then oldy# = getgroundheight( (sectiongroup * 3 + 1) - 3, 500.0, Abs(oldz# - (sectiongroup +.1)) * 10 )
z# = (z# - (((section -1) / 3)*100))
; set center matrix height
counter# = 10
While counter# > -1
;try to join 'matrices' together.. doesnt work yet though
If z# = 1 And section > 3 Then SETMATRIXHEIGHT(section, counter#, 0, oldy#)
SETMATRIXHEIGHT(section, counter#, z#, y#)
counter# = counter# + 1
Wend
;left matrix height
counter# = 10
While counter# > -1
SETMATRIXHEIGHT(section + 1, 10 - counter#, z#, y# + (((counter# * .01) * counter#) * leftheight#))
counter = counter - 1
Wend
; set matrix height for right side
counter# = 0
While counter# < 11
SETMATRIXHEIGHT(section + 2, counter#, z#, y# + (((counter# * .01) * counter#) * rightheight#))
counter = counter + 1
Wend
End Function
FUNCTION preparematrixs(tracklength#, leftheight#, leftwidth#, rightheight#, rightwidth#, groundtex#)
sections# = round(tracklength#, 100)
remaindinglength# = remainder(tracklength#, 100)
matrixnumber# = 1
currentsection# = 0
while sections# > currentsection# - 1
; create center for current section
creatematrix(matrixnumber#, 1000.0, 1000.0, 10.0 , 100.0, 0.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, leftwidth#, 1000.0, 10.0, 100.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, rightwidth#, 1000.0, 10.0, 100.0, 1000.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
currentsection# = currentsection# + 1
;set cursor 0,0
print "creating matrix"; matrixnumber#
; sync
Wend
;create matrix from the remainder
remaindinglength# = int(remaindinglength#)
creatematrix(matrixnumber#, 1000.0, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, 0.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, leftwidth#, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, rightwidth#, remaindinglength# * 100.0, 10.0, remaindinglength#* 10.0, 1000.0, currentsection# * 1000.0, groundtex#)
End Function
Function creatematrix(matrixnumber#, width#, length#, xsections#, zsections#, xpos#, zpos#, texture#)
makematrix(matrixnumber#, width#, length# ,xsections#,zsections#)
positionmatrix(matrixnumber#,xpos#,0,zpos#)
preparematrixtexture(matrixnumber#,texture#,1,1)
;setmatrixtexture(matrixnumber#,1,0)
fillmatrix(matrixnumber#,0,1)
; set matrix wireframe on matrixnumber#
End Function
Function round(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = ret# + 1
Wend
Return ret#
End Function
Function roundint(num, tonearest#)
ret = 0
While num > 0
num = num - tonearest
If num > 0 Then ret = ret + 1
Wend
Return ret
End Function
Function remainder(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = num#
Wend
Return ret#
End Function
[/CODE]
the final one is how i would preferably have it (using terrains rather than matrices), but i fear that i will have to completely reprogram my game if i do so. i'll explain what i need at the end of this post. the media needed for this is just matrixtexture2.bmp (again, any bmp)
[CODE]
Graphics3D 640,480,16,0
SetBuffer BackBuffer()
Global camera = CreateCamera()
Type trackstat
Field x#[100]
Field y#
End Type
Global road = CreateMesh()
Dim roadpoints(5)
;roadtexture$ = "roadtexture1.bmp"
groundtexture$ = "matrixtexture2.bmp"
;trackfilename$ = "testing" + "_road.map"
;Global roadtex = LoadTexture("roadtexture1.bmp")
;Global flectred = LoadTexture("reflectred.bmp")
;Global flectgrey = LoadTexture("reflectgrey.bmp")
Global terraintex = LoadTexture("matrixtexture2.bmp")
tracklength = 1000
Dim track.trackstat(tracklength)
For i = 1 To tracklength
track(i) = New trackstat
Next
noofterrains = roundint(tracklength, 100)
Dim terrainentitys(noofterrains)
preparematrixs(tracklength, terraintex)
cam_z# = 0
cam_y# = 0
cam_x# = 500
;set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
;rem the amount of tiles we've travelled past
matrix_z# = 1 ;: rem hopefully
;rem check if moving forward to make the track smoother
moving# = 0
;rem when this is 10, a reflector is placed
reflectcounter# = 0
;rem reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
;rem set matrix wireframe off 1
;rem 1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
While matrix_z# < tracklength
If moving# = 1
; rem store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
EndIf
; set moving If upkey is pressed, And move To Next z joint in matrix.
If KeyDown(200)=1
cam_z#=cam_z# + 10
moving# = 1
Else
moving# = 0
EndIf
If KeyDown(108) Then cam_z# = cam_z# - 1
If moving# = 1
If KeyDown(203)=1 And corner# > maxcorner# * -1 Then corner# = corner - 1
If KeyDown(205)=1 And corner# < maxcorner# Then corner# = corner + 1
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# < 0 Then corner# = corner# + .5
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# > 0 Then corner# = corner# - .5
If KeyDown(54) = 1 And slope# < maxslope# Then slope# = slope + 1
If KeyDown(157) = 1 And slope# > maxslope# * -1 Then slope# = slope# - 1
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# < 0 Then slope# = slope# + .5
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# > 0 Then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
matrix_z# = matrix_z# + 1
section = setheight(matrix_z#, cam_y#)
; write float 1, matrix_z#
; write float 1, cam_x#
; write float 1, cam_y#
; rem set triangle variables for road creation
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
;ERROR - MEMORY ACCESS VIOLATION
;roadpoints(0) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(1) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(2) = AddVertex(road, frontleft#, fronttriy#, fronttriz#)
;roadpoints(3) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(4) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(5) = AddVertex(road, backright#, backtriy#, backtriz#)
;rem create triangle polygons For road, texture them, And make them static
; AddTriangle(road, roadpoints(0), roadpoints(1), roadpoints(2))
; AddTriangle(road, roadpoints(3), roadpoints(4), roadpoints(5))
; make static Object roadtri#,1
; texture object roadtri#, 1
; inc roadtri#
EndIf
PositionEntity camera,cam_x#, cam_y# + 30, cam_z# - 100
; PositionEntity camera,cam_x#, 60,0 ; debug camera stays at start
Locate 0,0
print " frame " ; frame#
print " zposition" ;matrix_z#
print " real Z position#" ; cam_z#
frame# = frame# + 1
UpdateWorld
RenderWorld
Flip
Wend
;FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
; make object box number#,1,10,.1
; position object number#, x# - (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,2
; inc number#
; make object box number#,1,10,.1
; position object number#,x# + (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,3
;ENDFUNCTION
Function setheight(z#, y#)
y# = y# * .001
section = round(z#, 100.0)
z# = remainder(z#, 100.0)
Locate 0,50
;rem set center matrix height
counter = 128
While counter > -1
; If z# = 0 And section > 1 Then ModifyTerrain(terrainentitys(section) - 1, 100, z#, y#)
ModifyTerrain(terrainentitys(section), counter, z#, y#)
counter = counter - 1
Wend
End Function
Function preparematrixs(tracklength, texture)
remaindinglength# = tracklength
; sections = 0
sections = roundint(tracklength, 100)
For terrain = 0 To sections
makeTerrain(terrain, texture)
;terrain = terrain + 1
Next
End Function
Function makeTerrain(terrainno, texture)
terrainentitys(terrainno) = CreateTerrain(128)
ScaleEntity terrainentitys(terrainno),1000,10000,1000,1
PositionEntity terrainentitys(terrainno), 0, 0, terrainno * 1000
EntityTexture terrainentitys(terrainno), terraintex
End Function
Function round(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = ret# + 1
Wend
Return ret#
End Function
Function roundint(num, tonearest#)
ret = 0
While num > 0
num = num - tonearest
If num > 0 Then ret = ret + 1
Wend
Return ret
End Function
Function remainder(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = num#
Wend
Return ret#
End Function
[/CODE]
the only requirements are:
+ flat along the x axis (or at least near the track)
+ every z intercept should be 10 units apart in 3d space.
i dont care how many terrains/matrices it uses, what type of surface it uses (a mesh, terrain, or matrix). i just want to know how to get it to work like it did in DB.
please help a poor unfortunate soul that was struck with the disadvantage of knowing that DB exists, before he knew that blitz existed!
i know this is alot to ask, but if you can help me, you will definitely get your name in my credits :)
thanks in advance
lecks
from the demos, and playing with meshes, i feel i made the right choice by far (i WAS tossing up whether or not to buy db pro until i found blitz and converted some of my code to it). i wish i'd found about about blitz before db, because i've spent a hell of alot of time on this game, only to find out it will never work quick enough, or have good gfx on darkbasic. if anyone could help me, it would be highly appreciated.
my problem is with matrices(in db) or terrains(in blitz). my game physics work independant of the terrain/matrix, but the terrain/matrix has to look the same as the array that the physics work from, or the cars will be flying around no-where near the track :)
this is the darkbasic code (it's a bit messy, but it works, so you can use it in darkbasic classic demo or retail, or possibly db pro (i havent tried) it needs 2 bitmaps, matrixtexture2.bmp, and roadtexture1.bmp (these can be any size or whatever, but a small bitmap will be faster).
here it is:
[CODE]
sync on
tracklength# = 1000
`roadtexture$ = "roadtexture1.bmp"
`groundtexture$ = "matrixtexture1.bmp"
trackfilename$ = "testing" + "_road.map"
open to write 1,trackfilename$
write float 1,tracklength#
write float 1,100
write float 1,100
write float 1,100
write float 1,100
write string 1,roadtexture$
write string 1,roadtexture$
rem load textures
load image "roadtexture1.bmp",1
`load image "reflectred.bmp",2
`load image "reflectgrey.bmp",3
load image "matrixtexture2.bmp",4
preparematrixs(tracklength#, 100.0, 100.0, 100.0, 100.0, 4.0)
cam_z# = 0
cam_y# = 0
cam_x# = 500
rem set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
rem the amount of tiles we've travelled past
matrix_z# = 1 : rem hopefully
rem check if moving forward to make the track smoother
moving# = 0
rem when this is 10, a reflector is placed
reflectcounter# = 0
rem reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
rem set matrix wireframe off 1
rem 1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
while spacekey() = 0 and matrix_z# < tracklength# * 10
if moving# = 1
rem store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
endif
rem set moving if upkey is pressed, and move to next z joint in matrix.
if upkey()=1
cam_z#=cam_z# + 10
moving# = 1
else
moving# = 0
endif
if moving# = 1
if leftkey()=1 and corner# > maxcorner# * -1 then dec corner#
if rightkey()=1 and corner# < maxcorner# then inc corner#
if leftkey() = 0 and rightkey() = 0 and corner# < 0 then corner# = corner# + .5
if leftkey() = 0 and rightkey() = 0 and corner# > 0 then corner# = corner# - .5
if shiftkey() = 1 and slope# < maxslope# then inc slope#
if controlkey() = 1 and slope# > maxslope# * -1 then dec slope#
if shiftkey() = 0 and controlkey() = 0 and slope# < 0 then slope# = slope# + .5
if shiftkey() = 0 and controlkey() = 0 and slope# > 0 then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
inc matrix_z#
section = setheight(matrix_z#, cam_y#, 100.0, 100.0)
write float 1, matrix_z#
write float 1, cam_x#
write float 1, cam_y#
rem set triangle variables for road creation
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
rem create triangle polygons for road, texture them, and make them static
rem | POINT ONE | POINT TWO | POINT THREE |
MAKE OBJECT TRIANGLE roadtri#, frontright#, fronttriy#, fronttriz#, backleft#, backtriy#, backtriz#, frontleft#, fronttriy#, fronttriz#
make static object roadtri#,1
texture object roadtri#, 1
rem delete object roadtri#
inc roadtri#
MAKE OBJECT TRIANGLE roadtri#, backleft#, backtriy#, backtriz#, frontright#, fronttriy#, fronttriz#, backright#, backtriy#, backtriz#
make static object roadtri#,1
texture object roadtri#, 1
inc roadtri#
endif
update matrix section
update matrix section + 1
update matrix section + 2
position camera cam_x#, cam_y# + 30, cam_z# - 100
set cursor 0,0
print " frame " ; frame#
print " zposition" ;matrix_z#
print " real Z position#" ; cam_z#
inc frame#
sync
endwhile
FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
make object box number#,1,10,.1
position object number#, x# - (trackwidth# * .7), y# + 5, z#
make static object number#,1
texture object number#,2
inc number#
make object box number#,1,10,.1
position object number#,x# + (trackwidth# * .7), y# + 5, z#
make static object number#,1
texture object number#,3
ENDFUNCTION
FUNCTION setheight(z#, y#, leftheight#, rightheight#)
section = round(z#, 100.0)
sectiongroup = section
section = section * 3 + 1
oldz# = z#
if section > 3 then oldy# = get ground height( (sectiongroup * 3 + 1) - 3, 500.0, ABS(oldz# - (sectiongroup +.1)) * 10 )
z# = (z# - (((section -1) / 3)*100))
set cursor 0,50
print "setheight Z : " ; z#
print "setheight matrix : " ; section
print "section : " ; sectiongroup
print "setheight Y : " ; y#
print "setheight oldy : " ; oldy#
print "setheight oldz : " ; (oldz# - (((section -1) / 3)+.1)) *10
rem sync
rem set center matrix height
counter# = 10
while counter# > -1
if z# = 1 and section > 3 then SET MATRIX HEIGHT section, counter#, 0, oldy#
SET MATRIX HEIGHT section, counter#, z#, y#
dec counter#
endwhile
rem set matrix height for left side
counter# = 10
while counter# > -1
SET MATRIX HEIGHT section + 1, 10 - counter#, z#, y# + (((counter# * .01) * counter#) * leftheight#)
dec counter#
endwhile
rem set matrix height for right side
counter# = 0
while counter# < 11
SET MATRIX HEIGHT section + 2, counter#, z#, y# + (((counter# * .01) * counter#) * rightheight#)
inc counter#
endwhile
ENDFUNCTION section
FUNCTION preparematrixs(tracklength#, leftheight#, leftwidth#, rightheight#, rightwidth#, groundtex#)
remaindinglength# = tracklength#
while remaindinglength# > 10
dec remaindinglength#,10
inc sections#
endwhile
matrixnumber# = 1
currentsection# = 0
while sections# > currentsection# - 1
rem create center for current section
creatematrix(matrixnumber#, 1000.0, 1000.0, 10.0 , 100.0, 0.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, leftwidth#, 1000.0, 10.0, 100.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, rightwidth#, 1000.0, 10.0, 100.0, 1000.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
inc currentsection#
set cursor 0,0
print "creating matrix"; matrixnumber#
sync
endwhile
rem create matrix from the remainder
remaindinglength# = int(remaindinglength#)
creatematrix(matrixnumber#, 1000.0, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, 0.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, leftwidth#, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
inc matrixnumber#
creatematrix(matrixnumber#, rightwidth#, remaindinglength# * 100.0, 10.0, remaindinglength#* 10.0, 1000.0, currentsection# * 1000.0, groundtex#)
ENDFUNCTION
FUNCTION creatematrix(matrixnumber#, width#, length#, xsections#, zsections#, xpos#, zpos#, texture#)
make matrix matrixnumber#, width#, length# ,xsections#,zsections#
position matrix matrixnumber#,xpos#,0,zpos#
prepare matrix texture matrixnumber#,texture#,1,1
set matrix texture matrixnumber#,1,0
fill matrix matrixnumber#,0,1
rem set matrix wireframe on matrixnumber#
ENDFUNCTION
FUNCTION round(num#, tonearest#)
ret# = 0
while num# > 0
dec num#, tonearest#
if num# > 0 then inc ret#
endwhile
ENDFUNCTION ret#
[/CODE]
ok, so that's what i want to make. it might be a pretty stupid track editor, but it works perfect for the type of game i'm making, i just need to add functions like addscenery() after it.
ok now i've tried 2 methods to convert it to blitz, the first that i'll show is using "matrix.bb", which is in <blitzfolder>\samples\si\matrix\matrix.bb < this file needs to be in the same folder, im guessing ill get kicked/sued if i include it here, so i wont :). for me, this seems to create the matrices, but then does nothing. this one needs matrixtexture2.bmp (again, any bmp, but preferably a small one, and not pitch black :) )
[CODE]
Graphics3D 640,480,16,0
SetBuffer BackBuffer()
Include "matrix.bb"
Global camera = CreateCamera()
; gonna be for saving (hopefully)
;Type trackstat
; Field x#[100]
; Field y#
;End Type
;was gonna be for the road, but doest work yet
;Global road = CreateMesh()
;Dim roadpoints(5)
;roadtexture$ = "roadtexture1.bmp"
groundtexture$ = "matrixtexture2.bmp"
;trackfilename$ = "testing" + "_road.map"
;Global roadtex = LoadTexture("roadtexture1.bmp")
;Global flectred = LoadTexture("reflectred.bmp")
;Global flectgrey = LoadTexture("reflectgrey.bmp")
;Global terraintex = LoadTexture("matrixtexture2.bmp")
DB_LoadImage( groundtexture, 4 )
tracklength# = 101
;Dim track.trackstat(tracklength)
;For i = 1 To tracklength
; track(i) = New trackstat
;Next
noofterrains = roundint(tracklength, 100)
Dim terrainentitys(noofterrains)
preparematrixs(tracklength#, 100.0, 100.0, 100.0, 100.0, 4.0)
cam_z# = 0
cam_y# = 0
cam_x# = 500
;set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
;the amount of tiles we've travelled past
matrix_z# = 1 ;: hopefully
;check if moving forward to make the track smoother
moving# = 0
;when this is 10, a reflector is placed
reflectcounter# = 0
;reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
;set matrix wireframe off 1
;1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
While matrix_z# < tracklength
If moving# = 1
; store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
EndIf
; set moving If up key is pressed, And move To Next z joint in matrix.
If KeyDown(200)=1
cam_z#=cam_z# + 10
moving# = 1
Else
moving# = 0
EndIf
If KeyDown(108) Then cam_z# = cam_z# - 1
If moving# = 1
If KeyDown(203)=1 And corner# > maxcorner# * -1 Then corner# = corner - 1
If KeyDown(205)=1 And corner# < maxcorner# Then corner# = corner + 1
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# < 0 Then corner# = corner# + .5
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# > 0 Then corner# = corner# - .5
If KeyDown(54) = 1 And slope# < maxslope# Then slope# = slope + 1
If KeyDown(157) = 1 And slope# > maxslope# * -1 Then slope# = slope# - 1
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# < 0 Then slope# = slope# + .5
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# > 0 Then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
matrix_z# = matrix_z# + 1
setheight(matrix_z#, cam_y#, 100, 100)
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
;ERROR - MEMORY ACCESS VIOLATION, i'm leaving this for later :)
;roadpoints(0) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(1) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(2) = AddVertex(road, frontleft#, fronttriy#, fronttriz#)
;roadpoints(3) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(4) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(5) = AddVertex(road, backright#, backtriy#, backtriz#)
;create triangle polygons For road, texture them, And make them static
;AddTriangle(road, roadpoints(0), roadpoints(1), roadpoints(2))
;AddTriangle(road, roadpoints(3), roadpoints(4), roadpoints(5))
EndIf
PositionEntity camera,cam_x#, cam_y# + 30, cam_z# - 100
; PositionEntity camera,cam_x#, 60,0
Locate 0,0
Print " frame " + frame#
Print " zposition" + matrix_z#
Print " real Z position#" + cam_z#
frame# = frame# + 1
UpdateWorld
RenderWorld
Flip
Wend
;not worried about this yet.
;FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
; make object box number#,1,10,.1
; position object number#, x# - (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,2
; inc number#
;; make object box number#,1,10,.1
; position object number#,x# + (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,3
;ENDFUNCTION
FUNCTION setheight(z#, y#, leftheight#, rightheight#)
section = round(z#, 100.0)
sectiongroup = section
section = section * 3 + 1
oldz# = z#
If section > 3 Then oldy# = getgroundheight( (sectiongroup * 3 + 1) - 3, 500.0, Abs(oldz# - (sectiongroup +.1)) * 10 )
z# = (z# - (((section -1) / 3)*100))
; set center matrix height
counter# = 10
While counter# > -1
;try to join 'matrices' together.. doesnt work yet though
If z# = 1 And section > 3 Then SETMATRIXHEIGHT(section, counter#, 0, oldy#)
SETMATRIXHEIGHT(section, counter#, z#, y#)
counter# = counter# + 1
Wend
;left matrix height
counter# = 10
While counter# > -1
SETMATRIXHEIGHT(section + 1, 10 - counter#, z#, y# + (((counter# * .01) * counter#) * leftheight#))
counter = counter - 1
Wend
; set matrix height for right side
counter# = 0
While counter# < 11
SETMATRIXHEIGHT(section + 2, counter#, z#, y# + (((counter# * .01) * counter#) * rightheight#))
counter = counter + 1
Wend
End Function
FUNCTION preparematrixs(tracklength#, leftheight#, leftwidth#, rightheight#, rightwidth#, groundtex#)
sections# = round(tracklength#, 100)
remaindinglength# = remainder(tracklength#, 100)
matrixnumber# = 1
currentsection# = 0
while sections# > currentsection# - 1
; create center for current section
creatematrix(matrixnumber#, 1000.0, 1000.0, 10.0 , 100.0, 0.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, leftwidth#, 1000.0, 10.0, 100.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, rightwidth#, 1000.0, 10.0, 100.0, 1000.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
currentsection# = currentsection# + 1
;set cursor 0,0
print "creating matrix"; matrixnumber#
; sync
Wend
;create matrix from the remainder
remaindinglength# = int(remaindinglength#)
creatematrix(matrixnumber#, 1000.0, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, 0.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, leftwidth#, remaindinglength# * 100.0, 10.0, remaindinglength# * 10.0, leftwidth# * -1.0, currentsection# * 1000.0, groundtex#)
matrixnumber = matrixnumber + 1
creatematrix(matrixnumber#, rightwidth#, remaindinglength# * 100.0, 10.0, remaindinglength#* 10.0, 1000.0, currentsection# * 1000.0, groundtex#)
End Function
Function creatematrix(matrixnumber#, width#, length#, xsections#, zsections#, xpos#, zpos#, texture#)
makematrix(matrixnumber#, width#, length# ,xsections#,zsections#)
positionmatrix(matrixnumber#,xpos#,0,zpos#)
preparematrixtexture(matrixnumber#,texture#,1,1)
;setmatrixtexture(matrixnumber#,1,0)
fillmatrix(matrixnumber#,0,1)
; set matrix wireframe on matrixnumber#
End Function
Function round(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = ret# + 1
Wend
Return ret#
End Function
Function roundint(num, tonearest#)
ret = 0
While num > 0
num = num - tonearest
If num > 0 Then ret = ret + 1
Wend
Return ret
End Function
Function remainder(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = num#
Wend
Return ret#
End Function
[/CODE]
the final one is how i would preferably have it (using terrains rather than matrices), but i fear that i will have to completely reprogram my game if i do so. i'll explain what i need at the end of this post. the media needed for this is just matrixtexture2.bmp (again, any bmp)
[CODE]
Graphics3D 640,480,16,0
SetBuffer BackBuffer()
Global camera = CreateCamera()
Type trackstat
Field x#[100]
Field y#
End Type
Global road = CreateMesh()
Dim roadpoints(5)
;roadtexture$ = "roadtexture1.bmp"
groundtexture$ = "matrixtexture2.bmp"
;trackfilename$ = "testing" + "_road.map"
;Global roadtex = LoadTexture("roadtexture1.bmp")
;Global flectred = LoadTexture("reflectred.bmp")
;Global flectgrey = LoadTexture("reflectgrey.bmp")
Global terraintex = LoadTexture("matrixtexture2.bmp")
tracklength = 1000
Dim track.trackstat(tracklength)
For i = 1 To tracklength
track(i) = New trackstat
Next
noofterrains = roundint(tracklength, 100)
Dim terrainentitys(noofterrains)
preparematrixs(tracklength, terraintex)
cam_z# = 0
cam_y# = 0
cam_x# = 500
;set maximum and current corner and slope variables,
maxcorner# = 10
maxslope# = 5
corner# = 0
slope# = 0
;rem the amount of tiles we've travelled past
matrix_z# = 1 ;: rem hopefully
;rem check if moving forward to make the track smoother
moving# = 0
;rem when this is 10, a reflector is placed
reflectcounter# = 0
;rem reflector object no. start at 900 to avoid conflict in the game
reflectno# = 1000
;rem set matrix wireframe off 1
;rem 1st Triangle to create road from
roadtri# = 20000
backtriy# = 0
fronttriy# = 0
backtrix# = 500
fronttrix# = 500
backtriz# = 0
fronttriz# = 0
moving# = 0
frame# = 0
section = 1
While matrix_z# < tracklength
If moving# = 1
; rem store variables for road triangle polygon creation
backtriy# = cam_y# + 0.5
backtrix# = cam_x#
backtriz# = cam_z#
EndIf
; set moving If upkey is pressed, And move To Next z joint in matrix.
If KeyDown(200)=1
cam_z#=cam_z# + 10
moving# = 1
Else
moving# = 0
EndIf
If KeyDown(108) Then cam_z# = cam_z# - 1
If moving# = 1
If KeyDown(203)=1 And corner# > maxcorner# * -1 Then corner# = corner - 1
If KeyDown(205)=1 And corner# < maxcorner# Then corner# = corner + 1
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# < 0 Then corner# = corner# + .5
If KeyDown(203) = 0 And KeyDown(205) = 0 And corner# > 0 Then corner# = corner# - .5
If KeyDown(54) = 1 And slope# < maxslope# Then slope# = slope + 1
If KeyDown(157) = 1 And slope# > maxslope# * -1 Then slope# = slope# - 1
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# < 0 Then slope# = slope# + .5
If KeyDown(54) = 0 And KeyDown(157) = 0 And slope# > 0 Then slope# = slope# - .5
cam_x# = cam_x# + corner#
cam_y# = cam_y# + slope#
matrix_z# = matrix_z# + 1
section = setheight(matrix_z#, cam_y#)
; write float 1, matrix_z#
; write float 1, cam_x#
; write float 1, cam_y#
; rem set triangle variables for road creation
fronttriy# = cam_y# + 0.5
fronttrix# = cam_x#
fronttriz# = cam_z#
backleft# = backtrix# - 25
backright# = backtrix# + 25
frontleft# = fronttrix# - 25
frontright# = fronttrix# + 25
;ERROR - MEMORY ACCESS VIOLATION
;roadpoints(0) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(1) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(2) = AddVertex(road, frontleft#, fronttriy#, fronttriz#)
;roadpoints(3) = AddVertex(road, backleft#, backtriy#, backtriz#)
;roadpoints(4) = AddVertex(road, frontright#, fronttriy#, fronttriz#)
;roadpoints(5) = AddVertex(road, backright#, backtriy#, backtriz#)
;rem create triangle polygons For road, texture them, And make them static
; AddTriangle(road, roadpoints(0), roadpoints(1), roadpoints(2))
; AddTriangle(road, roadpoints(3), roadpoints(4), roadpoints(5))
; make static Object roadtri#,1
; texture object roadtri#, 1
; inc roadtri#
EndIf
PositionEntity camera,cam_x#, cam_y# + 30, cam_z# - 100
; PositionEntity camera,cam_x#, 60,0 ; debug camera stays at start
Locate 0,0
print " frame " ; frame#
print " zposition" ;matrix_z#
print " real Z position#" ; cam_z#
frame# = frame# + 1
UpdateWorld
RenderWorld
Flip
Wend
;FUNCTION placereflectors(number#, x#, y#, z#, trackwidth#, texture1#, texture2#)
; make object box number#,1,10,.1
; position object number#, x# - (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,2
; inc number#
; make object box number#,1,10,.1
; position object number#,x# + (trackwidth# * .7), y# + 5, z#
; make static object number#,1
; texture object number#,3
;ENDFUNCTION
Function setheight(z#, y#)
y# = y# * .001
section = round(z#, 100.0)
z# = remainder(z#, 100.0)
Locate 0,50
;rem set center matrix height
counter = 128
While counter > -1
; If z# = 0 And section > 1 Then ModifyTerrain(terrainentitys(section) - 1, 100, z#, y#)
ModifyTerrain(terrainentitys(section), counter, z#, y#)
counter = counter - 1
Wend
End Function
Function preparematrixs(tracklength, texture)
remaindinglength# = tracklength
; sections = 0
sections = roundint(tracklength, 100)
For terrain = 0 To sections
makeTerrain(terrain, texture)
;terrain = terrain + 1
Next
End Function
Function makeTerrain(terrainno, texture)
terrainentitys(terrainno) = CreateTerrain(128)
ScaleEntity terrainentitys(terrainno),1000,10000,1000,1
PositionEntity terrainentitys(terrainno), 0, 0, terrainno * 1000
EntityTexture terrainentitys(terrainno), terraintex
End Function
Function round(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = ret# + 1
Wend
Return ret#
End Function
Function roundint(num, tonearest#)
ret = 0
While num > 0
num = num - tonearest
If num > 0 Then ret = ret + 1
Wend
Return ret
End Function
Function remainder(num#, tonearest#)
ret# = 0
While num# > 0
num# = num# - tonearest#
If num# > 0 Then ret# = num#
Wend
Return ret#
End Function
[/CODE]
the only requirements are:
+ flat along the x axis (or at least near the track)
+ every z intercept should be 10 units apart in 3d space.
i dont care how many terrains/matrices it uses, what type of surface it uses (a mesh, terrain, or matrix). i just want to know how to get it to work like it did in DB.
please help a poor unfortunate soul that was struck with the disadvantage of knowing that DB exists, before he knew that blitz existed!
i know this is alot to ask, but if you can help me, you will definitely get your name in my credits :)
thanks in advance
lecks