Well, I got it down to this, but I still can't figure out where it gets 6 across from...
Here's the code, tell me if you can figure out how to reduce 6 tiles across....
`Track Editor v1.0
`======================
`P.Parkinson
`======================
`Main Source File
randomize timer()
set display mode 1024,768,32
sync on
sync rate 60
autocam off
color backdrop 0,rgb(128,128,255)
set text font "Arial"
set text size 16
set text transparent
position camera 0,800,0
point camera 0,0,0
make_track_images()
vec1=make vector3(1)
vec2=make vector3(2)
vec3=make vector3(3)
vec4=make vector3(4)
vec5=make vector3(5)
type pointType
x as float
y as float
z as float
endtype
global maxPoints as integer=100
global numPoints as integer=4
dim points(maxPoints) as pointType
global numSections as integer=4
global maxSections as integer
global joined as integer=0
dim trackData(maxPoints*numSections,5) as float
global roll as integer=0
global roll_multiplyer as float=3.0
global editMode as integer=0
global angle#=0
dim pos(maxPoints*numSections,16)as pointType
`set up start points
for l=1 to numPoints
points(l).x=l*70-200
points(l).y=25.0
next l
create_point_objects()
position_point_objects()
`main loop
do
if joined=0 and editMode=0 then add_point()
if editMode=0 then move_points(1,numPoints)
if editMode=1 then adjust_height(1,numPoints)
maxSections=add_sections()
set_section_angles_and_positions()
add_point_numbers()
`add_section_angles()
check_for_loop_join()
check_for_change_mode()
check_for_camera_move()
if editMode=0
ink rgb(255,255,255),0
text 0,0,"Num. Control Points "+str$(numPoints)
text 0,20,"Num. Sections "+str$(maxSections-999)+" Parts Per Sector(Used For LOD) "+str$(numSections)
if joined=0 then text 0,40,"Loop Is Open And Points Can Be Added":text 0,60,"Press ' j ' To Close The Loop"
if joined=1 then text 0,40,"Loop Is Joined And Points Cant Be Added":text 0,60,"Press ' u ' To Open The Loop"
text 0,80,"You Are In Point Edit Mode,To Switch To Hight Press ' h '"
text 0,100,"LMB Add Point"
text 0,120,"RMB Move Point"
text 0,140,"SPACE To Switch On And Off Test Mode"
text 0,160,"' s ' To Save Track Data Out As A Text File"
text 0,180,"' l ' To Use Test Track Data"
endif
if editMode=1
ink rgb(255,255,255),0
text 0,0,"Num. Control Points "+str$(numPoints)
text 0,20,"Num. Sections "+str$(maxSections-999)+" Parts Per Sector(Used For LOD) "+str$(numSections)
if joined=0 then text 0,40,"Loop Is Open And Points Can Be Added":text 0,60,"Press ' j ' To Close The Loop"
if joined=1 then text 0,40,"Loop Is Joined And Points Cant Be Added":text 0,60,"Press ' u ' To Open The Loop"
text 0,80,"You Are In Hight Edit Mode,To Switch To Point Press ' p '"
text 0,100,"LMB Lower Point"
text 0,120,"RMB Raise Point"
text 0,140,"L Arrow Spin Left"
text 0,160,"R Arrow Spin Right"
text 0,180,"U Arrow Zoom In"
text 0,200,"D Arrow Zoom Out"
text 0,220,"SPACE To Switch On And Off Test Mode"
text 0,240,"' s ' To Save Track Data Out As A Text File"
text 0,260,"' l ' To Use Test Track Data"
endif
if spacekey() then free_flight()
if inkey$()="s" then save_data()
if inkey$()="l" then use_test_track_data()
if inkey$()="+" and numSections<50 then inc numSections
if inkey$()="-" and numSections>5
for l=1000 to maxSections
if object exist(l) then delete object l
next l
dec numSections
endif
sync
loop
function create_point_objects()
for l=1 to numPoints
if object exist(l)=0
make object sphere l,20
endif
color object l,rgb(255,255,0)
if l=1 then color object l,rgb(255,0,0)
if l=numPoints then color object l,rgb(0,255,0)
next l
endfunction
function position_point_objects()
for l=1 to numPoints
if object exist(l)
position object l,points(l).x,points(l).y,points(l).z
endif
next l
endfunction
function add_point()
if mouseclick()=1
if numPoints<maxPoints
inc numPoints
Pick Screen MouseX(),MouseY(),1000
psx = Get Pick Vector X() + Camera Position X()
psy = 25
psz = Get Pick Vector Z() + Camera Position Z()
points(numPoints).x=psx
points(numPoints).y=psy
points(numPoints).z=psz
create_point_objects()
position_point_objects()
while mouseclick()=1
endwhile
endif
endif
endfunction
function add_point_numbers()
ink rgb(0,0,255),0
for l=1 to numPoints
text object screen x(l)-6,object screen y(l)-6,str$(l)
next l
endfunction
function add_sections()
obj=1000
for l=1 to numPoints-3
`Fill vectors with point coordinates
set vector3 1,points(l).x,points(l).y,points(l).z
set vector3 2,points(l+1).x,points(l+1).y,points(l+1).z
set vector3 3,points(l+2).x,points(l+2).y,points(l+2).z
set vector3 4,points(l+3).x,points(l+3).y,points(l+3).z
`Loop through the sections between points
for y = 1 to numSections
`Work out point on catmull rom spline (filledVector,pointA,pointB,pointC,pointD,value (0.0 = beginning of curve, 1.0 = end of curve, 0.5 = half way down curve))
catmullrom vector3 5,1,2,3,4,1.0/numSections*y
`Draw point
if object exist(obj)
position object obj,x vector3(5),y vector3(5),z vector3(5)
else
make object box obj,20,1,1:position object obj,x vector3(5),y vector3(5),z vector3(5)
endif
inc obj
next y
next l
if joined=1
`Fill vectors with point coordinates
set vector3 1,points(numPoints-2).x,points(numPoints-2).y,points(numPoints-2).z
set vector3 2,points(numPoints-1).x,points(numPoints-1).y,points(numPoints-1).z
set vector3 3,points(numPoints).x,points(numPoints).y,points(numPoints).z
set vector3 4,points(1).x,points(1).y,points(1).z
`Loop through the sections between points
for y = 1 to numSections
`Work out point on catmull rom spline (filledVector,pointA,pointB,pointC,pointD,value (0.0 = beginning of curve, 1.0 = end of curve, 0.5 = half way down curve))
catmullrom vector3 5,1,2,3,4,1.0/numSections*y
`Draw point
if object exist(obj)
position object obj,x vector3(5),y vector3(5),z vector3(5)
else
make object box obj,20,1,1:position object obj,x vector3(5),y vector3(5),z vector3(5)
endif
inc obj
next y
`Fill vectors with point coordinates
set vector3 1,points(numPoints-1).x,points(numPoints-1).y,points(numPoints-1).z
set vector3 2,points(numPoints).x,points(numPoints).y,points(numPoints).z
set vector3 3,points(1).x,points(1).y,points(1).z
set vector3 4,points(2).x,points(2).y,points(2).z
`Loop through the sections between points
for y = 1 to numSections
`Work out point on catmull rom spline (filledVector,pointA,pointB,pointC,pointD,value (0.0 = beginning of curve, 1.0 = end of curve, 0.5 = half way down curve))
catmullrom vector3 5,1,2,3,4,1.0/numSections*y
`Draw point
if object exist(obj)
position object obj,x vector3(5),y vector3(5),z vector3(5)
else
make object box obj,20,1,1:position object obj,x vector3(5),y vector3(5),z vector3(5)
endif
inc obj
next y
`Fill vectors with point coordinates
set vector3 1,points(numPoints).x,points(numPoints).y,points(numPoints).z
set vector3 2,points(1).x,points(1).y,points(1).z
set vector3 3,points(2).x,points(2).y,points(2).z
set vector3 4,points(3).x,points(3).y,points(3).z
`Loop through the sections between points
for y = 1 to numSections
`Work out point on catmull rom spline (filledVector,pointA,pointB,pointC,pointD,value (0.0 = beginning of curve, 1.0 = end of curve, 0.5 = half way down curve))
catmullrom vector3 5,1,2,3,4,1.0/numSections*y
`Draw point
if object exist(obj)
position object obj,x vector3(5),y vector3(5),z vector3(5)
else
make object box obj,20,1,1:position object obj,x vector3(5),y vector3(5),z vector3(5)
endif
inc obj
next y
endif
dec obj
point_sections_to_next_one()
endfunction obj
function move_points(s,e)
obj=0
if mouseclick()=2
obj=pick object (mousex(),mousey(),s,e)
if obj>0
d#=get pick distance()
Pick Screen MouseX(),MouseY(),d#
psx = Get Pick Vector X() + Camera Position X()
psz = Get Pick Vector Z() + Camera Position Z()
points(obj).x=psx
points(obj).z=psz
position_point_objects()
endif
endif
endfunction
function point_sections_to_next_one()
for l=1000 to maxSections
if object exist(l) and object exist(l+1)
point object l,object position x(l+1),object position y(l+1),object position z(l+1)
endif
next l
if joined=1
if object exist(maxSections) and object exist(1000)
point object maxSections,object position x(1000),object position y(1000),object position z(1000)
endif
endif
endfunction
function add_section_angles()
ink rgb(255,0,0),0
for l=1000 to maxSections
if object exist(l)
text object screen x(l),object screen y(l)+16,str$(int(trackData(l-999,5)))
text object screen x(l),object screen y(l)+36,str$(int(trackData(l-999,4)))
endif
next l
endfunction
function set_section_angles_and_positions()
for l=1000 to maxSections
if object exist(l)
trackData(l-999,1)=object position x(l)
trackData(l-999,2)=object position y(l)
trackData(l-999,3)=object position z(l)
trackData(l-999,4)=object angle y(l)
endif
next l
set_relative_section_angle()
endfunction
function set_relative_section_angle()
for l=1000 to maxSections
if object exist(l) and object exist(l+1)
ang1#=object angle y(l)
ang2#=object angle y(l+1)
turn#=ang2#-ang1#
if turn#>180.0 then turn#=turn#-360.0
if turn#<-180.0 then turn#=turn#+360.0
trackData(l-999,5)=turn#
if roll=1
if turn#>0.0 then roll object right l,turn#*roll_multiplyer
if turn#<0.0 then roll object left l,abs(turn#*roll_multiplyer)
endif
endif
next l
if joined=1
if object exist(maxSections) and object exist(1000)
ang1#=object angle y(maxSections)
ang2#=object angle y(1000)
turn#=ang2#-ang1#
if turn#>180.0 then turn#=turn#-360.0
if turn#<-180.0 then turn#=turn#+360.0
trackData(maxSections-999,5)=turn#
if roll=1
if turn#>0.0 then roll object right maxSections,turn#*roll_multiplyer
if turn#<0.0 then roll object left maxSections,abs(turn#*roll_multiplyer)
endif
endif
endif
endfunction
function check_for_loop_join()
if inkey$()="j" and joined=0
joined=1
endif
if inkey$()="u" and joined=1
for l=1000 to maxSections
if object exist(l) then delete object l
next l
joined=0
endif
endfunction
function MouseControl(Speed as float)
xrotate camera camera angle x()+mousemovey()
yrotate camera camera angle y()+mousemovex()
if mouseclick()=1 then move camera Speed
if mouseclick()=2 then move camera (0-Speed)
r=mousemovex()
r=mousemovey()
endfunction
function free_flight()
cls
text 0,0,"Building Track"
sync
if file exist ("track poly data.txt") then delete file "track poly data.txt"
open to write 1,"track poly data.txt"
ms#=maxSections-999
ns#=numSections
write float 1,ms#
write float 1,ns#
`wait for spacekey release
while spacekey()
endwhile
`delete editable track
for l=1 to numPoints
if object exist(l) then delete object l
next l
for l=1000 to maxSections
if object exist(l) then delete object l
next l
for x=1 to 6
`smooth track
for l=1000 to maxSections-1
tot#=trackData(l-999,5)
tot#=tot#+trackData(l+1-999,5)
trackData(l-999,5)=tot#/2.2
next l
if joined=1
tot#=trackData(maxSections-999,5)
tot#=tot#+trackData(1000-999,5)
trackData(maxSections-999,5)=tot#/2.2
endif
next x
`create new track objects here
for l=1000 to maxSections
make_straight_ahead_object(l)
position object l,trackData(l-999,1)*5,trackData(l-999,2)*5,trackData(l-999,3)*5
yrotate object l,trackData(l-999,4)
next l
`make mesh from object data
obj=10000
for l=1000 to maxSections-1
make_strip(obj,l,l+1)
texture object obj,1
inc obj
next l
make_strip(obj,maxSections,1000)
texture object obj,1
inc obj
`delete objects no longer needed
for l=1000 to maxSections
if object exist(l) then delete object l
next l
close file 1
set ambient light 30
hide light 0
make light 1
set spot light 1,20,90
set light range 1,500
`movement
l=1000
do
text 0,0,"fps"+str$(screen fps())
position camera trackData(l-999,1)*5,trackData(l-999,2)*5+15,trackData(l-999,3)*5
point camera trackData(l-998,1)*5,trackData(l-998,2)*5+15,trackData(l-998,3)*5
position light 1, trackData(l-999,1)*5,trackData(l-999,2)*5+25,trackData(l-999,3)*5
point light 1, trackData(l-990,1)*5,trackData(l-990,2)*5,trackData(l-990,3)*5
sync
if spacekey() then exit
inc l
if l>maxSections then l=1000
` mouseControl(5.0)
` sync
loop
delete light 1
show light 0
set ambient light 100
`wait for spacekey release
while spacekey()
endwhile
`delete non editable track
for l=1 to maxSections
if object exist(l) then delete object l
next l
for l=10000 to obj
if object exist(l) then delete object l
next l
`create editable track
create_point_objects()
position_point_objects()
maxSections=add_sections()
`reset camera to proper mode
if editMode=0
position camera 0,800,0
point camera 0,0,0
endif
if editMode=1
position camera 0,400,-400
point camera 0,0,0
endif
endfunction
function check_for_change_mode()
if inkey$()="h" and editMode=0
editMode=1
position camera 0,400,-400
point camera 0,0,0
endif
if inkey$()="p" and editMode=1
editMode=0
position camera 0,800,0
point camera 0,0,0
endif
endfunction
function check_for_camera_move()
if editMode=1
if leftkey()
spincameraaround(-5)
endif
if rightkey()
spincameraaround(5)
endif
if upkey() then move camera 1.0
if downkey() then move camera -1.0
endif
endfunction
function SpinCameraAround( Speed#)
angle# = wrapvalue(angle# + Speed#)
xPos# =cos(angle#) * 400
yPos# =400
zPos# =sin(angle#) * 400
position camera xPos#, yPos#, zPos#
point camera 0,0,0
endfunction
function adjust_height(s,e)
obj=0
if mouseclick()=1
obj=pick object (mousex(),mousey(),s,e)
while mouseclick()=1
if obj>0
inc points(obj).y
position_point_objects()
maxSections=add_sections()
sync
endif
endwhile
endif
if mouseclick()=2
obj=pick object (mousex(),mousey(),s,e)
while mouseclick()=2
if obj>0
dec points(obj).y
position_point_objects()
maxSections=add_sections()
sync
endif
endwhile
endif
endfunction
`function make_straight_ahead_object(obj)
` make object cube obj,1
` if object exist(50000) then delete object 50000
` make object cube 50000,1
` if mesh exist(1) then delete mesh 1
` make mesh from object 1,50000
`
` add limb obj,1,1
` offset limb obj,1,40,10,0
`
` add limb obj,2,1
` offset limb obj,2,-40,10,0
`
` add limb obj,3,1
` offset limb obj,3,70,30,0
`
` add limb obj,4,1
` offset limb obj,4,-70,30,0
`
` add limb obj,5,1
` offset limb obj,5,90,70,0
`
` add limb obj,6,1
` offset limb obj,6,-90,70,0
`
` if object exist(50000) then delete object 50000
` if mesh exist(1) then delete mesh 1
`
`endfunction
function make_straight_ahead_object(obj)
make object cube obj,1
if object exist(50000) then delete object 50000
make object cube 50000,1
if mesh exist(1) then delete mesh 1
make mesh from object 1,50000
add limb obj,1,1
offset limb obj,1,50,0,0
add limb obj,2,1
offset limb obj,2,-50,0,0
add limb obj,3,1
offset limb obj,3,100,0,0
add limb obj,4,1
offset limb obj,4,-100,0,0
add limb obj,5,1
offset limb obj,5,150,0,0
add limb obj,6,1
offset limb obj,6,-150,0,0
if object exist(50000) then delete object 50000
if mesh exist(1) then delete mesh 1
endfunction
function create_memblockobject(memnum,v)
make memblock memnum,12+(36*v)
write memblock dword memnum,0,338
write memblock dword memnum,4,36
write memblock dword memnum,8,v
endfunction
function create_vertex(memnum,v,vposx#,vposy#,vposz#,color as dword,u#,v#)
write memblock float memnum,v*36+12,vposx#
write memblock float memnum,v*36+16,vposy#
write memblock float memnum,v*36+20,vposz#
write memblock dword memnum,v*36+36,color
write memblock float memnum,v*36+40,u#
write memblock float memnum,v*36+44,v#
endfunction
function set_normal(memnum,v,normalx#,normaly#,normalz#)
write memblock float memnum,v*36+24,normalx#
write memblock float memnum,v*36+28,normaly#
write memblock float memnum,v*36+32,normalz#
endfunction
function make_strip(obj_num,t1,t2)
`write track angle
write float 1,trackData(t1-999,4)
`write the bend angle
write float 1,trackData(t1-999,5)
`write track center line
write float 1,trackData(t1-999,1)*5
write float 1,trackData(t1-999,2)*5
write float 1,trackData(t1-999,3)*5
`make a memblock big enough to hold the data
memblock_size=36
if memblock exist(1) then delete memblock 1
create_memblockobject(1,memblock_size)
posx1=limb position x(t1,6)
posy1=limb position y(t1,6)
posz1=limb position z(t1,6)
posx2=limb position x(t1,4)
posy2=limb position y(t1,4)
posz2=limb position z(t1,4)
posx3=limb position x(t1,2)
posy3=limb position y(t1,2)
posz3=limb position z(t1,2)
posx4=object position x(t1)
posy4=object position y(t1)
posz4=object position z(t1)
posx5=limb position x(t1,1)
posy5=limb position y(t1,1)
posz5=limb position z(t1,1)
posx6=limb position x(t1,3)
posy6=limb position y(t1,3)
posz6=limb position z(t1,3)
posx7=limb position x(t1,5)
posy7=limb position y(t1,5)
posz7=limb position z(t1,5)
posx8=limb position x(t2,6)
posy8=limb position y(t2,6)
posz8=limb position z(t2,6)
posx9=limb position x(t2,4)
posy9=limb position y(t2,4)
posz9=limb position z(t2,4)
posx10=limb position x(t2,2)
posy10=limb position y(t2,2)
posz10=limb position z(t2,2)
posx11=object position x(t2)
posy11=object position y(t2)
posz11=object position z(t2)
posx12=limb position x(t2,1)
posy12=limb position y(t2,1)
posz12=limb position z(t2,1)
posx13=limb position x(t2,3)
posy13=limb position y(t2,3)
posz13=limb position z(t2,3)
posx14=limb position x(t2,5)
posy14=limb position y(t2,5)
posz14=limb position z(t2,5)
u#=1.0/6.0
v_num=0
create_vertex(1,v_num,posx8,posy8,posz8,rgb(255,255,255),0,0)
write float 1,posx8:write float 1,posy8:write float 1,posz8
inc v_num
create_vertex(1,v_num,posx2,posy2,posz2,rgb(255,255,255),u#*1,1)
write float 1,posx2:write float 1,posy2:write float 1,posz2
inc v_num
create_vertex(1,v_num,posx1,posy1,posz1,rgb(255,255,255),0,1)
write float 1,posx1:write float 1,posy1:write float 1,posz1
inc v_num
create_vertex(1,v_num,posx8,posy8,posz8,rgb(255,255,255),0,0)
write float 1,posx8:write float 1,posy8:write float 1,posz8
inc v_num
create_vertex(1,v_num,posx9,posy9,posz9,rgb(255,255,255),u#*1,0)
write float 1,posx9:write float 1,posy9:write float 1,posz9
inc v_num
create_vertex(1,v_num,posx2,posy2,posz2,rgb(255,255,255),u#*1,1)
write float 1,posx2:write float 1,posy2:write float 1,posz2
inc v_num
create_vertex(1,v_num,posx9,posy9,posz9,rgb(255,255,255),u#*1,0)
write float 1,posx9:write float 1,posy9:write float 1,posz9
inc v_num
create_vertex(1,v_num,posx3,posy3,posz3,rgb(255,255,255),u#*2,1)
write float 1,posx3:write float 1,posy3:write float 1,posz3
inc v_num
create_vertex(1,v_num,posx2,posy2,posz2,rgb(255,255,255),u#*1,1)
write float 1,posx2:write float 1,posy2:write float 1,posz2
inc v_num
create_vertex(1,v_num,posx9,posy9,posz9,rgb(255,255,255),u#*1,0)
write float 1,posx9:write float 1,posy9:write float 1,posz9
inc v_num
create_vertex(1,v_num,posx10,posy10,posz10,rgb(255,255,255),u#*2,0)
write float 1,posx10:write float 1,posy10:write float 1,posz10
inc v_num
create_vertex(1,v_num,posx3,posy3,posz3,rgb(255,255,255),u#*2,1)
write float 1,posx3:write float 1,posy3:write float 1,posz3
inc v_num
create_vertex(1,v_num,posx10,posy10,posz10,rgb(255,255,255),u#*2,0)
write float 1,posx10:write float 1,posy10:write float 1,posz10
inc v_num
create_vertex(1,v_num,posx4,posy4,posz4,rgb(255,255,255),u#*3,1)
write float 1,posx4:write float 1,posy4:write float 1,posz4
inc v_num
create_vertex(1,v_num,posx3,posy3,posz3,rgb(255,255,255),u#*2,1)
write float 1,posx3:write float 1,posy3:write float 1,posz3
inc v_num
create_vertex(1,v_num,posx10,posy10,posz10,rgb(255,255,255),u#*2,0)
write float 1,posx10:write float 1,posy10:write float 1,posz10
inc v_num
create_vertex(1,v_num,posx11,posy11,posz11,rgb(255,255,255),u#*3,0)
write float 1,posx11:write float 1,posy11:write float 1,posz11
inc v_num
create_vertex(1,v_num,posx4,posy4,posz4,rgb(255,255,255),u#*3,1)
write float 1,posx4:write float 1,posy4:write float 1,posz4
inc v_num
create_vertex(1,v_num,posx11,posy11,posz11,rgb(255,255,255),u#*3,0)
write float 1,posx11:write float 1,posy11:write float 1,posz11
inc v_num
create_vertex(1,v_num,posx5,posy5,posz5,rgb(255,255,255),u#*4,1)
write float 1,posx5:write float 1,posy5:write float 1,posz5
inc v_num
create_vertex(1,v_num,posx4,posy4,posz4,rgb(255,255,255),u#*3,1)
write float 1,posx4:write float 1,posy4:write float 1,posz4
inc v_num
create_vertex(1,v_num,posx11,posy11,posz11,rgb(255,255,255),u#*3,0)
write float 1,posx11:write float 1,posy11:write float 1,posz11
inc v_num
create_vertex(1,v_num,posx12,posy12,posz12,rgb(255,255,255),u#*4,0)
write float 1,posx12:write float 1,posy12:write float 1,posz12
inc v_num
create_vertex(1,v_num,posx5,posy5,posz5,rgb(255,255,255),u#*4,1)
write float 1,posx5:write float 1,posy5:write float 1,posz5
inc v_num
create_vertex(1,v_num,posx12,posy12,posz12,rgb(255,255,255),u#*4,0)
write float 1,posx12:write float 1,posy12:write float 1,posz12
inc v_num
create_vertex(1,v_num,posx6,posy6,posz6,rgb(255,255,255),u#*5,1)
write float 1,posx6:write float 1,posy6:write float 1,posz6
inc v_num
create_vertex(1,v_num,posx5,posy5,posz5,rgb(255,255,255),u#*4,1)
write float 1,posx5:write float 1,posy5:write float 1,posz5
inc v_num
create_vertex(1,v_num,posx12,posy12,posz12,rgb(255,255,255),u#*4,0)
write float 1,posx12:write float 1,posy12:write float 1,posz12
inc v_num
create_vertex(1,v_num,posx13,posy13,posz13,rgb(255,255,255),u#*5,0)
write float 1,posx13:write float 1,posy13:write float 1,posz13
inc v_num
create_vertex(1,v_num,posx6,posy6,posz6,rgb(255,255,255),u#*5,1)
write float 1,posx6:write float 1,posy6:write float 1,posz6
inc v_num
create_vertex(1,v_num,posx13,posy13,posz13,rgb(255,255,255),u#*5,0)
write float 1,posx13:write float 1,posy13:write float 1,posz13
inc v_num
create_vertex(1,v_num,posx7,posy7,posz7,rgb(255,255,255),u#*6,1)
write float 1,posx7:write float 1,posy7:write float 1,posz7
inc v_num
create_vertex(1,v_num,posx6,posy6,posz6,rgb(255,255,255),u#*5,1)
write float 1,posx6:write float 1,posy6:write float 1,posz6
inc v_num
create_vertex(1,v_num,posx13,posy13,posz13,rgb(255,255,255),u#*5,0)
write float 1,posx13:write float 1,posy13:write float 1,posz13
inc v_num
create_vertex(1,v_num,posx14,posy14,posz14,rgb(255,255,255),u#*6,0)
write float 1,posx14:write float 1,posy14:write float 1,posz14
inc v_num
create_vertex(1,v_num,posx7,posy7,posz7,rgb(255,255,255),u#*6,1)
write float 1,posx7:write float 1,posy7:write float 1,posz7
inc v_num
make mesh from memblock 1,1
make object obj_num,1,0
set object texture obj_num,2,0
set object normals obj_num
endfunction
function make_track_images()
ink rgb(50,50,50),0
box 0,0,256,256
for l=1 to 60000
col=rnd(50)+100
dot rnd(256),rnd(256),rgb(col,col,col)
next l
ink rgb(255,0,0),0
box 0,0,10,128
ink rgb(255,255,255),0
box 0,128,10,256
ink rgb(255,255,255),0
box 246,0,256,128
ink rgb(255,0,0),0
box 246,128,256,256
get image 1,0,0,256,256
ink rgb(200,200,200),0
box 0,0,256,256
ink rgb(190,190,190),0
box 1,1,255,255
ink rgb(180,180,180),0
box 2,2,254,254
ink rgb(50,50,50),0
box 3,3,253,253
for l=1 to 60000
col=rnd(50)+100
dot rnd(250)+3,rnd(250)+3,rgb(col,col,col)
next l
get image 2,0,0,256,256
endfunction
function save_data()
cls
sync
text 0,0,"Saving Track Data To Text File Ready To Cut And Paste"
sync
for l= 1 to 1000000
next l
if file exist("track data.txt") then delete file "track data.txt"
open to write 1,"track data.txt"
write string 1,"data "+str$(numPoints)+"`number of points"
write string 1,"data "+str$(joined)+"`joined"
for l=1 to numPoints
write string 1,"data "+str$(points(l).x)+","+str$(points(l).y)+","+str$(points(l).z)
next l
close file 1
endfunction
function use_test_track_data()
cls
sync
text 0,0,"Loading Test Track Data"
sync
for l=1 to 1000000
next l
restore track_data
read numPoints
read joined
for l= 1 to numPoints
read points(l).x
read points(l).y
read points(l).z
next l
for l= 1 to maxPoints
if object exist(l) then delete object l
next l
for l= 1000 to numSections*maxPoints
if object exist(l) then delete object l
next l
`create editable track
create_point_objects()
position_point_objects()
maxSections=add_sections()
`reset camera to proper mode
if editMode=0
position camera 0,800,0
point camera 0,0,0
endif
if editMode=1
position camera 0,400,-400
point camera 0,0,0
endif
endfunction
track_data:
`data 35`number of points
`data 1`joined
`data -130,0,0
`data -60,-26,0
`data 10,-32,0
`data 80,0,0
`data 172,4,41
`data 164,16,128
`data 106,16,165
`data 61,0,146
`data 29,0,85
`data -40,0,59
`data -141,0,95
`data -138,0,167
`data -76,0,224
`data 1,0,236
`data 102,0,227
`data 179,0,201
`data 229,27,162
`data 265,0,82
`data 272,21,-20
`data 241,0,-93
`data 161,28,-178
`data 108,0,-217
`data -2,27,-259
`data -91,0,-226
`data -82,-25,-164
`data 38,0,-173
`data 69,0,-97
`data 32,0,-49
`data -68,0,-68
`data -151,0,-126
`data -206,0,-176
`data -288,37,-129
`data -322,29,5
`data -260,0,75
`data -211,0,34
data 27`number of points
data 1`joined
data -185,25,27
data -64,17,-19
data 81,19,14
data 221,25,-33
data 363,25,13
data 380,25,141
data 242,25,210
data 94,25,175
data -64,25,153
data -167,40,266
data -87,45,388
data 76,25,385
data 255,33,337
data 401,50,258
data 489,25,123
data 486,25,-37
data 435,16,-184
data 294,25,-255
data 192,33,-372
data 41,34,-360
data -123,18,-235
data -297,25,-186
data -465,33,-197
data -544,40,-93
data -520,38,70
data -405,31,153
data -266,18,138
