Build a Car in Blender for Racer
Build_a_Car_2.html

## Step 9. Make a shadow.tga

Driving the car we find that the shadow file is wrong so let's make a new one. It's a .tga file with an alpha channel made with PSP and Blender. Open tutcar.blend In Blender and go to top view, 7-key then press A-key to deselect the car (no pink edges) next press the "Print Screen" key on your keyboard to copy the screen to the clipboard. Quit Blender and start PSP, paste the image into PSP (Ctrl+V-key) and promote to a layer. Delete all of the image except the car, crop tool works well for this. Paint the car all black and resize to width 100 x length 256, change canvas size to 300 x 300 centering the car horizontally and vertically. Gaussian Blur the image with radius=7 and resize the image to 128 x 128 then make a mask (new, from image, source opacity). Save the mask to alpha channel as "alpha0" then save the image as shadow.tga (24 bit, compressed) into your "texture_files" folder and copy it to the racer/data/cars/tutcar folder. Set the size of the shadow in tutcar's car.ini file. If you don't have PSP then use GIMP or another program to get the final result.

## Step 10. Make Tire/Wheels

Time for some wheels/tires! The wheels/tires, steering wheel, brake lights, suspension/brakes are all made centered on 0,0,0 and position is set in the car.ini file.
Open tutcar.blend in Blender, select the body object and move it to layer20. With the cursor at 0,0,0 and on layer 1, add in the top view, 7-key, a mesh circle, 18 vertices, Radius 1 and rotate it -5 degrees. Press S-key and scale to 0,0,0 holding CTRL-key down, LMB click remove doubles (17), turn off "Double Sided" and move upward 0.305 m. Switch to side view, 3-key, rotate -90 degrees. Switch to top view, 7-key, and move right +0.0762 m., extrude (Only vertices) and move left -0.1524 m. Select both vertices, switch to front view, 1-key, extrude, (Only vertices) and move down 0.1047 m. In front view 1-key, subdivide these two vertical lines with the K-key then select the middle two vertices, and scale S-key, X-key outward to 1.1000. Select the bottom two vertices, extrude (Only vertices) and move down 0.0100 m. Then scale S-key, X-key inward to 0.9000. Use F-key to connect bottom two vertices. Select all vertices, A-key, switch to side view, 3-key and set the variables in the "Mesh Tools" box in the bottom button panel as shown below, (Deg=360, Steps=18, turns=1) press spin, the results are shown below. If you get a question mark cursor with the spin button then click in the left port. Select all and recalculate normals outside, Ctrl+N-key, also remove doubles (8). Name the object Ob:wheel_0.

We now have a tire but it needs a wheel, let's make that part. Tab out of edit mode. Add a mesh cylinder, 18 vertices and rotate it -5 degrees and S-key scale it up/down to just fit inside the tire. In front view 1-key, scale S-key, X-key inward to 0.1000 and move right, G-key 0.0400 m. The two images below will be used to texture the tire/wheel. The one on the left from my Formcar, the one on the right from raromachine's mini-cooper, modified. Both .tga image files are in your "texture_files" folder. You can of course make a better wheel like we did the tire, laying out a cross section and using "spin" to make it.

Tab-key to Object mode, select the tire and move it to layer 2. Select the wheel, press 3-key, then press F-key to go to UV Face Select mode, press A-key to select all faces and load the wheel.tga file from your "texture_files" folder into the UV/Image Editor in the right port. Make sure you are using Draw Type: Textured in the left port or you won't see the texture being applied. Press U-key and select "Project from View (Bounds)". The wheel is now textured on all sides. Press A-key in right port selecting all vertices then S-key to scale so that there are no white areas around the edges. F-key out of Face mode in left port.
Switch to layer 2 only, side view, and select the tire_0 object. Press F-key to go to UV Face Select mode, Select only faces visible and load the tirentread.tga file into the UV/Image Editor in the right port. Press U-key and select "Project from View (Bounds)". The tire is now textured on one side. Then in the left port press Ctrl-3-key to see other side and select only the tire faces you see, leave the tread and inside for later. Select the tirentread.tga in the right port. Press U-key and select "Project from View (Bounds)". Now select all the inside tire faces only, you can rotate the tire around in the left port to get them all. Select the tirentread.tga in the right port. Press U-key and select "Reset" in the left port, then select all vertices in the right port and S-key scale all down to a small square on the tread pattern in the center of the texture image. Use F-key in left port to select all tread faces only. Select the tirentread.tga in the right port. Press U-key and select "Reset" in the left port, then select all vertices in the right port and S-key scale all down to fit the tread pattern in the center of the texture image. Use 1-key in left port to see/fit the tread pattern on the tire until you get a tread that looks good. F-key out of Face mode in left port. The results are below. Tire/wheel objects can be made very elaborate, your choice.

Select both layer 1 and layer 2, right click the "cylinder" object to select it then Shift+right click the wheel_0 object and press Ctrl+J-key to join the two objects as wheel_0. Now we have to duplicate it for the tire/wheel on the other side of the car. The wheel_0 object should be on layer 2. Tab into edit mode and select all vertices, press Shift+D-key, Enter-key, P-key, Tab-key. The duplicate, object wheel_0.001 is under object wheel_0, LMB click to select it then press M-key and select layer 3. Wheel_0.001 should now be on layer 3. Select layer 3 only. Switch to top view 7-key, Tab-key into edit mode and A-key select all vertices. Press R-key and rotate 180 degrees. Name the object wheel_1. Both 3-key side views look the same but tire/wheel objects you make may look different on each side. We will export them one at a time as they will occupy the same space on layer 1, that's why I have them on two layers. Tab-key into edit mode, select all vertices and LMB click the new button to th right of "Vertex Color" or you will get an error when exporting, ref Step 8, Note 2. Move each "Wheel" object in turn to layer 1 and export as you did the "Body" object. Return each to the layer they came from after each export.
Save the file, quit Blender and drag and drop the two .dof files from C:/_DOF to your racer/data/cars/tutcar folder and run racer to see if we got wheels now.
Note: You will have to adjust the variables in the car.ini file to position the body, wheels/tires, steering wheel, etc. when you make your own car and you will need to do your own car.shd file.

## Step 11. Make Glowing Brake Discs

RACER information page link RACER Glowing brake discs webPage gives an overview of how to make the brake discs glow when using brakes. Use the following method to get them to work:

First you need a "shader_disc" in your car.shd file. I put shader_disc and shader_disc1 in the tutcar folder car.shd file so you can see what is in it. The important item is the "map" named "rotor.tga" in the first and "map" named "brakedrum" in the second. The map item is the texture name for the brake rotor that will glow. We can have different textures for each brake rotor made.

Second you need the "disc_heat.cg" code referenced in the link in a "cg" folder in the car folder. Copy the "cg" folder from the "texture_files" folder to your "tutcar" folder.

Third you need to put in the front_wheel and rear_wheel sections just before the final bracket of your car.ini file the following code:
`; Brakedisc temperature ;0.003
brake_heating=0.03
brake_dissipation=0.0005
brake_max_temp=1000`

Last you need to make the brake rotor part of each wheel and the brake caliper part. The rotor is not to be made when the wheel is made but after and then joined to the wheel/tire object. Let's make the brake rotor part now.

Open tutcar.blend and select layer 2, object "wheel_0" in right view should be in the left port. Select it, edges turn pink. Tab-key into edit mode, A-key to deselect all vertices and select the wheel vertices only. This is done easily in the right port if the right port is in "Wireframe" view. I'll let you find and set that in the menu bar. Then border select B-key in the right port the wheel vertices only. You could make a circle/cylinder object but as we already have one we'll use it. Press Shift-D-key, X-key and move the vertices left -X 0.0400 m. Press S-key, and scale down to 0.900 m. and press P-key to separate it. Tab out of edit mode and select the new "wheel_0.001" object. Press F-key and select all faces. Switch the right port to "U/VImage Editor" and X off the texture image. The object turns pink in the left port and the texture disappears in the right port. In the right port LMB select "Image", "Open" and find load the "rotor.tga" texture image. Press U-key in left port and LMB select "Project from View (Bounds)" as we did with the tire and adjust vertices to just fit the object. We can delete the center vertex and then duplicate the remaining vertices and scale down to match the rotor but for now we won't. Press F-key in left port and RMB the "wheel_0" object, press Ctrl-J key to join objects. Move object "wheel_0" to layer 1 and export it. Save the file and quit Blender.

Run Modeler.exe (in racer folder) wait for it to stabilize (on my computer it blinks several times and then it's ready to work). LMB click on the "(I)mport DOF" button and navigate to the "C:\_DOF" folder and open the "wheel_0" object it will appear in the window. LMB click the "Material" radio button and then LMB click the "Edit material name" button and in the window that pops up replace "rotor" with disc. LMB click OK and then LMB click the "(E)xport DOF" button and export it replacing the wheel_0 .dof file in your C:\_DOF folder.

Using Windows Explorer, drag and drop the .dof file into your racer/data/cars/tutcar folder and see glowing brakes when you run the car in racer.

Repeat the steps for object "wheel_1" on layer 3, only this time use "brakedrum.tga for the texture image and move the duplicated object +X 0.0400 m. Move object "wheel_1" back to layer 3 after exporting it. Try it out in racer and see the effect after doing the modeler step on "wheel_1". Adjust the brake_heating value to get the desired effect. The brake caliper will be made later as it isn't needed to get glowing brakes.

## Step 12. Body Object Changes

Before we make the rest of the .dof's we need to do a couple of things to the body.dof. Open tutcar.blend and activate layer 20 where the body object should be. Select the faces on both sides where the front wheels go and delete with X-key "only faces".
Subdivide the bottom lines twice, in the side view select only the center three vertices (both sides) and move them towards the back 0.0600 m. Delete both center vertices. Select the two vertices (both sides) and extrude up 0.3300 m. Select only two vertices on one side then Shift+S-key seelect "Cursor to Selection" the cursor is now between the two vertices. Then press E-key, S-key, Y-key and scale to the the cursor to 0.0000. Do the same with the other side. Select all vertices and remove doubles (2). In top view select five vertices on the side with the cursor and extrude (only edges) towards the otherside of the body 0.3000 m. Do the same on the other side of the car (extrude 0.3000m.). Switch to side view, select the ten vertices on both sides, Ctrl+N-key "Recalculate normals outside", then flip normals. In side view select the center top vertices and move up 0.1000 m. Select the top 8 corner vertices and move down 0.0400 m. Use F-key to make faces where there are none and then texture the faces using the black and dark gray squares on the body.tga image that is already loaded, results shown below.
Select the faces on both sides where the rear wheels go and delete with X-key "only faces". Subdivide the bottom lines twice, in the side view select only the center three vertices (both sides) and move them towards the car front 0.0900 m. Delete both center vertices. Select the two vertices (both sides) and extrude up 0.3000 m. Select only two top vertices on one side then Shift+S-key Cusor to Selection and then press E-key, S-key, Y-key and scale toward the cursor to 0.0000. Do the same with the other side. Select all vertices and remove doubles (2). In top view select five vertices on one side and extrude (only edges) inward 0.3000 m. Do the same on the other side of the car (extrude 0.3000m.). Switch to side view, select the ten vertices on both sides, Ctrl+N-key "Recalculate normals outside", then flip normals. In side view select the center top vertices and G-key move up 0.1400 m. Select the top rear six vertices and move back 0.2000 m. Use F-key to make faces on the vertices like you did for the front and then texture the faces like the front whellwells. Tab out of edit mode, press Shift-S-key and select "Cursor->Selection" to center the cursor on 0,0,0. Move the body object to layer 1 and export it. save the file, quit Blender, drag and drop from C:/_DOF to your racer/data/cars/tutcar folder and run it in racer to see what it looks like. The body needs to be moved a bit so the wheel are centered in the wheelwells. Tab into edit mode, press A-key to select all vertices and move -Z down 0.1000 m. then move the body back +Y 0.0200 m. Tab out of edit mode, export, save and quit Blender.

## Step 13. Make bodyshdo

Next is the bodyshdo.dof (for the graphics.shadow model). Open tutcar.blend, select layer 1, RMB select the body object and move it back to layer20. Switch to layer 20 tab into edit mode, side view, select all vertices, Shift+D-key, enter, press P-key to separate. Tab out of edit mode and RMB click the body selecting object "body.001" and M-key move it to layer 10, seect layer 10 only, name this object Ob:bodyshdo. Tab into edit mode, As this object casts the cars shadow we need wheels with it in the proper position. Let's add them using just wheel_0 which we will duplicate, rotate, translate or whatever else we need to do to get four wheels/tires in position. Select layer 2 only, RMB click on object wheel_0 to select it. Tab into edit mode, select all vertices, Shift+D-key, enter, P-key to separate Tab-key out of edit mode. RMB select object "wheel_0.001" and move it to layer 10. Select layer 10 only. The right port should be in "3D View" and "Wireframe" so we can see the wheel_0.001 object which should be pink. Tab into edit mode, select all vertices and G-key, Y-key move forward -Y -1.2000 m., switch to top view, G-key, X-key move +X 0.6300 m. Press Shift+D-key and move -X -1.2600 m. Press Shift-S-key (Cursor to selection) and rotate 180 degrees. Press 3-key to switch to side view, select all vertices (A-key), press Shift+D-key, Y-key and move Y 2.4000 m., select all again and G-key move down Z -0.5000 m., tab out of edit mode, RMB click to select first the wheel_0.001 object and then Shift-RMB to select the bodyshdo object and press Ctrl+J-key to join the two objects as bodyshdo. Press Shift-S-key (Cursor to selection), move bodyshdo to layer 1, export it and move it back to layer 10. Save the file. Drag and drop the .dof as in Step 12. At the end of the Tutorial after adding some stuff to the body we'll work on this again.

## Step 14. Make Steering Wheel

Now for the steering wheel, str.dof. LMB click select layer 4 in front view, 1-key. Add a cylinder mesh with 20 vertices, radius 0.057 m., depth 0.0032 m. cap ends, with the cursor at 0,0,0. Double sided s/b off. Right port 3-key right view. All normals should be coming out of the object. Select four vertices on the left side of the object, the ones in yellow shown below in left image. Delete X-key faces only. Extrude (only edges), X-key and extrude -X 0.140 m. Do the same with the four vertices on the right side extruding +X 0.140 m. Result shown below in middle image. Tab out of edit mode, press F-key to enter face mode, press A-key to select all faces and load "misc.tga" (right image below) from your "texture_files" folder in the "UV/Image Editor" in the right port. Press U-key in left port and select "Reset", we'll sort them out later.
Press F-key to exit out of face mode. You can make a steering shaft if you want one, I have left that up to you. Now we'll make the outside of the steering wheel. Switch to top view, left port, Tab into edit mode and select only the four left most vertices, press Shift-S-key, select "cursor to selection" and add a circle with 6 vertices, radius 0.0200. Rotate -15 degrees and Tab out of edit mode, press Shift+S-key, select "cursor to selection" to put cursor back to 0,0,0, Tab-key back into edit mode press 1-key and select the virtices you just made. Set the Mesh Tools variables as shown in left image below. Press "Spin" and the result s/b like the right image below, if you get a ? cursor, click in the left port and you should have the outside of the steering wheel. Select all vertices and remove doubles (6). Press Ctrl+N-key "Recalculate normals outside" and name this object Ob:str.
RMB on a vertex on the outside and press Ctrl-L selecting only the vertices in the rim, Tab out of edit mode and we will texture our steering wheel. While still in front view (1-key) press F-key to enter face mode, all faces turn pink on the rim. You should be in "U/VImage Editor" in the right port, click the and select misc.tga. Press U-key in left port and select "Reset". Select all vertices in the right port and scale down to fit the "leather" square in the lower left of the misc.tga image. Select two faces at the top of the rim and scale them to fit the red square on the misc.tga image. Helps to keep track of when the wheel is straight. Tab to edit mode and A-key deselect all vetices. RMB click on a vertex on the center hub, press Ctrl-L to select vertices, Tab back to face mode and select all vertices in the right port and scale and move the square as shown in the left image below. With the F-key select only the faces on the back and front of the center hub, use Ctrl-1-key. Press U-key in left port and select "Project from View" then select all vertices in the right port and scale/move the square as shown in the right image below. Press F-key to exit face mode. Move the object to layer 1, export it and move it back to layer 4. Save the file. Drag and drop from C:/_DOF to your racer/data/cars/tutcar folder and run it in racer.
The steering wheel came out wrong in RACER, rotate -90 deg in right view, rotate 180 degrees in front view. Now it's right in racer. More work will be done in Step 19 in the car.ini file. There are still a few things missing which we will make in the next installment.
Build_a_Car_3.html