Posts filed under ‘Tutorials’
As I said previously, the trackeditor does not (yet) support grades or cambers in tracks, so every track created in the editor will be absolutely flat. Unless its an airport track, flat is both unrealistic and boring – you need some height and camber changes to spice things up and give your track character. This is especially the case if you want to make a rally track with lots of jumps and bumps, but equally true of smooth fast tracks like Forza, where the slopes are more subtle but present nonetheless.
Ok, so now its time to get to grips with the track’s XML, which I presume you have open in vim your favourite editor.
If you look closely you’ll see two lines appearing in each and every segment:-
<attnum name=”z start” unit=”m” val=”0.0″ />
<attnum name=”z end” unit=”m” val=”0.0″ />
Now there’s two ways of determining height changes in a SD track. One is to specifically set the height (the “z” value) for the start and end of each segment. The other is to use a gradient percentage. I prefer the latter, as its much easier to define a constant slope across multiple segments, so I’ll describe that method here.
First thing you need to do is remove all of the above lines, except for the “z start” on the first segment and the “z end” on the last. This ensures that those segments will meet properly, and your cars won’t be jumping off a cliff or running into a wall when they cross the start-finish line.
Next, let me introduce you to the two lines that go in their place:-
<attnum name=”grade” unit=”%” val=”0″/>
<attnum name=”profil end tangent” unit=”%” val=”0″/>
The “grade” value is the gradient of the segment, and the “profil end tangent” specifies the expected slope on the next segment, ensuring a smooth transition with minimal bumps. I usually keep the two values the same except for when there’s a significant change in gradient from one segment to the next, in which case I make the end tangent approximately halfway between the two segments’ gradient values.
Work your way through the XML adding gradients – it may help to still keep the trackeditor open so you can click on segments & see what their names are. Just don’t use the trackeditor to save anything, as you’ll lose all your gradients and cambers. Once you’re done, run trackgen to create the 3D model, then open the track’s .ac file in your favourite 3D editor. I should say at this point that I’m an avid AC3D user – I’ve never gotten the hang of Blender, so if you’re looking for advice on how to use it you’ll need to ask someone else. Anyway, once you’ve gotten the track open in your 3D editor, look at the part leading up to the start/finish line. The following screenshots show what I mean.
Now you can look at the track’s camber. Generally you want straight sections to be flat, and the camber to provide a nice bank on the corners that helps you take them at speed. If you’re making a Nascar-style oval where you turn left for hours on end, the whole track will have a fairly steep camber. Perhaps though you might have a cruel streak, and want to punish careless drivers with off-camber sweepers, sloping down towards the outside of the bend and sending cars into the dirt *cough*Brondehach*cough*. Anyway, here’s how you define the camber for each segment:-
<attnum name=”banking start” unit=”deg” val=”0″ />
<attnum name=”banking end” unit=”deg” val=”0″ />
Unless you’re making an off-camber corner, a left turn will want a negative value and a right turn, positive. Make absolutely sure that the end camber of one segment matches the start camber of the next, otherwise you’ll have unsightly gaps in your track. Also try to avoid making large camber changes across short segments, as they’ll translate into dangerous bumps (unless, of course, you’re trying to create dangerous bumps!).
Once you’re done, you have a very important task remaining before you can start making the track look good. You must test drive again. And again. Using both robots and driving yourself. Look closely for any parts of the track that don’t feel right, that aren’t fun to drive in the way you’ve envisaged. If changes in slope and camber don’t feel right, now is the time to change them until they’re perfect. Don’t skip over this, because it’ll be too late to implement fixes once you’ve spent days & weeks adding trackside objects and customising the trackside terrain.
Much of how this program works is quite simple and straightforward, so I’d rather not waste time repeating the obvious. Instead I’ll look at the basic idea behind this tool, what it can do and (as of the latest version) what it can’t, and look at a few quirks that will help you get the most out of it.
As I touched on in the previous post, Speed Dreams reads XML files that describe the layout of each track. The radius and arc of each corner, the length of each straight, the location of the pits, the surface properties of the track, track borders, side runoffs and fences/walls – all are detailed in the XML.
The aim of the trackeditor is to give you a visual method of creating this XML. Using it you can create a new track, define basic properties such as the width of the track, the pit side, location, entry and exit. Clicking on one of the three green arrow buttons (straight, right turn, left turn) lets you add segments. The Segment Editor popup dialog lets you adjust the length (if a straight), or the arc, start radius and end radius (for corners) of each segment. As you move the sliders you see the segments change in the main window, which is very cool. You can also edit the width and surface of the borders, runoffs (“Side”) and fences (“Barrier”) for each side of the track. With your background image loaded you can easily create a track that closely maps your design.
So, what are the limitations? Well, firstly, trackeditor assumes the “profil steps length” is always 4, no matter what value appears in the XML. This value is used to determine how long each of the little mini-segments are that comprise a track segment. The default value, 4, means each will be 4m long, which gives you a nice smooth track. It also creates a lot of surfaces that may not be that necessary and will result in the track taking a long time to load. If you change the default value in the XML the alignment of the track will slightly change, causing the end & start segments to no longer line up. Unfortunately the trackeditor won’t show you when this has happened. You can also change the profil steps length for individual segments, but again trackeditor doesn’t know when you’ve done it and won’t show you any changes.
What else? Ah yes, it has no support for segment elevation, as it explicitly sets every segment’s z heights to zero (ignoring what’s in the XML) and doesn’t save changes you might make in the editor. Neither does it know about the “grade” value. Track camber? No, not supported. I’ll look at all of these in the next post, as you’ll need to edit them directly in the XML itself.
What I suggest you do is, create a basic track using the trackeditor from start to finish, getting the end of the last segment as closely aligned to the start of the first segment as possible. Hit the save button, then open the XML file in a text editor of your choice. You’ll see a couple of things right away. Firstly it has a “Main Track” section that gives default values for each segment. Then the segments are listed, each with their own list of values.
Here’s where the trackeditor, unfortunately, gets really annoying. By default it sets every track border to “curb-5cm-r” with a style of “plan” and a height of “0.05”. Do you really want raised curbs bordering the track along its entire length? No, didn’t think so. Do you necessarily want them to be 0.05 in height? Maybe, maybe not. Now you could use the trackeditor and go along changing each segment, but ugh, the pain!. What I’d suggest you do instead is use a Find & Replace to change “0.05” to “0.0”, and “curb-5cm-l” to “tar-grass3-r”. You can add curbs back in later where you need them.
What else is there? Oh yes, the barriers. For some reason it saves them as style “curb”, which is just plain wrong, with a width of 0.1. These will be double-sided fences with weird texture mapping. Fences should either be of type “fence”, which is a single row of polygons using one third the resources of the default curb-style barriers, or “wall”, which will give you a nice 2 sides & a top shape that is easy to map to a texture. Wall is necessary for things like concrete and tyre barriers, while fence is fine for armco railings and wire or wood fences. Feel free to globally substitute “0.1” for “0.0” and “curb” for “fence”.
Now, reopen the file back in trackeditor, and click on the segments where you want, say, curbs instead of a flat tar-grass transition. Change the border surface to curb-5cm-r and, if you want a height > 0, its style to “curb” as well. Follow this procedure for areas where you want sand runoffs instead of grass, or tirewalls (which will need a width value of at least 1.0 and a style of “wall”) instead of fences.
Once you’ve finished that, you’ve pretty much done with the trackeditor – everything else needs to be done by editing the XML, and then the 3D model itself. Note that you can use trackeditor to create the 3D model, but that won’t work once you’ve started adding heights, grades and cambers in the XML. You’re better off opening a command prompt in the speed-dreams directory and running trackgen from there.
After you’ve run trackgen, fire up Speed Dreams and test drive. You want to be 100% happy with the layout, bearing in mind it has no camber/slope changes yet, before you go any further, as it’ll be terribly painful coming back later trying to fix something you should have taken care of now.
Let me conclude by saying that work is underway to write an improved track editor, but I don’t know how far away it is or what features it will have.
Obviously before you can start you want to have an idea of what your track will look like. Yes, this means you should have a feel for the general look and feel of the track and its surroundings – what country is it in, what season, is it mountainous or flat, rural, forest or built up etc etc. You may even have collected or created some textures already. Its definitely good to have an idea of what direction you’d like to go in this regard before you begin, but its not essential. I’ve found that in reworking old tracks I can study the nature of the track and from that derive an idea of what setting would work best later.
So … what comes first is the actual layout of the track. Its straights, its fast sweepers, its tight chicane or challenging S bends. Where the pits are, where the start/finish line is (doesn’t have to be the same place). Some people are really good at inventing tracks like this – I’m not one of them. Eric Espie is/was a genius. To design a layout, I guess you’d make a sketch of the idea, scan it (if its an old-school pencil sketch) and then use it as a background in the trackeditor. Other people like modelling real-world tracks, assembling Google World screenshots for maximum accuracy. Whatever works for you – what you need is an image, to scale, of the track you want to create from directly overhead.
I’ll talk a bit more about trackeditor in the next post, but one feature that’s not immediately obvious, and really essential, is how to use the background image. Here’s how you go about it:-
1. File Menu -> Properties. Select the Image tab. Choose the file you want, and the scale factor (you can change this later if its wrong).
2. The World-with-binoculars button shown in the screenshot below. It toggles displaying of the background image.
3. Right-click and drag to position the image relative to the track – you’ll have the very first segment of track visible if its a brand new track.
With the image in place you can create track segments to match the curves of the track you’ve designed.
I should take a quick moment to explain something here. Many racing sims use the 3D model itself to determine where the drivable surfaces are, their slopes and so on. Speed Dreams does not. It defines the layout of the track in its entirety in an XML file that the trackeditor creates. This XML file is then used to generate a 3D model that you can later enhance, but the 3D model is nothing more than eye candy. The game itself only goes off the XML file to work out where cars can drive, the friction, slope and camber of surfaces and so on. You could delete everything in the 3D model and Speed Dreams will still work, showing a car driving suspended in mid-air.
The trackeditor’s job is to make it easy to create this XML file and setup its basic values – what the segments are, the width and texture of side runoffs, where curbs start and finish, and the fences/walls on the edges. The trackeditor has its limits though. It only takes you so far, and then you’ll have to edit the XML directly. I’ll get to all that in the next few posts.
So you’d like to make a TORCS Speed Dreams track? You love the game (and lets be honest, who wouldn’t?) and you’d like to hurl a 1936 Alfa Milano 12c around your favourite race track, which for some strange reasons isn’t already part of the game. Perhaps you’d like to host your tracks on your own website for Speed Dreams enthusiasts to download, or even better, you envisage your creations becoming part of the game itself.
You just don’t know how to go about it. I mean, anyone can use the included track editor to define a circuit, but how do you include hills and valleys in the track? Most importantly, how do you transform the bland, character-less cookie-cutter tracks it creates into the work of art you envisage in your mind? How do you change trackside terrain, improve its textures, and include trackside objects? How do you add shadows for that extra touch of realism?
Over the last few years I’ve made a lot of tracks (street-1, wheel-2, ruudskogen, dirt-3, forza, brondehach, reworks of e-track-6, alpine-2 and corkscrew) for TORCS and now Speed Dreams, and thought it was time to share some of the hard-won knowledge I’ve gained during the process, hence this, the first in a series of tutorials on creating tracks for the game.
First, let me be blunt. Making Speed Dreams track is a ton of work. It usually takes me about 2 to 3 months from start to finish, spending about 10 hours a week before I finish a track. That’s 80 to 120 hours or so, not for the faint hearted. Usually once I complete a track I’m exhausted & unable to bear the thought of starting another one, which is why I only create one or two a year max.
So … you’re still here? Still want to give it a go? Ok then. The first thing you need to do is write a todo list. That way you have a plan of attack, and know what needs to be done to bring your idea to fruition. It also gives me a list of things to post about in this tutorial 🙂
It so happens that I’ve just started a major rework of the old TORCS track, e-track-4, for inclusion in Speed Dreams. Ok, its not a new from-scratch track, but as I’ve changed the layout somewhat its pretty close to being one. As I go through each step in the process I’ll use it as an example in this series of tutorials. So, here’s my todo list for this project – yours should look something similar.
- Design the circuit layout, including an idea of elevation changes and allowing at least 240m of a straight for pits (16 pits of 15 meters in length) with enough length for pit entry and exit.
- Create the circuit using the trackeditor tool.
- Define changes of elevation in the XML.
- Test drive until 100% satisfied with the track.
- Trackside terrain
- Trackside objects
- Naming of textures.
- Editing the 3D model..
- Editng textures.
- Materials and surface settings
- Creating a shadow map
- Applying the shadow map
- Adding a “raceline”.
My next post will look at steps 1 and 2. If you’re working on tracks yourself and have any questions or would like to share some of the tips and tricks you’ve discovered, please add a comment or two!