Revision as of 23:46, 20 October 2017
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. 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. 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 Add-Ons 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 Legacy:Style Guidelines 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
When modeling for video games, the polygon count means the triangle counts. The model of a kart for STK should not have more than 18 000 triangles (character and wheels included). Ideally it should be between 6 000 and 12 000 but all vehicles are differents and not exactly karts. A vehicle which is a kart and cartoon-like should be about 3 000 triangles. When modeling, always try to aim the old requiments (about 6 000 triangles). In the future, STK will support LOD, so a lower definition model (so lower polygon count) would also be very appreciated. For your work to be accepted by the team, you have to know that we can be flexible according to vehicle and character kind, but if the polygon count is excessive compared to your vehicle design it won't be accepted.
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 tris 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.
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 wheel-steerings 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 geometry's 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 Materials 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.
- Jumping animation: markers start-jump and end-jump.
- Backpedal animation: markers backpedal-left, backpedal and backpedal-right.
- Kart selection screen animation: markers selection-start and selection-end.
- Other parts with loop animation (like Xue's hovercraft's propeller and Adiumy's key): Make it a separate object and STK will play it with variable speed in a loop.
Meshes must be animated with skeletal animations, using blender's armatures. STK supports multiples animated objects (one armature by distinct animated mesh) since the 0.7.1 version.
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.
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.
Currently you must have two nitro emitters even if you want keep one. If not, your empty is ignored and a default nitro emitter is set. Just duplicate the existing one at the same position.
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. 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 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!