New kart tutorial
This page is outdated. Please see New_kart_tutorial_2 for the latest tutorial.
This page explains how to make a kart for STK using Blender. It assumes you know the basics of modeling, UV texturing and skeletal animations in Blender, and concentrates on aspects that are specific to SuperTuxKart. It is based upon the previous tutorials Making kart tutorial and Making karts for Irrlicht, the Guidelines for making karts and characters, and the general Style Guidelines which you can also consult for more details. See the Kart resources index page for other resources about karts.
See the Kart export checklist for a short list that sums up every important point to know in this page, and make sure everything is OK before exporting a kart with STK's kart exporter.
See the Blender resources page for a list of tutorial links to learn how to use Blender (2.4).
Important note : Before any work, it is essential to know that any STK content (and eventual content used to make it) must strictly be of an acceptable license (see Licensing).
Character and kart design
All of STK's characters are open-source mascots, therefore if you want to add a kart to STK you must satisfy this constraint. You can find a list of the most known open-source mascots here (try to find all of STK's characters :p). Be careful that you do not choose one which is already involved in some work in progress, or present in the add-on pack of STK. You can check it out on the forum, and the addons website.
Once you have chosen your mascot, you need a kart design for it. If you wish it to be included in the official game package, you must design it so it fits well with the game atmosphere and is credible. See Style Guidelines and Guidelines for making karts and characters to know more about STK's design requirements. Remember that the most seen part of the karts by players is the back so this is a part that should be polished.
Mesh & vertex count
The model of a kart for STK should not have more than 3000 triangles, eg. 2000 for the vehicle, wheels included, and 1000 for the character (note that this limitation is not respected by every current STK kart, as some need to be improved). It makes 1500 faces if every face is a quad, ideally this would be around 1300. You can consult some old statistics about models here. In the future, STK will support LOD, so a low poly model (500 to 900 faces) would also be very appreciated.
To know roughly the number of triangles of your mesh, you can temporarily convert your faces to triangles with Ctrl+T on Blender, or view the exported kart (see #Exporting karts to learn how to export a kart) in the selection screen of STK, with the "Show FPS" option checked -- wait a little to have a "Ktris" value.
During the modeling phase, remember that the kart is made to be seen from medium and far distances, but not very close distances, so detailing it a lot may be useless as some details would only be visible in rare and precise situations. Also, it is way harder (and boring) trying to decrease the poly count of an existing high poly model than designing and modeling a low poly kart from the beginning, so it is worth keeping the poly number in mind.
Before the kart export, mesh modifiers need to be applied, as they won't be taken in consideration in the game.
STK's karts dimensions are approximately between 0.7x0.4 and 0.9x0.5 openGL units, so you may first choose a same ranged dimension. Then, ingame tests will be required to adjust it. Note that currently, kart physics depends on the dimensions of the models, but this will change when karts will have individual physics attributes.
Before being exported, the kart must be located as if the Y-axis was the road, and have a 0 X and Z translation (this last part may not be required, but this is cleaner like this ;). Also, when you hit Numpad 1 in Blender, you should see the back of the kart. The final model's rotation must be 0, and its scale 1 in object mode.
Objects in Blender scene
Ideally, the kart has its own mesh, the character another independent mesh, and each wheel another additional mesh object. The wheels must be given the game-logic property 'type="wheel"'. The old way to declare them is also possible : objects name has to be "FrontWheel.L" to "RearWheel.R".
Every object in your blender scene will be exported by STK's kart exporter except :
- objects tagged with a game-logic property "type" with the value "ignore".
At this time, STK supports UV texturing (with one texture only by face) and material color. All other options set in blender's material panel will be ignored.
To meet OpenGL requirements, the UV textures files must have power of two dimensions (e.g. 128x256, or 512x512). Note that here again, as this model purpose is a real-time use, textures size should not be unnecessarily too large. In general, 512x512 textures are large enough, and increasing the resolution does not change a lot the final ingame render.
The JPEG format is one of the most efficient in terms of compression, so although some existing textures are in png, the jpg is the best format for the game (if you use jpeg, please keep the original lossless file!). If you need a part of your model to be transparent, or have specific properties, you can assign it a specific texture file (a tiny image is OK for a single color) or a material color, then create a custom materials.xml file -- that you will have to include later in the kart game folder with models and textures. Note that the material.xml file is used by STK, but not by Blender.
STK's karts can be animated. The current karts animations in STK are :
- Steering, left and right : Specify the frames with markers named "left", "straight" and "right".
- Winning animation, specified with the "start-winning", "start-winning-loop", and "end-winning" named markers. The frames between start-winning and start-winning-loop are played once, then the frames between start-winning-loop and end-winning are looped.
- Losing animation : as the winning animation : "start-losing", "start-losing-loop" and "end-losing".
New animations and markers will surely be added in future versions of STK, they might be :
- Explosion : "start-explosion", "end-explosion",
- Character selection screen animation,
You can also make them, but they won't be used for the moment (and might be not used at all).
Meshes must be animated with skeletal animations, using blender's armatures. Note that STK will only be able to play animations if the armature is the parent object of the animated mesh in the Blender scene (you might have to remove the "armature" modifier if you used it, otherwise transformations can be applied twice to the mesh). STK supports multiples animated objects (one armature by distinct animated mesh) since the 0.7.1 version.
Also, make sure every bone of your armature has a 0 roll, otherwise ingame animation will look pretty weird.
Icon & shadow
The last things an STK kart needs are an icon and a shadow image.
The icon should be a 64x64 png image, and should have the same design than the other STK karts icons (most of them are from WorMux, adapted by yeKcim (FR)). A smaller version (for instance 32x32) may also be specified to be used in the in-game minimap (if you don't provide the smaller version, the 64x64 one is resized down, which may look less good than an icon crafted to be smaller).
The shadow image is a png image which is applied on the ground under the karts. To be credible, it must correspond to the kart shape, otherwise the kart will seem to float above the ground. Here is a little method to get quick and fast a nice shadow : Kart shadow tutorial.
Once everything is ready, or just to see a work in progress version of the kart ingame, you need to export it using the STK kart exporter. To do so :
- Copy from your STK folder (the STK version for which you want to export the kart) the two following files, and paste them in your kart model folder (or anywhere you want) :
- Drag-down the upper dock of Blender, and in the "File Path" tab, click on the folder icon of the "Python Scripts :" field, and select the folder in which you pasted the two previous .py files. Then click on the window icon near the folder icon of the "Python Scripts :" field to update your Blender GUI.
- Click on File>Export>STK Kart Exporter to display the exporter GUI. Just fill in the fields, knowing that the "color" labeled one is used to specify the color that will be displayed around the icon. The custom sounds are not used currently. Validate with the "Export" button, wait for a couple of seconds, until the "Successful" message appears under your cursor. More info about the generated xml file here.
- In your kart model folder, some files have been created : kart.xml, <kartname>.b3d, wheel-front-left.b3d to wheel-rear-right.b3d. Copy them, with the shadow file, the icons files, every texture used by the models, and eventually your custom materials.xml file. Paste all these files in <yourSTKinstallFolder>/Resources/data/karts/<yourKartName>, without any subfolders (even if there was some when you ran the exporter).
- Restart STK, drive your kart :)
If you have remarks or feedback about this tutorial, don't hesitate to post them on the forum, and if you see any mistakes please tell, or even correct them !