So as some of you guys may know I created a spline track a while ago use in the racing game FUR. Now I created a new version and so far it’s working because we switched programming language and I was not happy with FUR. Now FUR is working, yes, but still has lack of content and gameplay features, it has a crappy menu, only useful in an arcade cabinet and you need to close it with Alt-F4. Al with all: not finished.
Anyway I will explain a bit on how I implemented my spline track. At first I define the points the track needs to travel trough. For example we have 4 points, creating a round track, 2 red, 2 blue. The red is where we will draw the curved road (green arrow). First I define 2 imaginary points named p1 and p2. From red point 1 we interpolate to p1 and call this result A, from p2 we interpolate to red point 2 and call this result B. Now the final part: interpolate between A and B and you have your curved points.
Vector3 A = Vector3.Lerp(Red1, p1, t); Vector3 B = Vector3.Lerp(p2, Red2, t); Vector3 result = Vector3.Lerp(A, B, t); PointList.Add(result); // add result to some kind of list
Now we have the curved points, we can determine the direction simply by current point – next point, normalize this and extrude it with triangles which is a fairly simple process as you already have the direction. For further use it’s also very easy to implement a banked curve simply by linear interpolating the bank for each point. This way it’s very easy to create a spline based road or race track. Procedural for the win!!
ps. Hometown GP which is nowhere to be found anymore also has a similar track system.