Register Forgot Password
You may login to remove the ads!

Author Topic: Lofting Tutorial  (Read 5223 times)

Nuno Lourenço

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Lofting Tutorial
« on: November 25, 2014, 11:55:55 am »
Lofting Tutorial

This method uses a combination of a path and cross section splines to extrude a track surface. It's the classic way to model a track and has been used for years to model simple low poly tracks, but it's capable of much more if used correctly. Lofting is great for roughing out a new layout quickly and gives quick results. It's a good technique for beginners, but requires ALOT of post-lofting poly editing and UVW coordinate mapping to really flesh out a design.

I’ve been made tracks using lofts for years and it’s a versatile track making method My signature track, Lime Rock Park, was made originally from lofts; from the track surface and curbs, to the hills, it was all made easier and more organic looking with the shapes and lines that were used.

This is an old school technique, but it’s still useful for several reasons;

1) Its completely done in-3D Max, so you don’t need to export from a 3rd party program;

2) You get quick results. Literally within minutes you can have a road surface to drive on.

3) Testing new ideas and layouts is easy due to the quick turn around and spline based modeling.

1) Setting up the scene

In this section we will be setting up the scale and map.

To start your track, get your units set to generic units (one generic unit = 1 meter) Getting the scale correct is pretty much a lot of guesswork unless you know for a fact that, say, the front straight is exactly 1200m long. Get a good map of the track that is to the correct scale and then set it as a diffuse map on a material. Create a flat plane roughly the size of the track (top view, obviously). It will be used as a template for tracing the tracks path. Assign the track map material to the plane and lower it 10 meters down so it’ll be out of the way of your work.

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/1.jpg
Lofting Tutorial


UV map the plane using the “fit” and “bitmap fit” functions to get it mapped proportionally correct to the plane. Then you can uniform scale it to whatever size you need, without worrying about messing up proportions.

2) Making the Path

This object is made by tracing a line around the track layout.

Start creating a standard line (spline) and set the vertex type to "smooth". It doesn't matter where on the track you start from, it doesn't make any difference if it's the start/finish line or not. Draw the line down the centre of the pavement. Click to create a vertex only when necessary, create the minimum number of vertices you can get away with. Since all the vertices will be of type "smooth" you'll notice the line will sometimes bulge out as if it wants to go in another
direction--ignore this for now and just keep plotting along down the center of tarmac. Just to give you some idea, a typical horseshoe shaped hairpin will typically require only 3 vertices to make (one placed just before the start of the turn and one just after the exit of the turn). Again, at this point don't be concerned if the line is bulging out in places; just make sure your vertices are in the center of the tarmac.

When you end the line click the last vertex on top of the first vertex to complete the circuit. It then asks you if you want to close the spline, answer yes.

At this point you'll have a pretty roughed-in line following the center of the pavement. For corners that need to be touched-up you can change the vertex type from "smooth" to "bezier" or when you're in a really tough situation choose "bezier-corner". DO NOT USE "corner" type vertices.

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/2.jpg
Lofting Tutorial



3) Making the Shape

This object represents the track’s cross section.

So, somewhere out of harms way create a line (spline) that is perfectly straight and flat with only two vertices (the start point and the end point) and make them both "corner" type vertices. What I do is just splash down a rough line then go into vertex edit mode and use the transform type-in (F12) to move each of the vertices so they are exactly straight. Let's say vertex 1 is at (200,200,0) and vertex 2 goes at (212,200,0) which would be 12m to the right. The width of this line will be the width of the lofted pavement. I find widths between 8m-16m to be good for racing.

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/3.jpg
Lofting Tutorial


4) Setting up the loft

Here we will assign the splines to the loft and adjust its settings.

OK then, on to the next step, which unfortunately takes a lot of words to explain but is remarkably easy and quick. Everything I say here is based on 3D Studio MAX 3.0, the locations and perhaps even the names of some of these functions may be different in other versions of MAX and I really can't help you there.

If you've gone through any lofting tutorials then you understand that lofting is the process of pulling one or more "shapes" along a "path" to form a 3D object. For example:

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/4.jpg
Lofting Tutorial


Hmmmm... that squiggly line looks kind of like a part of a race track. What if, instead of that stupid star "shape" we substituted a simple straight line? Pulling that along the squiggly "path" would probably yield something like a road, eh?

Now then, you've got your "shape" and your "path" so you're ready to loft your track. Select your "path" line (the line that looks like your track).

The "loft" function is rather hard to find in 3D Studio MAX:

- In the command panel go to the "create" tab (the one with the little white arrow pointer on it).
- Directly under that select the "geometry" button (looks like a gray sphere).
- In the pull-down list select "Compound Objects".
- In the arrangement of buttons below will appear a button that says "Loft". (Somewhere in the fancy modeling icons list there is a "loft" icon that does the same thing, but that's just as hard to find.)

In the lower part of the command panel will now appear a whole set of loft settings and functions.

In the "Path Parameters" section you will see selections for Percentage, Distance or Path Steps -- choose "Path Steps".

In the "Creation Method" section make sure "Instance" is selected, then click the "Get Shape" button.

Click on your straight little "shape" line. As soon as you click the loft will be generated. Now go back and click the "Get Shape" button again to exit that mode.

"Well, ummmm.... Jeeezzz, it created something but it doesn't look too much like a road...what gives???"
It will look a lot better as soon as we apply the right settings.

If the loft is facing upright like a wall, you need to select the shape line and go to the modify panel find “Line segment mode” and use the transform type-in window to rotate the line on its Z axis 90 degrees, until its flat like a road, then turn off line segment mode. Take a look at it in the side and front view ports to make sure its level.

Go all the way down to the bottom of the command panel to the "Skin Parameters" section (you might have to click it to make it roll-out). Use the following settings

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/5.jpg
Lofting Tutorial


At this point your loft should start looking more like a drivable road. If you were to apply a tarmac bitmap to it you could instantly make it look like tarmac. Let's go ahead and do that....

Create your material and link it to a road surface bitmap that you like. Apply your road surface material to the loft object. If you render the scene you'll notice that the material is probably heavily stretched along the length of the track (blechhhiieee!!). Let's fix it up nice and pretty....

http://endless-resources.org/Images/Boards/Lofting_Secundary_images/6.jpg
Lofting Tutorial


The Length Repeat setting is critical to get right in order to make the tarmac look believable in-game. Length Repeat is exactly what it sounds like: how many times your road surface bitmap is repeated along the entire length of the loft. The correct setting depends entirely upon the length of your track and, frankly, comes
down to a sort of guessing game to find the number that looks best for you. We've started with 40 and will increase/decrease that number until the road surface looks good.

Set the view port to "Smooth + Highlights" so you can see the materials in real-time; if your display system is incapable of this you will just have to resort to rendering it each time. Zoom in to a piece of the track close enough so you can see what the surface is going to look like. Using a bitmap that doesn’t tile very well (just for testing purposes) is the best way to find the right repeat length, its best to have it a little less than square though or else it’ll look jagged at high speed. Try making it 2 long.

Similarly, Width Repeat is how many times the bitmap is repeated across the width of the loft. Almost always you want this set to 1, but there are some rare situations where you would want it repeated multiple times; this setting allows you to achieve that.

Notice also that you are allowed to specify fractional numbers like 1.5 or 3.25 to get just the effect you might need for those unusual situations.

If the track uses multiple line segments on its shape line, its best to set width repeat to its number of segments and turn off “normalize” on the surface parameters. You can the select each line segment and scroll down the modify panel to the surface parameters and give each segment a unique material ID. This will be helpful when you convert the loft to a mesh because each polygon going out from the track will already have a material ID and will be easy to assign materials to.

Let's switch back to wire frame viewing mode for this next part. Remember above in the "Skin Parameters" section I mentioned there would be more about the "Shape Steps" and "Path Steps"? Well, here you go:

Shape Steps is essentially how many times across the width of your road polygons will be generated. A setting of 0 = 1 quad across, 1 = 2 quads across, 2 = 3 quads across, etc. Go ahead and play with that number and you will be see what I mean. You can see how playing with this number can instantly cause you to have a high-poly track that could be very FPS- unfriendly for everyone. A setting of 0 works best in almost all cases. There are some cases where increasing the polycount across the width of the road is desirable in order to make the road smoother in areas where the pavement twists or banks to a significant degree and makes the road too bumpy in-game, but you would really only want to increase the number of polygons in those specific areas that need it, not the entire track--that would be a wasteful excess of polys. You could always loft those troublesome sections with a separate loft using the same "path" and "shape" as your original track loft, and increase the Shape Steps for that second loft.

Then just use the higher-poly track parts in the areas that need it and stick with the original loft for the rest of the track.

Note that "Shape Steps" has no effect on the "Width Repeat" for the bitmap
mapping across the width of the track, which is something totally independent regardless of how many polys you have across the width of the track. Also note that it does not change the width of the track, it only increases the polygon density across the width.

Path Steps controls how many polygons are generated down the length of your road. Finding the best number for this setting comes down to "best feel" and "what looks best" and it is also greatly effected by how many vertices you have on your "path" line. You will notice that around curves and where hills start/end you need to increase the polycount in order to make it smooth.

Each time you change the Path Steps setting it will warn you that doing so will change the locations of "shapes". This is actually a pretty important thing to be concerned about and you will see why when we get into adding additional "shapes" to change the road width, add camber, banking, etc. Try not to get into the habit of mindlessly just clicking YES to this warning. For right now, however, we have a very basic loft with only one shape on it, so go ahead and adjust this number up/down and look closely at how it affects your track. Notice that if you increase it too much the track will actually start to fold over itself in tight turns and this becomes a royal mess to try and fix later. You want your final settings to yield a track that is smooth around corners and hills/dips but also very low-poly along straights. It will quickly become clear to you that this setting alone is not going to give us what we need.

The other thing that greatly affects the poly density is the placement of the vertices on your "path" line. Remember plotting out all those "smooth", "bezier" and "bezier-corner" vertices? Notice how the loft increases the poly density based on those vertices.

Notice also that how much you pushed/pulled on the bezier handles of those vertices also affects the ultimate density and arrangement of your track's polys. Let's see this in-action....

Un-select your loft and select your "path" line -- since it is underneath your loft it might be easiest to use the select-by-name feature (Edit - Select By - Name).

Go into vertex .edit mode and move a vertex. Notice how the loft is effected in real-time and adjusts the poly arrangement accordingly. Notice also how pushing/pulling on the bezier handles of a bezier vertex has a profound effect on the smoothness of your loft. Now go ahead and use refine to add a vertex somewhere. Pretty powerful stuff, eh?

Since the whole goal is to end up with a track that is smooth where it needs to be smooth, and low-poly along straights it is important to find the right balance between the "Path Steps" setting and the amount and placement of vertices. Yet you might not be able to make major changes to the vertices without changing the shape of your track too much. You also do not want to end up with sections where the polygons overlap each other. You can also experiment with changing some vertices from "smooth" to "bezier" or visa-versa. It shouldn't take too long to strike a good balance. If you have examined the construction of many of the
original tracks and you will already have some idea of what to shoot for in your track surface.

5) Fine tuning the track Path

Adjust the path so it lines up with the track better and has an optimal number of vertexes

Move the vertices around and tug-and-pull on the bezier handles until your line follows the center of the pavement all the way around the track as perfectly as you can. In some cases you might have to go back and actually add some additional vertices in order to achieve the perfect curvature to follow the center of the tarmac; you do this by clicking the "refine" button then click where you want the new vertex to be created (make sure you created the right type of vertex for the situation at hand--either smooth, bezier or bezier-corner). Be careful to not go overboard and add too many vertices there should typically be a vertex every 20 meters on the tight spots and every 80 meters on a long straightaway. Most turns can be achieved with only 2-3 vertices, and I have never run across a turn so complicated as to require more than 4 vertices. Use the minimum amount you can get away with--you'll see why in the lofting step.

Now go back and raise/lower individual vertices on the line to add the elevation changes. Again, to achieve the correct and smooth elevation changes feel free to use "refine" to add an additional vertex if you have to. You don't want any knife-edge elevation changes. Pay close attention to your measurements here, it's easy to over do it and end up with huge heights or really steep hills.

I’ve noticed that if you rise or lower a point by 1 meter it will make a gradual hill and 2 meters per point will make a fairly steep hill. It’s a good idea to make the 2 points at either end of the hill half the height difference of the rest to make a gradual transition.

Don't worry about getting this line too perfect on you’re first-try, you will be able to go back and adjust this line as much as you need to later. NOTE: do NOT attach this line to any dummy or to the "hierarchy". It should remain a free-floating object in the "schematics view". Also, never delete this line (the "path), it can come in very handy even much later in the track development process.

I've been asked if the grass and such are also lofted. Well, you can loft the polygons for the rumble strips and berms pretty well and also at least have the loft generate the spare polys that you can then pull on and stretch to form the grass and gravel traps.

An alternative is to just "extrude" the polys for the rumble strips/berms/grass from the edges of the lofted tarmac when it's finished. You can push/pull on these new polys to form whatever you need. The good thing about doing it this way is that it is incredibly easy and fast, the drawback is that you will have to manually map those polys (if you loft them they can be automatically mapped to follow the curves and hills--cool stuff when it works!).

With your "path" line selected, over on the command panel in the "modify" tab you will see a "General" section. In there are settings for "Interpolation" and a check-box for "Adaptive". I turn on "Adaptive"; it seems to result in smoother lofts and better polygon arrangement in some situations. You can turn this setting on/off at will at any time later if you want to compare how your resulting loft is affected. Another way is to set Interpolation to “steps” and set it equal to the number of steps in you’re loft, then it will match up perfectly.

6) Developing you’re shapes

This step is used where there is a change in terrain type, camber, or track width

The first thing you need to do is count how many lateral surfaces you will be working with, starting from the middle and working outward. Be sure to double the numbers to accommodate both sides. Here’s an example;

1 segment in the middle for road
4 segments on either side for front and top of the curbs
2 segments for grass
6 segments for the front, top, and back of the outer wall
So you will need to make a shape with 13 segments.

The process of creating the line and the sections is the key to making it work correctly.

1) turn on 3d snap and check grid and vertex snap in the snap settings.
2) Make the grid visible then create a line that is 30 meters long, (snap the line to the grid.)
3) Use the refine tool to cut the line into even 3 sections, to define the 2 grass edges and middle road section.
4) Refine 2 more lines at 0.5 and 1 meter from edge of the road; these will be for the curbs. Do this twice; you should have 2 segments for each side of the road
5) refine 3 segments at either end of the line; these will be for the outer wall

For making curbs and optimizing purposes, you can setup the 1 or 2 extra segments for the curbs, then for areas that don’t have curbs; snap the vertexes of the curb segments together (to the road edge) so they are and have an unsnapped set of them for the parts where curbs are used. For the curb/ non-curb transition; I go one space past the curbs and then add a non curb shape. This keeps the track normal without making it look weird where the curbs and road transition.

You can make multiple width segments for the shapes as well by dividing the edges of the line

7) Making the in/outfield and pit area

This step creates the extra real estate needed for a complete, fleshed out venue.

8) Some important tips
One thing to keep in mind when lofting is to make sure the cross section is flat. I use the transform type-in (right click on the rotate button to bring the window up it up). Then use exact degrees like 90 and 180 to rotate with. If you don’t pay attention to the flatness of the cross section, later on you will have problems with the track being off by an inch or two on one side and you may need to redo the whole thing...

Another good idea is to setup the material ID's of the loft sections by selecting the shape's edge and assigning each edge the appropriate material ID in the surface properties section. This will make all sections that are after the line use this new material ID set.

I setup my shapes so they are always oriented on one of the X axises so they are either straight horisontal aor verticle depending on which is easier to use while editing angles and visible as a cross section from the top view. This makes it easier to edit and to manage many shapes. If they placed are at right angles you can use the transform gismo's handles and the transform type in window to edit very precisely by focusing on one axis at a time.

Some finishing notes

What you want to look for first is whether the track is smooth enough to drive on at high speed, with no lethal bumps or sudden angles in the surface. Also check out the elevation changes, do they seem realistic? Are the turns relatively round and not choppy and angular? Is the pavement wide enough or too wide?

Try to drive the entire track surface. Do you run into any polygons where the game will not allow you to drive? If you need to smooth out the loft or make other changes to it remember to make those changes to the original loft that you have hidden. Un-hide it, and make your changes, then clone it. Hide the original again for safe keeping and convert only the clone into an editable mesh.

The idea is to keep one "master loft" under development -- as opposed to generating a new loft in each edit session. When it's time to export you make a clone of it and convert that to editable mesh (which can be exported). The "master loft" remains as a loft with all the changes up-to-date as you continue to refine
and tweak it. This only goes on for short time as you will soon reach a point where you are happy with the loft and declare the road surface is now "good enough". You will then clone it one last time, convert that clone to an editable mesh and start doing the next phase of track development directly to those polygons, such as extruding grass, walls, curbing, etc.

Always keep that finalized loft (and the lines you used to generate it) tucked away somewhere because you may find yourself in a situation later down the road where you say to yourself "Damn! I wish I still had that finished version of the loft because it would come in handy for what I'm trying to do right now."

If the track seems to be too wide, use the "Tape Measure" tool in 3D Studio Max to measure the width. If the "shape" line measures 12 then the road width should also have turned out to be 12.

If it is not the same then you may have scaled the path line up to make it the right size for the track. This creates some serious problems because the resulting loft is further effected by any scaling you did to the original path line, thus the pavement will be the wrong size, and even the mapping values will be thrown off.

In fact, all units of measure are now thrown off when you later try to work with those polygons; for example, try to extrude one 1 meter and it may end up only 0.273 meters in reality, so you have to figure a "conversion factor" to adjust for the scaling. It can quickly become very aggravating. This is why it is important to zoom your view port so that the grid matches up to the scale of the background image correctly before you even start.

I have not found a way to tell 3D Studio MAX that I want the path line to be considered to be un-scaled without it shrinking back to its original smaller size.

Unfortunately, the easiest and safest thing to do is to make a new path line, considering the fact that you probably now have your view port zoomed out to the proper size to trace the track map.

Stay away from scaling anything used in your lofts, it causes some tricky issues.

If you already know the length of the track you can do a measured lap around your track at 30 Kmh\Mph and divide the lap time by 2 to find the actual track distance in Km or Miles. You can then use cross multiplication to find out how much the track needs to be enlarged or reduced in size.

To reduce the size of the loft create a “measuring tape” helper, go to “move mode” and move the triangle part of it to be on the west side of the track and the box shaped part is on the west side. Then go to the modify panel and click the specify length box and increase the length until the green line reaches the east side of the track (where the box is). Multiply the measuring tapes length to the number you got from the measured lap and type in the new length. Then select the path line in “line segment mode” and reduce\increase its size to match the measuring tape using uniform scale. You may need to move the line around a bit to match it up to the measuring tape.

Here is and an example:
The track real world length is: 3 miles
You take a lap around the track at approximately 30 Mph and it take 8 minutes.
The 8 minutes divided by 2 = 4 miles
The 3 miles divided by 4 = 0.75
The measuring tape length is 500 meters
Multiply the 500 meters by .75 and it = 375
Type this into the measuring tape length and reduce make the path line match the green line’s length.

Glossary of terms

Loft
A compound object composed of a Path for the layout and one or more Shapes for the cross section.

Path
An editable spline used to control the length of the track; where the track goes and the elevations

Shape
An editable spline object similar to a path, but used to control several features; the width of the track or how wide the road, curbs grass and walls are; the height of curbs and walls, and control camber angles and embankments beside the track.
« Last Edit: November 25, 2014, 12:18:50 pm by Nuno Lourenço »