NFS 3-4 Cars import for TORCS




This tutorial explain how to import a car from EA Need For Speed (NFS) file format cars into TORCS.

First important point:

PLEASE DO NOT PORT AND PUBLISH CARS WITHOUT THE AUTHORIZATION OF THE AUTHOR

This tutorial is based on the Jaguar E lightweight of Butch (K/Cendra)

You will need the following tools to make the conversion:

Extracting the files

Ok now let's start with a car.viv file, the first step will be to extract the files with NFS Wizard under win32.

the files extracted look like:

-rw-r--r-- 1 torcs torcs 1049115 Aug 4 2003 car00.tga
-rw-r--r-- 1 torcs torcs 825624 Aug 4 2003 careng.bnk
-rw-r--r-- 1 torcs torcs 7528 Aug 4 2003 careng.ctb
-rw-r--r-- 1 torcs torcs 7528 Aug 4 2003 careng.ltb
-rw-r--r-- 1 torcs torcs 1179040 Aug 4 2003 car.fce
-rw-r--r-- 1 torcs torcs 4823 Aug 4 2003 carp.txt
-rw-r--r-- 1 torcs torcs 5643159 Aug 4 2003 car.viv
-rw-r--r-- 1 torcs torcs 1049115 Aug 4 2003 dash00.tga
-rw-r--r-- 1 torcs torcs 675680 Aug 4 2003 dash.fce
-rw-r--r-- 1 torcs torcs 66616 Aug 4 2003 dash.fsh
-rw-r--r-- 1 torcs torcs 1557 Aug 4 2003 fedata.bri
-rw-r--r-- 1 torcs torcs 1557 Aug 4 2003 fedata.eng
-rw-r--r-- 1 torcs torcs 1553 Aug 4 2003 fedata.fre
-rw-r--r-- 1 torcs torcs 131112 Aug 4 2003 fedata.fsh
-rw-r--r-- 1 torcs torcs 1562 Aug 4 2003 fedata.ger
-rw-r--r-- 1 torcs torcs 1577 Aug 4 2003 fedata.ita
-rw-r--r-- 1 torcs torcs 1557 Aug 4 2003 fedata.spa
-rw-r--r-- 1 torcs torcs 1566 Aug 4 2003 fedata.swe
-rw-r--r-- 1 torcs torcs 90981 Aug 4 2003 jgel.qfs
-rw-r--r-- 1 torcs torcs 81976 Aug 4 2003 ocareng.bnk
-rw-r--r-- 1 torcs torcs 257 Aug 4 2003 readme.txt
-rw-r--r-- 1 torcs torcs 553704 Aug 4 2003 scareng.bnk


In red you can see the important files.

We'll continue the tutorial under Linux.

Converting the files

Make a directory to store the car in the runtime directory :

$ cd /usr/share/games/torcs/cars
$ mkdir kc-lightweight

Copy the files in this directory :

-rw-r--r-- 1 torcs torcs 1049115 Mar 17 22:04 car00.tga
-rw-r--r-- 1 torcs torcs 1179040 Mar 17 22:04 car.fce
-rw-r--r-- 1 torcs torcs 4823 Mar 17 22:04 carp.txt
-rw-r--r-- 1 torcs torcs 257 Mar 17 22:04 readme.txt

Use The Gimp to convert the texture in rgb format:







We'll see the necessary modifications of the texture later.

3D Mesh conversion

The tool used to convert the 3D model is called nfs2ac written by Christophe Guionneau.
The usage is:

$ nfs2ac car.fce > kc-lightweight.ac

Now we have the 3D model in AC3D format, we can edit it to change the texture name from car00.tga to kc-lightweight.rgb
and open it with AC3D:



First remove the wheels as TORCS provides its own wheels:

Select the object mode:



The select the wheels:



and remove them:



Set the vertical origin of the car at the bottom:



First select all (Ctrl-a) then use the arrow to get the size, set the y value to half the height of the car and click on the Move to button.

Now make the transparent parts a separate object.

Select only the body (:HB) with the Hierarchy View tool:



Then hide the other parts of the car:



Now switch in surface mode and select all the glasses:



With the menu Surface -> Cut-away object... (Ctrl + Shift + X) make a new object from the windows,
switch back to the Object mode and name the new object :WI



Locate the windows location on the texture with the Tool -> Texture Coordinate Editor (F10)
then use The Gimp to make it transparent in the texture (along with the steering wheel border).



Now use the menu Object -> Optimize surfaces... to remove degenerated surfaces.
Save this first version into kc-lightweight.ac and remove the "crease"
lines from the file.

Generating the wheel texture

We will use the wheel in the car texture:

First extract it with The Gimp:



Then add the tire around:



Use the Filter -> Blur -> Motion Blur filter in radial mode with the following values for Length and Angle:


to compose the following image:



Resize it to 128x128 and save it as tex-wheel.rgb

Now create a white image of 128x128 called shadow.rgb

The files so far should be:

-rw-r--r-- 1 torcs torcs 1049115 Mar 17 22:04 car00.tga
-rw-r--r-- 1 torcs torcs 1179040 Mar 17 22:04 car.fce
-rw-r--r-- 1 torcs torcs 4823 Mar 17 22:04 carp.txt
-rw-r--r-- 1 torcs torcs 401487 Mar 17 23:14 kc-lightweight.ac
-rw-rw-r-- 1 torcs torcs 1049088 Mar 17 23:09 kc-lightweight.rgb
-rw-r--r-- 1 torcs torcs 257 Mar 17 22:04 readme.txt
-rw-rw-r-- 1 torcs torcs 66048 Mar 17 23:39 shadow.rgb
-rw-rw-r-- 1 torcs torcs 66048 Mar 17 23:38 tex-wheel.rgb

Creating the XML file with the car's settings

First check that the carp.txt file do not end with a coma ',' (remove it if necessary)
the use the nfsperf tool to convert the settings from the NFS description to TORCS description.

$ nfsperf -c ../../categories/Historic/Historic.xml -o kc-lightweight.xml

Now edit the kc-lightweight.xml file.

First you have to fix the beginning of the file. Replace the header by:

















Then add the following sections:


























































































The position of the driver have to be just before the wind-shield and the lights are optional.
The position are taken within AC3D.

Update the Car section with the values measured within AC3D.


















Use AC3D to set the axles positions:













Set up the wheels too:






























































Now the car should be driveable, the result so far is:



To make the shadow texture follow the tutorial.

It looks better now:



Additional Steps - Smoothing and Level of Details

To have reflections on the car, you'll need to run a tool called accc written by Christophe Guionneau.

$ kc-lightweight]$ accc +es 0 kc-lightweight.ac kc-lightweight.acc

This will generate an .acc file that will be referenced in the kc-lightweight.xml file instead of kc-lightweight.ac




kc-lightweight.acc"/>




Now it looks much better:



Generating the LOD (Level of details)

This can be done with AC3D:

First load the kc-lightweight.ac file in AC3D, then switch to object mode and select all then use the menu:
Object -> Reduce... function with 80% as value:



Save the model as kc-lightweight-lod1.ac and uses accc to smooth it:

$ accc +es 30 kc-lightweight-lod1.ac kc-lightweight-lod1.acc

you can do the same to generate kc-lightweight-lod2.acc kc-kc-lightweight-lod3.acc lightweight-lod4.acc
with respectively 60%, 40% and 20% of reduction factor.

Change kc-lightweight.xml accordingly:





























Now, it's done you can play with it.