# HOWTO create a car for Ultimate Stunts

This includes the following steps:

- Make a 3D model
- Convert the file format
- Modifications with ustunts3dedit
- The car's physics settings

# Make a 3D model

You can make your 3D model with any 3D modelling program that has export capabilities to usual formats like 3DS. Note that it is not always possible to preserve things like color and textures during the conversion process to Ultimate Stunts: this is only possible if you can export to formats that are supported directly by ustunts3dedit, like 3DS and LWO.

The scale is not really important because everything gets scaled in a later stage, but if you want to know it: the basic unit in Ultimate Stunts is meter. It is more important to exactly align your model with the coordinate axes.

Ultimate Stunts can currently only use one texture file per car, so remember to put the textures of every part into the same image file.

# Convert the file format

Export your models to a format that is supported by either ustunts3dedit or the 3dto3d utility. The first option is preferred; ustunts3dedit currently supports 3DS and LWO files. If you have the 3dto3d conversion program, then you can convert the file to the "smoothed raw" format, and import that in Ultimate Stunts. Note that in this process, colors and texture coordinates are not preserved.

    3dto3d /if1 /of1 /dbody.raw body.3ds

Copy the file that needs to be imported to the root or a subdirectory of the Ultimate Stunts data tree.

# Modifications with ustunts3dedit

### Load the file

(Please first learn how to use the ustunts3dedit program!) Start the ustunts3dedit program. Load the file that you prepared with the Load function (shift-F). Answer 'n' to the question if you want to add it as a LOD to the existing scene, then choose the right file format and give the filename. The given filename must be relative to the ultimatestunts data directory (that's why you had to place the file somewhere in this directory).

If the importing was succesful, then you can save your temporary result with the Save (f) function. You can do this every time to make a backup of your temporary work. The .glt file format is useful for this, because it has a higher precision than the .glb format. You need to save as .glb as soon as you want to use a finished model in Ultimate Stunts.

### Scale the model

If you followed everything so far, then you've succesfully loaded your file. The model's size is probably not right, so scale it around the origin with a size of 5 (key 's'). Alternatively, if you want to apply an exact scale factor, Do a 'rotation' ('r'), and give these answers (example: scale factor 0.5):

    Rotate entire scene: y
    Rotate around x: n
    Rotate around y: n
    Rotate around z: n
    Give new x axis: 0.5,0,0
    Give new y axis: 0,0.5,0
    Give new z axis: 0,0,0.5

Now you should be able to see and check your model.

### Set the correct orientation

The correct orientation for the body is: nose towards negative z direction, top towards positive y direction. If you would sit in a car, then you would have the default openGL orientation: x to the right, y upwards, z backwards. This is also the camera orientation of ustunts3dedit at startup, so you might want to restart ustunts3dedit to get re-oriented.

After you've read the previous lines for a couple of times, and made some drawings to understand it, you can check if your model has the right orientation. This is probably not the case, as 3D modellers usually have the z axis pointing upwards. Rotate your body ('r') to get it right, and save it.

### Translate your model

It is useful for tuning the car to have the center of gravity of the model at the origin of the car model. So you need to translate ('t') your model in such a way that the origin lies where you want the CG. Don't confuse this CG with the term CG that is sometimes used in ustunts3dedit: here I mean the physical CG in Ultimate Stunts' physics simulation, while ustunts3dedit uses a pseudo-CG for some operations, which is the mean of the vertex positions.

Since version 0.6.1, the CG of a car can be set to a position that does not equal the body model origin, so this operation is not really necessary. However, it is necessary to have the origin in the middle between the left wheel and the right wheel.

### Set the right scale

If you are not sure if the current scale is correct, then you can scale your model now. With the autoscale function ('s') you can set the size of the model. For the size you can enter the length of the car. You must always use the largest size of the model, so if you have an exotic car that is more high than long, then you have to enter the height.

### Set the colors

You can set color, opacity and reflectance on a per primitive basis. First select the primitive ('p') , then change ('C'). If texture coordinates are not lost in the conversion process, then you can also assign a texture to a primitive in this process. If you have a nice result, don't forget to save.

### Split up into body and wheels

As soon as the model looks like how you want it in the game, you can split it up into a body model and wheel models. To make the body model, delete all primitives that make up the wheels, and save the rest (don't forget to use a different filename, or else the model with wheels will be lost). To make the wheel model, delete all primitives that do not belong to a wheel. The result should be one of the left wheels. If the front and rear wheels are different, then you should create one model for each, else you only need one wheel model.

As an alternative to deleting primitives, you can open a .glt file in a text editor, and delete everything that belongs to other primitives. This is useful when there are a lot of primitives in a car model. Please read the .glt file format definition for more information.

A wheel model is supposed to have its origin at its rotation axes, so you need to translate it. If possible, remember or write down the translations that you do. These will help you to place the wheels back into the right position when tuning the car.

### Primitive order

[TODO]

### Collision model

For car body and wheels, the collision model cannot be equal to the graphical model. So for all graphical primitives you need to exclude the "c" from the LODs, and you need to add primitives for the collision model. This is not easy to explain (maybe you can read the ustunts3dedit documentation). You can have a look at the existing cars to have an idea of what is expected.

An easy way to add collision planes, is to add the file cars/generic/bodycollision.glb as a LOD (the c LOD) to the car. Then, apply the collision primitive function ('l') to this primitive, so that it fits your model. You can do the same thing for the wheel model and cars/generic/wheelcollision.glb, but here you also need to scale the planes so that their top and bottom vertices are on the outer side of the tire. They are used for calculating the radius of the wheels.

### LODs

[TODO]

# The car's physics settings

After you've saved your finished .glb files somwhere in the ultimatestunts data directory (a separate directory for your car would be good), you can make the physics settings file. A .conf file from an existing car can act as a starting point: just make a copy of it. You can change it with a text editor. The first thing to change is the location of the .glb files for the body and the wheels: fill in the location of your own files. Now you can already test it with Ultimate Stunts.

The first thing you may want to change is the position of the wheels. Once this position is fixed for your car, you can already drive it. After that you can fine-tune the physical properties of your car. You could enter the values of the real-world car, if you have them. After playing a while with the settings, you'll notice that it's not easy to make a "supercar". For example, a lower mass will increase acceleration, but it will also lower the force on the wheels, which makes them go slipping more easily.

#