New kart tutorial 2
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. Also see 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 doing any work, it is essential to know that any STK content (and eventual content used to make it) must be licensed with an acceptable open 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.
It is important to note that some weapons like the swatter attach themselves on the back part of the kart, so it is important to make sure that this area can receive equipment.
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.
Alternatively, you can always consult the current face count of your project using Blender's "Info" panel
By default Blender displays the sum of all the faces from the active scene (only active layers will be taken in count): "Fa" stands for faces and "Ob" stands for the current number of elements placed at the 3D scene, if you enter in "Edit Mode" (TAB key) the counter will be displaying the number of faces of the shape you are currently editing, while no necessary it is recommended to work with "tri faces" until no further modeling is needed.
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, a good trick is making these details part of the vehicle's texture. 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, also remember to apply any rotation and/or scale to your meshes for better results.
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.
When preparing the mesh and armature make sure they both have a rotation of (0,0,0) to avoid problems. We're working on resolving these issues but for now please bear with limitations of the exporter.
If you need to fix an already rigged model, it's not too late, you can do the following : reset the rotation on the armature to (0,0,0), unparent the mesh from the armature (select Keep transformation), invoke apply rotation on the mesh, reparent the mesh and armature.
Objects in Blender scene
Ideally, the kart has its own mesh, the character another independent mesh, and each wheel another additional mesh object. Assign the wheels their type in the property panel :
Note that karts can have (up to) 4 wheels. Wheels that are on the front are considered steering wheels and will automatically rotate as you steer in-game. The wheel's origin in Blender is used by SuperTuxKart for the wheel movement, an incorrectly placed "origin" can cause the wheel improper movement, also you might want to make test for aesthetic purposes, mostly to fix the point from where the wheel steers.
The collision is calculated only for the vehicle mesh (assuming the character never go outside the kart), if your vehicle features big wheels is most likely these will go through other vehicles and track objects like walls or guard rails, even over fences some times so be sure to make enough tests if your vehicle has to have big wheels, like in the case of monster trucks. Contrary case, try no to make your vehicle's chassis too low, as the car would find problems with irregular terrain.
Every object in your blender scene will be exported by STK's kart exporter except :
- objects where type ignore is selected in the property panel
At this time, STK supports UV texturing (with one texture only by face [addendum: STK 0.8 supports normal maps and shadow maps]) and vertex colors. 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. 256x256, 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 vertex 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.
The current STK Blender plugin features a custom panel to directly edit the attributes of the textures to be used by the current project, Under the section Super Tux Kart Image Properties panel you can find an extensive explanation about each properties, note that for Karts you won't be needing to edit or watch over all the properties.
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.
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.
Note : the duration of 'left steer' and 'right steer' does not matter since in-game the frame will move between the markers depending on how much the kart steers; for animations like winning or losing, however, the duration of the animation in blender is directly related to its duration once exported to STK.
Note : we currently only support skeletal animations for karts. Therefore, you cannot animate a kart object by moving it around and assigning keyframes; instead you need to attach it to a bone inside the kart mesh
You can specify two nitro emitters. They must be set on empty objects; the nitro particles will be emitted from this location.
Icon & shadow
The last things an STK kart needs are an icon and a shadow image.
The icon should be a 128x128 or 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.
To see how you kart looks in STK, you need to export it using the STK kart exporter.
After setting up blender as described in Installing the tools, locate the SuperTuxKart panel :
Check the is a SuperTuxKart kart checkbox, then fill the information asked for. When you have configured the kart, press the Export button in the Kart Exporter panel
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!