Bending of track in a racing game
- by caius
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.