# Generating a track for a racing game

This topic is 3758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I want to be able to randomly generate a stripe-like track that runs through a 3d environment. The stripe is to bend and twist and joined together in both ends. Something like this: The racing car is to run on the track and it only moves in the direction along the track. Any ideas on how to do this?

##### Share on other sites
On Benjamin Nitschke book (Professional XNA Game Programming: For Xbox 360 and Windows) you have a very good example on how to fow it. You can grab the source here: http://creators.xna.com/

##### Share on other sites
Quote:
 Original post by Ivo LeitaoOn Benjamin Nitschke book (Professional XNA Game Programming: For Xbox 360 and Windows) you have a very good example on how to fow it. You can grab the source here: http://creators.xna.com/

Thanks alot.

##### Share on other sites
The XNA Racing Game Starter Kit uses Catmull-Rom Splines to represent the track. Info about the technique is available here. When the track is generated a normal and direction vector is calculated for each point. The normal can be tweaked to make the track twist and bend.

##### Share on other sites
You could use a parametric representation, with a single parameter t giving a 3D closed curve plus the orientation of the track normal (only one additional degree of freedom) and possibly the width of the track.
It would be easy to randomize (self-intersections can be ignored and you only need to worry about excessive curvature) and easy to draw (just build triangle strips or the like from evaluations for increasing and decreasing t around the camera target, stopping when the next slice of geometry is out of view).

##### Share on other sites
Quote:
 Original post by LorenzoGattiYou could use a parametric representation, with a single parameter t giving a 3D closed curve plus the orientation of the track normal (only one additional degree of freedom) and possibly the width of the track.It would be easy to randomize (self-intersections can be ignored and you only need to worry about excessive curvature) and easy to draw (just build triangle strips or the like from evaluations for increasing and decreasing t around the camera target, stopping when the next slice of geometry is out of view).

Sounds interesting. Not sure how to generate a parametric representation for a track though.

##### Share on other sites
Couldn't you just write a tile map maker and have it randomly place tiles. each tile being a piece of the track. of course you would have to add functions and variables to make sure there are no dead ends and everything fits together right. If you want email me at moha82@juno.com and ill send you a pretty easy to understand tile map generator i made a while back.

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999981
×