Build a Car in Blender for Racer
Build_a_Car_1.html

## Step 5. Make a Body

Step 5 and 6 are only to give you the basics of modeling a body then in Step 7 and beyond we will make tutcar. You can skip steps 5 and 6.
Start by adding a plane mesh at 0,0,0 on layer1. In object mode (Tab-key), press 1-key and add the mesh. Make sure the 3D Cursor "Pivot" is on. This scales and rotates about the cursor. Scale the plane down to fit the front end face and using the X-key delete the face only. Name this Object "body"
Using G-key(move), W-key(subdivide), S-key(scale), Shift+S-key(Cursor to Object) put vertices on the lines in the views object. You will have to switch views, 1, 3, or 7 keys to get the vertices where you want them. When you have the vertices in the right location select them all and press E-key(extrude only edges) and move them forward. Notice the normals aren't all in the same direction. Select all vertices, press Ctrl+N-key to recalculate normals outside. Result below.
Save the file. Do this often so that when things don't work right you can reload the file and start over.

## Step 6.

It's easier to see the views if there are no faces so X-key them off. You can put the faces back on later. A picture of the real car helps when doing this.
image from: http://www.citroen.mb.ca/Documents/Motor/motor2cv.html
The modeling of cars can take a lot of time. I have spent the better part of a month getting the body vertices where I want them. So...
You get the general idea about making a car body.dof file, I'm sure, so we will make a very simple "box" car to speed things up a bit. In object mode, Select the body object press Shift+S-key and click Cursor -> Selection to center the cusor back to 0,0,0 and erase the body object. You can also erase the views object, but first and this is very important. Always delete the texture from an object before deleting the object or you will wind up with lots of unused textures that you can't get rid of. Select all faces with F-key in left port then LMB click on the "X" in the right port.

## Step 7. Make the Body

With the left port in top view add a cube then switch to side view 3-key. You'll be in edit mode, Tab-key out of edit mode. Press N-key and set "Scale" values as shown below left.
Tab-key into edit mode, press S-key, Z-key and scale to 1.600 m. hold Ctrl-key down while scaling. The dimensions are indicated on the object lines. Then S-key, Y-key and scale to 0.640 m. Press 1-key in right port to switch to front view. Press S-key, X-key and scale to 2.000 m. Select the bottom vertices and delete the face with X-key. Select all and press K-key and LMB select "Knife (Midpoints)" and drag the brush icon vertically thru the center and press Enter-key. Result shown below right.

Move to left port and select the left vertices then press E-key, LMB select "Region" and extrude -Y 0.690 m. Then select and delete only the center bottom vertex. Ctrl-Z-key will undo operations. Select the right vetices Then press E-key, LMB select "Region" and extrude +Y 0.520 m.
Again delete the vertex at the bottom, inside the object with X-key. Select the bottom right 3 vertices, press G-key, Y-key and move +Y so the line value is 0.680 m. Select the 9 vertices on the top right, press E-key, LMB select "Region" and extrude +Z 1.000 m. Select the 3 top front verices, press G-key, Y-key and move +Y so the line value is 0.420 m. The result of all this is shown below. Name the object Ob:body. Tab in to object mode and save the file.

Now let's put a body texture and windows texture on it. Blender and RACER can use .jpg images but RACER uses .tga images with an alpha channel to make transparent areas. Images for RACER must be a power of 2, 16x16, 512x512, 128x256. The .jpg and .png images are only used for this tutorial, .tga's won't appear in your browser.
The following two images are .jpg's. I put the same images (body and glass) as .tga's in the texture_files folder. If not there, recheck Step 1.

body.tga glass.tga
Tab out of edit mode and in the right port select the UV/Image Editor as you did in Step 4. Press F-key in left port (UV Face Select mode) and select all faces with the A-key. In the right port navigate to the body.tga texture and load it. The texture image "body.tga" is applied to all faces. All faces are now checkered with the texture. Press U-key in left port and select "Reset". In the right port Press A-key, S-key, scale to make the UV face slightly smaller than the blue square. The car body should now be blue.
Press the A-key to deselect all faces and select the glass faces only. "X" delete the body texture from these faces. They turn pink. Apply the texture image "glass.tga" as you did the body texture. Press F-key in left port to exit Face mode. Result shown below. Save the file.

## Step 8: Exporting as DOF files (Windows only)

READ THIS SECTION COMPLETELY BEFORE DOING ANYTHING
There is info on RSC about using the Python scripts with a MAC by citronized, find it if needed with search.
If you downloaded Brent Burton's DOFexporter it will need to be modified as shown in Method 1 below. I recommend looking at his webpages (link at top of Build_a_Car.html)
Get and unzip the DOF exporter into any convenient empty folder (I use a folder named dofExporter that I added to my hard drive) then read the readme.txt file in the folder. Copy these files to the folder where Blender 2.45 is located: `Mesh2DOF.py, VertOpt.py, DOFfile.py,` and`save_dof.py`. We will load the "save_dof.py" script file into BLENDER and use it to export the body object as body.dof In the right port select the "Text Editor", File, Open as shown below. then navigate to the save_dof.py file and "Open Text File".
The code should now be in the right port. With the cursor in the right port press Alt+P-key to run the script. If we did everything right the body.dof file should now be in the C:/_DOF folder. You can check the Blender Console (click on the Blender245 button on the bottom of your monitor screen). It should look like this. Minimize, don't close, the Console or you will have to repeat all steps since your last save file operation.
Save the file and quit Blender. We'll see what it looks like in RACER. Drag and drop the body.dof file from C:/_DOF to your racer/data/cars/tutcar folder.

Method 1.
One file needs to be modified in your Blender folder, "save_dof.py". In the "usage" section of the 'exporter' readme.txt file DON'T do step 3, instead make the change to save_dof.py before loading it into Blender (you only have to do this once). Below is the code that you will change by right clicking save_dof.py and selecting "Edit with IDLE". Edit to match the line in red.

`# Export layer 1 meshes as DOF version 1.0
#
import os
import Mesh2DOF
# Set 'dest' to the directory into which DOF files
# should be saved. Be careful setting this, since
# this exporter will overwrite files without warning.
# For new tracks, change this value when this script
# is loaded into your .blend workspace.
dest = "c:/_DOF"
if not os.path.exists(dest):
os.mkdir(dest)
os.chdir(dest)
print ""
print "----- Mesh2DOF Exporter version %.2f" % (Mesh2DOF.version)
print "----- Exporting into " + dest
Mesh2DOF.ExportLayer(1, dest)`

Make sure you are in object mode with draw mode textured. Select window type "Text Editor" in the right pane and load save_dof.py. the result should be as shown in the image below. Make sure the red mark is on the left of the # character, arrow 1.

Note 1. Insure that all objects are on layer 1. Place the cursor in the right pane and press Alt-key + P-key to export all objects on layer 1. It can take awhile, you can click on the other (console) blender button in the task bar to watch the progress. Save the .blend file, then quit blender. You should now have the body.dof file in a C:/_DOF folder created by the save_dof.py script.

Note 2. If you get "Python error check console" and the console has "index error: list index out of range" then check to make sure the Vertex Color button is on in the lower button panel for each object to be exported, arrow 2. If it is not on, Tab into edit mode and LMB click on "new" for each object to be exported, then Tab out of edit mode. If this doesn't fix the error then try splitting up the objects into smaller sections using the P-key to separate the objects vertices out, reduces the number of vertices in each object.

Method 2. Prefered, use instead of method 1
Create a folder named C:/_DOF where you can put your exported .dof files and then drag and drop them to a desired folder. Makes it easier to keep track of where things are.
Then just copy the 4 Python script files (`Mesh2DOF.py, VertOpt.py, DOFfile.py,` and`save_dof.py`) from the "texture_files/B.Burton_exporters" folder to your Blender 2.45 folder. Then copy dof_export.py from your "textures" folder to your Blender 2.45/.blender/scripts folder. The changes have been made to the "save_dof.py" file.

Ensure that all objects to be exported are on layer 1. See Note 2. in Method 1. LMB click on "File", then "Export", then "Racer DOF (.dof)" and a window will open in a port as shown below. Your image may be slightly different.

LMB click on the two dots just above ".blender" which will switch into your C:\ drive, then LMB click the "_DOF" folder as shown below.

LMB click on "Export DOF" and the file will be exported to C:/_DOF/tutcar as indicated in the image below.

You can delete the "tutcar" and body.dof will be exported to C:/_DOF. You will have to click on "Export DOF" twice. Check the Console to ensure the files were exported and there are no errors in exporting.

Drag and drop the body.dof file from C:/_DOF to the tutcar folder we made in Step 1.
This is what you should now have in your tutcar folder.

1. body.dof file
2. The 18 .tga images from the "texture_files" folder
3. The 13 files from the "tutcar" folder, ref. Step 1.

Start RACER and select your favorite track and "tutcar", tutcar may show up on your menu screen as shown below.
Oh my it's all red! What happened, I know I put a texture on it. You don't have any textures in your racer/data/cars/tutcar folder and the car.shd file also needs to find texture files. So copy by drag and drop all the .tga texture files in your texture_files folder to your racer/data/cars/tutcarfolder. Check your Qlog.txt file, it has a lot of errors! Never mind, just delete it. Restart RACER and try again, tutcar should now look like the one below and your Qlog.txt file should only show an AI error, some missing .dof's and a few .tga's used for the views.ini file, ignore them. All shaders have been made so you don't need to as that's a whole different ballgame we won't get into now.
You can now drive the car in racer but there are a few parts missing which we will make in the next installment
Build_a_Car_2.html