Creating Custom Cars with Freeware

From TM Wiki

Jump to: navigation, search

It is possible to use free software to create a 3d car model for use in Trackmania United. This tutorial explains how to produce a simple model and get it into TMU and assumes no knowledge of the tools we will use. If you are a beginner I recommend that you work through all the steps to learn how the process works. I give very very minimal instruction on using the tools so if you stray off the path you may struggle to find it again.

Contents

Get the tools

  • Blender

Download this from http://www.blender.org/. I used version 2.45: the Windows installer as opposed to the zip archive. Blender is open source and free. Install it. It will ask you where you wish to install Blender's User Data files. I do not know what this means but I chose "Use Installation Directory".


  • The Blender script I made that enables Blender to export a 3ds file without errors. (Right-click the link and save it. Make sure it has extension .py)

http://homepage.ntlworld.com/glaucobacchi/3ds_export_tmu.py This has been tested with Blender v 2.45 and 2.48. Experienced Blender users: my script cannot handle parented objects nor empties.


  • (I have also adjusted a full car template that Nadeo made so that it looks ok in Blender. Get it at

http://homepage.ntlworld.com/glaucobacchi/tmu%20template.blend This has been tested with Blender v 2.45 and 2.48)


  • DXTBmp

Download this from http://www.mnwright.btinternet.co.uk/ and install. I used version 4.00.79. I believe the author makes this program available free of charge.


  • A zipping tool.

Win XP comes with the required functionality built in.


  • An image creation tool. I used GIMP.


  • I used Windows XP. I apologise if some part of this procedure fails when using any other OS.

Understand TMU's requirements.

The amount of detail of your model is limited.

TMU will look for either a high detail or low detail model to display, depending on your choice of the setting Cars Quality reached by clicking the Configure button on the initial splash screen, then clicking advanced then the tab labelled Game. This setting suggests that there would be three levels of detail but I believe this to be incorrect. I do not know how the Medium quality setting affects thing.

The level of detail of other players' cars you see when racing online is determined by the same setting and hence what other players see can differ from what you see.

The low detail model must have no more than 11 parts and a total of no more than 3,600 corners. The limits for the high detail model are 40 parts and 20,000 vertices. You can create just one model but if TMU is looking for the one with the other detail level then you will see a standard car model in game so I recommend creating both by at least creating a low detail model and cloning it to create a 'high detail' one.

For either detail level, the following requirements must be met.

The model must be in a file of the correct type.

TMU expects to be presented with a 3ds file containing your model. This is a format native to the application 3ds Max which costs a lot of money. Fortunately Blender can export a model in this format for free thanks to some hard work by some cool people.

The model's parts must be named correctly.

The model must be made up of at least one of the following parts, which must be named correctly. ( This info is copied with permission from the page http://99.235.192.175/UGG/Downloads/Tutorials/3d_model_conversion_for_tmu.htm written by Trick.)

Main body parts

  • sBody - the parts of the model that can be repainted in the in-game painter, this is usually the body of the car).
  • dBody - the interior, the window rubber, the lights, the front grill, all other except glass and wheels).
  • gBody - all parts that will be shown transparent in the game, windows, sunroof, headlight and taillight covers).
  • dFLWheel - the front, left wheel part that cannot be painted in the in-game painter, this is usually the tyre).
  • sFLWheel - the front, left wheel part that can be painted in the in-game painter, this is usually the rim).
  • dFRWheel - the front, right wheel part that cannot be painted in the in-game painter, this is usually the tyre).
  • sFRWheel - the front, right wheel part that can be painted in the in-game painter, this is usually the rim).
  • dRLWheel - the rear, left wheel part that cannot be painted in the in-game painter, this is usually the tyre).
  • sRLWheel - the rear, left wheel part that can be painted in the in-game painter, this is usually the rim).
  • dRRWheel - the rear, right wheel part that cannot be painted in the in-game painter, this is usually the tyre).
  • sRRWheel - the rear, right wheel part that can be painted in the in-game painter, this is usually the rim).

Wheel suspension parts

  • dxxHub - xx can be FL,FR,RL,RR (the 'kingpin'). Must be used to make the other suspension parts to work.
  • dxxArmTop - xx can be FL,FR,RL,RR (an upper control arm)
  • dxxArmBot - xx can be FL,FR,RL,RR (a lower control arm)
  • dxxArmDir - xx can be FL,FR,RL,RR (the steering rod)
  • dxxSusp - xx can be FL,FR,RL,RR (the spring/shock absorber)
  • sxxGuard - can also be dxxGuard (xx can only be FL or FR)
  • dxxCardan - rear wheel driveshafts (xx can only be RL or RR)

Other

  • pPilHead - the head of the driver, which will 'bauble'.zzz
  • ProjShad - a cone shaped, unseen part that will be used tell TMU where to place the car's shadow on the road below the car, uses the Projshad.dds file.
  • LightFProj - a cone shaped part, which will not be visible in game, that is used to project a light on the road in front of the car, uses the default CarLights.dds file.


8 Helpers/Dummys with these names

  • LightFL1 and LightFR1 (front lights, left and right, big flare)
  • LightFL2 and LightFR2 (front lights, left and right, small flare1)
  • LightFL3 and LightFR3 (front lights, left and right, small flare2)
  • LightRL and LightRR (rear lights, left and right)

In Blender make these as normal objects but then delete all the vertices in Edit mode. If you use Empties instead my export script will fail.


Note that TMU really will be satisfied if it finds just one of these objects. Therefore this tutorial will explain how to produce a model which is just a cuboid called sBody, which should be enough to get you started.

The model must not be too big.

The model must fit within an imaginary box.

The model comprises faces, each defined by three vertices. Each vertex has co-ordinates in three dimensional space, ie (x,y,z) co-ordinates. For each vertex the following conditions must be met:

-1.5 < x < 1.5   
-3 < y < 3               
-0.2 <z < 2.5

The object's center must be at (0,0,0)

Well, it does if it is a main piece like sBody or dBody.

Certain parts of the model must be UV mapped

In game, Trackmania takes the model and wraps an image around it to produce the car you see. In fact, it wraps one image around some of the parts and another around other parts and so on. Images used in this way are called textures. The two most important textures are called Diffuse and Details. You will need to provide at least one of these images to TMU by producing a graphics file. The Diffuse texture will be applied by TMU to all parts named sxxx while Details will be applied to all parts named dxxx. Objects named gxxx will be shown as transparent in the game.

In the cars provided by Nadeo, you can paint on the sxxx parts in the editor but not the dxxx parts. I have not got the in game editor to let me paint my models yet.

In game, each face of the model is covered with just a part of a texture. (You may have expected to supply one texture for each face but that is not how things work.) TMU needs to be told which particular piece of the texture to apply to each face of the object. We use a process called UV mapping to tell TMU which part of each texture should be applied to each face of the model. Once UV mapping has been done, the 3ds file exported by Blender contains the model and the information which tells TMU which part of each texture to apply each face of the model.

Textures must be created.

The textures must be supplied to Trackmania as files of format .dds. dds is a format which can contain an image that has been compressed in one of several different ways. We need to produce ones which have been compressed using DXT5.

Create a 3d model using Blender which satisfies TMU's requirements.

We will create a simple cuboid because it is the simplest object to create and looks funny in the game.

Open Blender.

Blender automatically creates three objects: a cube, a camera and a lamp. You will see these in the main window called 3d View. To change your view of the objects in Blender's 3d view, hold down Alt while you left click somewhere within the upper window and move the mouse around. You should see the cube, the lamp (represented by a circle on a stick) and the camera (represented by pyramid on its side). You can zoom in and out with the mouse wheel. Try this now.


Cameras and lamps are special types of objects which relate to one of Blender's abilities: that of rendering the objects you create, which means it can show you what a viewer would see if the object was lit by lights you specify, taking into account lighting, shadows and reflections. Rendering is activated by pressing F12, which opens a new window, showing the view seen by someone positioned where the camera is. The lamp is a source of light: when Blender renders the objects you create you will see a black object unless there are lamps to act as light sources. Feel free to press F12 now; when you are finished just close that new window.

We will use the cube shaped object as the basis of our model, making only those changes needed to produce a working 3ds file.

Shrink the cube to fit within TMU's bounding box.

Click on View - Top to get a bird's eye view of things. You will see that the cube is two units wide and two units deep, which means its width and depth fit inside TMU's bound box.


Now click on View - Side to get a side-on view of things. You will see that the cube is two units tall, which is fine, but it extends from -1 to 1 vertically whereas TMU requires it to be within -0.2 to 2.5 vertically. Therefore we will move the cube upwards. However, we need to leave the object's centre point at (0,0,0), where the blue vertical line and green horizontal line cross. The centre point of an object is represented as a small pink square in the middle of the cube.


In side view select we need to have just the cube selected: with the mouse pointer in the top window, press the A key which toggles between all and no objects selected. When all objects are not pink, right click inside the cube: this will turn the cube pink: it is selected.Click on "Object mode" in the bottom bar of the upper window; this will change to "Edit mode"; now any changes we make will change the corners of the object without changing the location of its centre point. Now ensure that all corners of the cube are selected by pressing the A key until the edges and corners of the cube are yellow and the middle is pink . Hold down the Ctrl key (which will cause the cube to snap to the grid lines as we move it) then left click on the white circle near the centre of the cube and drag it up the screen until its bottom rests on the central, green horizontal line; ensuring it does not move sideways. Now use Alt + Left Mouse Button to take a look around.

In Blender, Object mode is for altering attributes of an entire object whereas edit mode is for altering individual vertices, edges etc.

Check where the object's centre is by pressing n while in Object mode and look in the Loc fields. If the object's centre has moved from 0,0,0 then set it back - click on the loc fields to change. Then reposition the mesh in edit mode.

Ensure your car faces in the direction of decreasing y values. In Blender's top view, the car should point down the screen.

Pressing t in object mode then selecting size brought up something like a bounding box which can be used to check all vertices are within the TMU limits. Undo this action (Ctrl+Z) after using it cos i do not know what it does.

Rename the cube

We will instruct TMU to consider our cube to be a part of the model which does not accept paint so we need to rename it as dBody. WIth the cube still selected (pink) and the pointer in the upper window, press N to bring up a little pop up window. In the top left corner is a field labelled OB holding the name of the object, currently "Cube". Left click here and change it to dBody and close the pop up by clicking on the cross at its top left. Note: we are only creating a part labelled dBody for this model so we will only need to create a Details.dds texture later. If we were creating a part whose name began with 's' we would need a Diffuse.dds texture.


Save the project as a blend file (Blender's native format).

We are not finished with it yet.


Create a UV mapping for the model.

In Blender, with your cube project open, be in Edit mode (TAB key should toggle between edit and object modes) and with the cube selected, go into UV Face Select mode by clicking on "Edit mode" and choosing UV Face Select from the list that pops up. In this mode, we choose which faces of the object we want Blender to create UV mapping information for. All faces of the cube should remain selected, ie pink. If not, press A until they are.

Now press the U key, which brings up a UV Calculation menu, which gives options as to how Blender should go about assigning each face to a part of the texture. Click on UV Unwrap Smart Projection, then click OK on the next box that appears without changing any options. This action generates the UV mapping information but does not present that new information in the current window. To see what we have done we need to change the upper window to be the UV Image Editor: click on the crosshatched button at the lower left corner of the upper window and choose UV Image Editor from the pop up list. You should see a black window with a grey rectangle in the middle, divided into smaller rectangles by pink dotted lines. Each small rectangle corresponds to a face of the cube and shows the part of the texture which will be applied to that face of the cube. The UV mapping has been done and when we export the model the UV mapping info will be bundled into the file. Remember, the 3ds file will not contain the texture itself, just the mapping data.

Blender can show you how the mapping you have generated will cause a texture to be applied to your object: You need a texture as a jpg or bmp file to do this. In The UV Image Editor view, click on Image in the tool bar at the bottom of the upper window and choose Open. Browse to your image file and click on Open. This will load the image. Then change back to Blender's 3d view to see the result. You may need to select Texture from the pop up list next to the one holding Object Mode, Edit Mode etc.

Save the project again as a blend and close Blender.


Export the model to a 3ds file.

Get the file 3ds_export_tmu.py as described in the Tools section.

Install this script by pasting it into Blender's scripts folder (mine is E:\Program Files\Blender Foundation\Blender\.blender\scripts)

Open Blender and open your project.

Select the object dBody by right clicking it.

Export it via File -> Export then "3ds for Trackmania". Give the file you are creating a name no longer than 8.3 because I read somewhere that applicationss expect 3ds files to have names within that limit.

Create the texture

(If you just want to see the model in TMU as soon as possible ignore this section, get hold of a details.dds file, eg from inside a skin zip file from trackmania-carpark.com and jump to section 5.)

We now need to create a texture which will look as we want when it is applied to the model. This is an art in itself, We can get Blender to help by producing a template which shows which part of each texture will be applied to each face of the model. With the object selected in UV Face select mode, enter UV/Image Editor view and click on UVs - Scripts - Save UV Face Layout. Then OK the next options box. This will cause a window to appear at the bottom of the screen where you can specify where the file is saved. Enter a name on the lower line and click on Save UV (tga). This saves the template as a tga file.

Load this template into your image editor and fill each rectangle with colour and save the file as a bmp file.

Run the program Dxtbmp, load your coloured in template bmp and save it as a dds file of type dxt5.

(Now we can have a look at how the model looks with the texture on it. In Blender with our project open in UV Image Editor screen open the bmp version (blender 2.45 is not compliant with dds files but the beta of 2.46 is) View the object in 3d view and change to Textured mode. This is not necessary but allows you to check how things will look easily.

Convert the 3ds file to a .gbx file.

Using the utility in Trackmania's splash screen's help screen. (Help -> Custom Data - Car Geometry and select your 3ds file). TMU will make a gbx file and give you a confusing message about renaming the file. Ignore the message. Then rename the gbx file as MainBodyHigh.Solid.Gbx. This is the 'high' detail version Copy the file and name it MainBody.Solid.Gbx This is the low detail version. Doing this will ensure you see your model in game, regardless of whether TMU is looking for a high or low detail version.

Bundle the files you made

Put the gbx files into a zip file with a sensible name along with at least the textures you made. ie if your model has dzzz parts then a Details.dds and if it has szzz parts then a diffuse.dds.

Place the zip file where TMU looks for such files.

In your my docs folder in /Trackmania/Skins/Vehicles/Carcommon/ (for Trackmania United Forever). You may need to create the Carcommon folder yourself.

Check your work

Run TMU and go to Profile, Vehicles. Select your zip file from the list of cars. Your model should appear.

Make a model worth racing.

You will need to improve the model, make interesting textures and improve your knowledge of how to create UV maps. I found the following useful.


References

  • The pdf called Import De Modeles 3d Guide Officiel at

http://www.trackmania-carpark.com/tutoriaux/Tuto_TMN_3D.zip has useful diagrams showing what the parts of the car are.

has other useful information but it is written mainly for users of 3d Studio Max.

Personal tools