Solidity

From Custom Mario Kart
Revision as of 16:11, 14 November 2011 by LBFlbf1 (talk | contribs)
Jump to navigation Jump to search

Introduction

The KCL file contains all the solidity info, as well as event triggers that trigger when touched by a vehicle, item, or object. For example, drivable roads are stored within KCL files, as well as fall boundaries that cause you to respawn (which should be triggered by falling off the track or into a hazard). Cannon triggers are also found here. More simply put, the BRRES model is just for sights while all the info about being able to touch stuff in-game is stored in the KCL file.

Collision Models

Benefits

File:CollisionImage-RegularCourseModel.jpg
A house on Rooster Island. This is the course_model version of the model, so the house is displayed in full detail. The flowerbeds are raised, which would normally collide with the player.
The house has been simplified in the collision model. The chimney, trim and upper windows have been deleted. The lower windows and door now have the same 'wall' texture as the sides of the house. A blue 'fall' texture has been applied to the to top; players will be respawned if they somehow get up there. The flowerbed has been lowered to the same level as the surrounding surfaces to allow driving through the flowerbed.

A separate collision model provides several potential benefits.

  • It can help prevent super short cuts and other glitches by putting in invisible walls and fall boundaries, or removing troublesome surfaces.
  • If your level has any complex geometry that can't or seldom will be touched by karts, this geometry can be deleted or simplified. This will reduce the likelihood of errors when that will prevent you from successfully creating a KCL.
  • You can use fewer textures when setting up your KCL, saving time.
  • In most games, simplifying collision can help prevent lag, FPS drops and other issues caused by the game making complex calculations when objects collide and replicating the results to players. It is likely this principle applies also applies to Mario Kart Wii.


Making a Collision Model

To create a collision model in Google SketchUp, first make a copy of your SketchUp file, making sure not to overwrite the old one. Change the textures within the new SketchUp file so that each texture represents a different solidity type and variant. You can right click any surface and Select all with Same Material then use the Paint Bucket to replace the texture. (Don't worry about the looks of your collision model. You will not be loading this file in-game, it will simply be used for KCL generation.) You can delete a lot of background geometry in your collision file, just set up simple polygons nearby with a texture you want to use for out-of-bounds or solid fall. Similarly, the upper parts of features that can be collided with, such as lamp posts, trees, and buildings, can be replaced with simpler polygons and assigned a "wall" texture. Explode all groups, components and curves before exporting. In the Materials Browser, textures that are considered to be in use will appear in the In Model section. Delete any textures that you have otherwise removed.

When using SketchUp, you should give textures descriptive names, similar to the solidity value you want to give them. This step isn't completely necessary, but can help you avoid confusion. To rename textures in SketchUp, open the Materials Browser and select the texture you want to change. Above the list of textures it will show the material's name. Simply type in a new one.

If you are using a different 3D editor, the principles are the same. If you are using 3DS Max you can rename polygons with ease, so it's recommended to name them to the values you want to give them, so that you won't have to write down or remember their names.

If your level has multiple drivable layers, move the tops of any walls that are directly below other drivable surfaces down slightly, at least 100 meters. This will prevent vehicles from striking an invisible boundary when driving on the surfaces above those walls. To create surfaces that can be moved through, such as clouds, water or small plants, simply delete the corresponding surfaces from your model.

Once you are done editing your collision model, export the OBJ as normal. Open the BRRES editor and import the file with the course_model option selected. Save the file with a name like course_model_solidity.brres. Import the BRRES into your SZS with SZS Explorer and save (you do not have to overwrite the normal course_model, but it is often easier to do so.) Open the SZS file in the SZS Modifier and follow the rest of this tutorial. Delete the collision model from your SZS or re-import the normal model after you're done generating the KCL.

Remember, if you make a change to any solid part in your main model, you will need to make a corresponding change in your collision model as well. To easily update your collision model, select all the faces and edges that you've changed in the course model file, copy, open the collision model, then select Paste in Place from the Edit Menu. Don't forget to delete the old surfaces you are replacing.

Generating a KCL

CTools

File:Soliditykh.png
Replacing the old course.kcl in the SZS Explorer component of CTools

Currently, KCL files created with the CTools KCL Editor are unusable as the road will be very bouncy if you use them, or the tool will otherwise fail in the creation process. MrBean35000vr believes the bounciness issue is caused by the grid generated being too small. You can use the CTools KCL Editor to create expanded KCL files, but you can't create a new KCL from scratch here; you will need to use the SZS Modifier's KCL Editor to patch an existing file with proper solidity. To access this editor, right click on your course.kcl in SZS Explorer, and choose "Open with" > "KCL Editor." You will need to import an OBJ file of your level to use this editor.

SZS Modifier

File:Solidity2kh.png
Generating a new course.kcl in SZS Modifier's KCL Editor

First you will need to import a large KCL file into your SZS. You can export the course.kcl from Maple Treeway (treehouse_course), take one that you generated with CTools, or use one from another custom track. Large KCL files are less likely to encounter a 'too complex' error. If you are using CTools to generate the initial KCL, add some extra geometry to your model (or use your normal course model if you have an optimized collision model) since SZS Modifier will typically generate a larger KCL than CTools but can not expand the KCL on its own. Replace the KCL in your SZS with this larger KCL.

Next, open your course_model.brres with SZS Modifier. If you have imported a separate collision model, open that BRRES file instead. Make sure that you're not opening the course.kcl in SZS Modifier, just the actual BRRES. There will be a message at the bottom left-hand corner of the screen that says Loading Textures. The model will then display, and you can use the zoom function to get a better look. On rare occasions there will be a message that says Parsing File. If it gets stuck on this message, reboot your computer.

Select Create KCL on the Tools Menu, and choose the solidity types you want for each texture. A list of solidity types and what they all do can be found in the KCL flags article. Once you have picked your solidity values, click OK and the program will begin patching the KCL file. You will typically get several error messages during this process. The first, with a yellow icon, "The KCL generation encountered a problem with one or more areas. These have been excluded from the KCL." is normal, and usually will not adversely impact your level. Click OK whenever this error pops up. If your KCL generation was successful, no more error messages will appear and the model will refresh in the preview screen. Don't forget to save your changes.

Your final error message might have a red x icon and read "There is not enough vertex space in the KCL for this operation. Space needed: XXXX." It is easy to miss this "not enough space" message and think that your level was patched, so keep an eye out for the red icon. There are a few different solutions to fixing this error. You can try excluding some textures when generating the KCL. Simply deselect (while holding CTRL) some textures in the right-hand pane that are not critical for your model, and run it again. This method is best used when testing your track in the early stages of your model. For a more permanent solution you will need to patch a larger KCL file, create a simplified collision model, or modify your collision model to have fewer faces.

Editing an Existing KCL

You can change solidity types without patching a KCL file. Open your SZS with SZS Modifier. Click on the course.kcl file. This will bring up the KCL editor window. Like before, refer to the KCL flags article to interpret solidity types.

What's Next?

Your level is almost ready to be driven on. The next step is to create a Minimap to find out where to position the player start, item boxes, enemy routes and other objects.