Bending of track in a racing game

I am trying to create a small racing game in which the track would be modeled using a BSpline curve for the path's center line and directional vectors to define the 'bending' of the track at each point.

My problem is that I don't know how to calculate the correct bending / slope of the curve, in such a way that it would be optimal or at least visually nice for a car to 'bend in the corner'.

My idea was to use the direction of the 2nd derivatives of the curve, however while this approach looks fine for most of the track, there are points in which the 2nd derivative makes sharp 'twists' / very quick 180 degree flips. I also read about 'knots' of bsplines, but I don't know if such 'twist' in 2nd derivatives is a knot or knots are something else.

Can you tell me that using a BSpline: 1. How could I calculate a visually nice bending of a track for a racing game? 2. Is it possible to do this by using some simple calculations of centripertal force / gravity? 3. Is it possible to do this by using 1st, 2nd and 3rd derivatives of the BSpline curve?

I am not looking for the 'physically correct' bending angle for the track, I would just like to create something which is visually pleasing in a simple game.

I am using a framework which has a built-in class for BSpline, including support for 1st, 2nd and 3rd derivatives of the curve.

-
I don't quite understand what your desired result is. I think you are talking about the path of a car following the track, not rendering the track itself; is that right? Are you trying to simulate the ideal racing line? Or if something else, maybe you could post a diagram with an example of the desired path vs what you're getting now? –  Nathan Reed Sep 12 at 23:11
@Nathan: I read this more as a request for help determining the ideal camber (see en.wikipedia.org/wiki/Cant_(road/rail)) of the road surface. –  Mac Sep 12 at 23:51
@caius: I agree with Natan. You should elaborate a little more. Is your problem to find the best track curve for a given car angular velocity? –  dsilva.vinicius Sep 14 at 14:24
Thanks for answering, and @Mac you're right, I was looking for that Cant. I have realized that the quirks at a certain point are due to cubic splines being only approximations. I finally solved it by manually filtering the discrete points. –  caius Sep 17 at 15:15
add comment

1 Answer

Consider this generated line to be the direction of your track: http://m2matlabdb.ma.tum.de/example.jpg?MP_ID=485

You could have your horizontal 'balance' line to be adjusted by the curvature of the line itself (consider you can find the red dots position like in the example i provided). Each red dot would higher the horizon line on the side it lives depending on its distance with the curve. (The challenge is to find the equivalent of the red dots. Maybe some visual representation of its derivatives can help.)

To have this basic principle working, you could calculate those horizon lines at each dot and make any kind of blending method between them (linear[not], cosine, quadratic, w/e).

Its a basic idea but i hope it will help.

-
add comment