Track editor help required

Blitz3D Forums/Blitz3D Programming/Track editor help required

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Something like this should help - not tested I'm afraid but used this method to create my own tracks ...

Assuming your points are held in an array ..
pointx(2,nopoints), pointz(2,nopoints)

Where pointx(1,..) and pointz(1,..) hold the x & z position of your initial track points.



for a=0 to nopoints-1

;get next point
b=(a+1) mod nopoints

;get vector from point a to point b
dx#=pointx(1,b)-pointx(1,a)
dz#=pointz(1,b)-pointz(1,a)
d#=sqr( dx*dx+dz*dz)

;normalise vector
dx=dx/d:dz=dz/d

;get points perpendicular to point a

;point to left
pointx(0,a)=pointx(1,a)-dz*trackwidth
pointz(0,a)=pointz(1,a)+dx*trackwidth

;point to right
pointx(2,a)=pointx(1,a)+dz*trackwidth
pointz(2,a)=pointz(1,a)-dx*trackwidth

next



Once you have this you can then build the track mesh from the new perpendicular points like this ..



mesh=createmesh():s=createsurface(mesh)

for a=0 to nopoints-1
;get next point
b=(a+1) mod nopoints
;add the 4 points to the mesh
v0 = addvertex (s,pointx(0,a),0,pointz(0,a))
v1 = addvertex (s,pointx(0,b),0,pointz(0,b))
v2 = addvertex (s,pointx(2,b),0,pointz(2,b))
v3 = addvertex (s,pointx(2,a),0,pointz(2,a))
addtriangle s,v0,v1,v2
addtriangle s,v2,v3,v0
next

...............