Tutorial 4: Modeling Vehicles in gmax
Introduction
This is a brief tutorial on creating vehicle models for Trainz using Gmax. A simple Ford Falcon sedan is the vehicle to be modeled.
Pictures Required These are some of the pictures you need to make a texture file.   Pictures should be taken square on to the surface, and have as even lighting as possible. Sometimes pictures taken on overcast days have the better uniformity. These are used to make one texture file. First you should make a good image from the original that can be pasted at a reduced size into the texture.  Note how the underside of the bumper has been lightened up, and the right bumper has been pasted over to the left side to make equal brightness and symmetrical detail. Additional pictures of the car tyre and rim are needed for a separate file. You also need to make a texture from the tread pattern.  Texture File You should choose a reasonable size for the file, and paste the various images into the file, filling the area available if possible. The texture file falcon.tga should look like this when finished.  Note how the pictures are all square on, the windscreens have been worked over to give a realistic reflection, and some additional coloring has been added at the edges of the pictures, to give even shading on the corners. You should do some calculations on how many pixels each image will cover in the texture file, so you may shrink the original pictures to fit. For the side on view, crop the original image and note the size of the picture. If using Paint Shop Pro, the size in pixels will be shown at the bottom of the screen as well as the ration of the size. This ratio is important. When you have determined how much of the texture file will be taken up by this image, make a selection area in the blank texture file, in the same proportions of the original image, and paste the image into the selection. This will ensure the correct length to height ratio. Do the same for the pictures of the other sides of the vehicle. You may not be able to get a picture of the hood or bonnet, so you need to make up a picture from existing colors of the vehicle. You can see that texture on the right of the above picture.  This file is 512 by 256, taillights have been brightened and the vehicle made symmetrical. Unless the vehicle is yours, you should change or blur the number plate. We need an additional side view picture of the car, to place in gmax so we can trace around the shape. The picture above is suitable and will be placed on a plane. As it is not going to be imported into Trainz the actual size of the file is not important. It can be tga or jpg file. The important thing is to have it correctly proportioned. 
Dimensions You need some dimensions of the vehicle, usually obtained when you took the pictures – length, width and height are needed, and the tyre diameter is a big help. You should also measure the width of the vehicle at the roof level, as this will be pulled in from the width of the body in most vehicles. If you are missing some dimensions, you need a key dimension, say the wheel diameter (0.65 metres in this case). In Paint Shop you can place the cursor on each side of a picture of the wheel and note the pixel count. Say the width of the wheel is 120 pixels, equals 0.65 metres. This means the scale of the picture is 185 pixels per metre. Counting pixels in other parts of the image will let you work out other sizes. Sometimes the vertical scale will be different from the horizontal one, and both need to be calculated. The pixel scale is only valid for this one picture, you need to do it again for other images.
Setting up gmax The first thing is to set the units to Metric, to set the grid to a fine scale, say 0.01 metres, to set “Auto increment” on, and to set “Auto backup to three files, and every 5 minutes. Use the Customise Menu and open each highlighted sub menu in turn.  From the Units Setup, set the units to metres.  From the Preferences Settings, also set the units to Metres  From the preferences Settings, tick all of the boxes below. This will make incremental saves, giving you a progressive number of files, so if you have a problem, you can go back a file or two. It also makes a backup file, saved every 5 minutes in case Gmax crashes. You do not lose more than 5 minutes of work. You find this backup file in the Autobak directory, as Autobak1, 2, 3. You can look at the time stamp for each file to determine the most recent. You may need to turn on “all File” when trying to load the file into Gmax, so you can actually see the files in the list.  The last one is to set the grid settings. These should be set to a small value say 0.01 metres, so you can see a fine grid as you zoom in. Set this in the Grid and Snap Settings – Home Grid.  Once you have a model with all the settings correct, you can load it again another time for a new model, delete the old one and you have a new model canvas with all the imported settings. For the model to be able to be included in the Auran traffic on roads, you need to construct the model facing down the page in top view, centered on the origin. 
Starting the Model In the side view window draw a plane the length and height of the side view of the vehicle. Make sure the plane is only 1 segment by 1 segment (it defaults to 4 by 4). It is not important as this plane will not be exported, but it is good practice for later. Allow for the wheels, and place the plane 0.1metres above the ground. This prevents the vehicle sinking too far into the Auran roads. Load the side view picture into the material editor and navigator and place the image on this plane.  We can now trace around the edges of the car using the line drawing tool and join up where we started. You should click to draw a point where there is any major change of direction of the body, but not too many points or the model will be complicated and hard to texture because of all the small surfaces. The outline is shown in the following view, and the line has been extruded in the next picture - see below. 
Extruding the Shape The lines should follow the shape above. We use the extrude tool in the modifier menu to make the line into a solid shape, 1.65 metres wide, to match the width of the car.  You can see the three dimensional shape.  We should pull the roof line at the top in a bit to give the correct shape to the turret. By selecting “Vertex” in the Modify menu, we can choose the roof vertices in red. With the move tool selected we can drag these vertices in a bit, to the measured dimensions of the roof. Type in accurate dimensions in the dimension boxes at the bottom of the screen.  We can add additional chamfers on the edges to get a better shape. In the perspective view of the car, from the modify menu – edges selection, start by choosing the edges along one side, and using the chamfer tool in the modify menu, make the chamfer 0.05 metres. Make sure you choose all the continuous edges along the side, before you apply the chamfer.  Do the other side of the car to match. The wireframe view will look like the picture below. 
Applying the Texture to the Model Load the texture into the material editor. Choose the model and apply the texture, and “show “ the texture by clicking the blue and white checkered cube. 
Mapping the Texture We are going to use the Unwrap UVW modifier to choose which surfaces have which part of the texture file applied. Open the Unwrap UVW Unwrap modifier, click on the “plus” sign to open the “select face” option.  Click on “Select Face” to choose the polygons to work with. You cannot do all the surfaces at once, so you should choose all the polygons on one side, including the chamfers along the top of the side.  Now click on the “Planar map”, and the “Edit”. This opens a screen with the texture showing, and lines representing all the polygons of the model. In order to turn off the ones that were not chosen, click the small triangle in the bottom of the screen to turn it red. Only the lines for the chosen polygons are now shown. 
Usually the vertices will be orientated in the same direction as the texture, but as you see above, they are sometimes rotated as above, and moving the vertices to conform with the shape is difficult, and often distorts the mapping. If the above happens, choose a different axis in the side menu (picture below) and re-click the Planar Map button. If you select the correct axis, the mapping coordinates will be aligned better with the texture, and using the move and scaling about one axis at a time buttons in step 3, you can easily manipulate the coordinates.

Using the scale, move and rotate tools you move the vertices showing until they make the polygons cover the correct parts of the texture file. You will need to drag the mouse around the vertices to select them, then use the tools to rotate and move the lines until they cover only the correct parts of the texture file.
You will need to flip the vertices if they are facing the wrong way. You must place the vertices in the correct location, and maintain the scale positions, so that you do not distort the shape. The lines should cover the side texture as in the picture below. Hints: There are additional zoom tools in the bottom task bar of the texture edit menu so you can see the vertices and shapes more clearly. If you have chosen all the vertices as in the picture above, right click the mouse to open the quad menus, and you can select flip horizontal or flip vertical to change the orientation of the shape. Make sure you surround all the required vertices before you try to move, rotate or scale. You need to move the mouse over one of the vertices to make the tool work.  Now choose other surfaces and repeat the process until all the polygons are mapped correctly. The vehicle should look like this as you work over the surfaces. Collapse the modifier when you are finished.  When you have finished, you can use the Smooth modifier to make the texture blend better around the corners. Open the modifier, choose “auto” and set the angle for 60 degrees say. You can experiment with this angle. It is the maximum angle between adjacent faces that the smooth modifier will use to smooth textures. 
Making the Wheels Method 1
Here are three ways to make a wheel
We can make a plane, and use opacity files to cut it into a circle. This method is very efficient on polygons but looks like a thin disk You can make the wheel two sided, so you see it from all sides. Auran uses this method and only makes the wheel one sided.
Make a separate 64 by 64 file for a wheel. It requires a texture.tga file with the wheel shape filling the square, and a separate opacity.bmp file to cut out the circular shape.  In gmax, make a plane for the wheel say 0.65 metres square, load the two files into the material editor and navigator, and apply them to the plane. The texture file is placed in the Diffuse layer slot, and if you open the “Maps” display, you can see where the opacity map will be placed. Tick the opacity box, and double click the “none” display. This opens the material navigator for you to find the opacity file.  Use the UVW Map modifier to map the plane, using the box or planar option. 
Making the Wheels Method 2
The second method uses a solid cylinder and uses more polygons, but gives a more solid wheel.
You need two texture files for this method. One is the same side-on view of the wheel, 64 by 64, no opacity map, and the other is a texture of a tread pattern that can be tiled around the cylinder.  In Gmax, make a cylinder 0.65 metres in diameter, and 0.195 metres thick. Choose say 9 to 12 segments for the cylinder, and 1 segment high.  Now select all the cylinder, and apply the tyre tread texture. Open the UVW Map modifier, and tile the tread around the cylinder say 5 or 7 times, determine the number by what looks correct for the tread pattern you are using. If the tread is running across the tyre, you can modify this in Gmax but it is easier to go back to your paint program and turn the texture 90 degrees, and reload it into gmax.  You should collapse the modifier when finished. Now we need to choose the face of the wheel, the circular shape only, so we can apply the wheel and tyre texture and map it. From the Modify menu, choose Editable Mesh, then Polygons, and click on the side face of the wheel. If you press the F2 key, this face will change color to red, so you can clearly see which faces you might have selected.  Open the material editor and apply the wheel and tyre texture to this chosen face. Use the UVW Map modifier to map it on the circle using the planar or box option, as explained for the single plane wheel. Depending on the number of segments chosen for the cylinder, the picture will match the shape of the circle better or worse. If you want a back surface, map this also, otherwise delete it. Don't forget to Collapse the modifiers when you have finished. The picture below is the tyre made as a solid object. It needs to be moved so it sits in the correct location, and hides the part of the wheel that appeared on the main body texture file. There is no point to cut an arch in the body for the mudguard space. This only increases the poly count. If some of the wheel on the body is still showing, go back to the main texture file and paint out the tyre parts with black Because the vehicle has some solid body where the tyre is, you should make the tyre sit a little wider than the body. This stops the flickering effect when two planes are set on top of each other. 
Making the Wheels Method 3
The third method is a combination of the first two. The tyre tread is made as in option b above. If you delete all the end segments of the cylinder, you will save 8 polygons per tyre side.
Now draw a plane 0.65 metres square and place it on the end of the remaining cylinder. Center it on the cylinder axis. If you now apply the wheel texture and the opacity layer as in option a. above, you will get a nice looking wheel with a saving of polygons, at the expense of using an extra opacity layer file. When you have finished the tyre, clone it (copy) or mirror it, so you make the other three tyres for the vehicle. Rotate the tyres if necessary, to make the normals face the correct way.
Issues
- Mapping the texture so that you keep body lines straight is quite hard. The shape of the car and the exact position of each vertex effects the texture mapping. You need to be accurate in placing the shapes in the edit box.
- Sometimes the extruded body shape makes very long triangles in trying to join vertices along acute angles, to make the polygons. A very small change in position of a vertex, can make a big distortion in the texture. In some cases you need to delete the whole side of a vehicle and create new polygons, of a more regular shape, using the polygon create tool, and re-map the textures.
Ian Manion (Vulcan) September 2005
Amendment Notes and Comments
8/09/05 Initial issue.
20/10/08 Amended to include a section on orientating the mapping co-ordinates with the texture, thanks to Dinorius Redundicus for the suggestion. |