Jump to content

View more

Image of the Day

The beast has a mighty searchlight of evil! #screenshotsaturday https://t.co/bzKepOojDL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

How to design race game track data

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 FanLemon   Members   


Posted 18 March 2014 - 08:00 PM

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.

#2 shadowisadog   Members   


Posted 18 March 2014 - 10:11 PM

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.

#3 Buckeye   GDNet+   


Posted 19 March 2014 - 12:44 AM

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."



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.

Edited by Buckeye, 19 March 2014 - 07:28 AM.

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.

#4 Buster2000   Members   


Posted 19 March 2014 - 02:53 AM

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.

#5 Stainless   Members   


Posted 19 March 2014 - 03:09 AM

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

#6 Stainless   Members   


Posted 19 March 2014 - 03:19 AM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.