Archive for November, 2009

Track Creation 104 – Grades and Cambers

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.

November 10, 2009 at 8:16 am Leave a comment

Track Creation 103 – Trackeditor

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.

November 6, 2009 at 1:55 pm Leave a comment


Categories

Archives