How to design race game track data

Started by
4 comments, last by Stainless 10 years, 1 month ago

I am big fan for race game. Now I try to build a 3d race game by myself.

I know a little about scene graph principle. But I just do not know how to design the track data? And how to organize these data in OpenGL?

Any ideas? Thanks.

Advertisement

Typically the process is that the track surface is modeled and textured in a 3d modeling package and saved to a common 3d file format. The 3d file format is then processed and the data is loaded into your game. The whole loading the 3d model data aspect is where layers above OpenGL can come in handy. The Open Asset Import Library should be able to help you though: http://assimp.sourceforge.net/

Other elements of the track can also be modeled such as tires and billboards. In some games a 3d level editor is used/created for the purpose of placing the 3d assets in a level. One example is Leadwerks http://www.leadwerks.com/werkspace/page/editor?showbanner=0

In this case you would have a "level" file that would control the position, orientation, and scale of various 3d models as well as other level properties.

For the track itself: A long time ago, I generated mesh (triangle) data from specifications for NASCAR racetracks. There used to be really precise dimensions, banking degrees, etc., but I can't find them now. This link is similar to what I used. I really liked using data from actual tracks.

Anyway, from the charts I made up a simple general spec for a track -

straightaway: ## of feet;

turn: elevation 13 degrees, radius, arc;

straightaway ## of feet;

turn elevation...

.. and so on.

I wrote a program to take those specs and generate mesh data based on a "track slice."

trackslice.png

One function generated a slice with input data such as x,y,z for inner left corner, turn radius, width, super-elevation angle, etc. I just "stitched" those together, and dumped the data to a file for loading. The loader read the file and generated a VBO for the track.

I was also using ODE (physics/collision engine) at the time and used the same data to create planes* for the collision engine. The first car I tried consisted of just a box and 4 spheres for tires, with something similar for the graphics car. Eventually I added suspension and steering, etc. You can make the suspension physics as simple or complex as you like. Designing the graphics for a car mesh is pretty satisfying, also.

*That pretty much sucked as the seams between slices caused bumps in the collision engine for some reason. So I eventually set up an algorithm to calculate tire elevation using the track specs.

I "stole" an engine sound from somewhere and that made the experience a lot better. Eventually I set the sound up to increase in frequency based on gear and accelerator position.

In any case, if you love racing, you're off on a really fun adventure!

EDIT: spelling and grammar corrections. Should not post after 1AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I worked on a race game a long time ago. The track and scenary was modelled in 3ds Max and exported as a custom mesh format. Then also in 3ds Max we created the Race lines and overtaking lines which are used by the AI cars.

These were just invisible objects that were spaced along the length of the track that contained information such as the optimal speed that an AI car should be at that particular node. We exported them seperatly using a max script and then they wee read into the engine and used by the AI.

There are some open source racing games about. Look at http://www.speed-dreams.org/

All of the ones I have looked at have two sets of data.

The track is defined as a bunch of meshes so you can view frustrum cull as many as possible

For the physics you usually have a seperate file. The most common format I have come across defines the track as left , right turns ans straight.

So you would have something like


typedef struct Left
{
       float angle;   // number of degrees the turn passes through
       float length;  // length of the arc
       float bank;    // bank angle
       float pitch;    // height change
};

You use a track editor to match the course to the 3D mesh

Actually I had a quick look

Speed dreams seems to use a bicubic patch for each track segment. They store 16 edge points for each track segment and interpolate between the points for the physics system.

This topic is closed to new replies.

Advertisement