Difference between revisions of "Solidity"

From Custom Mario Kart
Jump to navigation Jump to search
Line 37: Line 37:
 
==Generating a KCL==
 
==Generating a KCL==
 
==== Wiimms SZS Tools ====
 
==== Wiimms SZS Tools ====
Currently, the best method to create KCL is to use the '''wkclt''' tool of [[Wiimms SZS Tools]]. It creates aN OPTIMIZED KCL file directly from the exported OBJ file and does not need any other. It's also possible to export the KCL or to write small scripts to modify positions or the KCL flags in an algorithmic way.
+
Currently, the best method to create KCL is to use the '''wkclt''' tool of [[Wiimms SZS Tools]]. It creates an optimized KCL file directly from the exported OBJ file and does not need any other. It's also possible to export the KCL or to write small scripts to modify positions or the KCL flags in an algorithmic way.
  
 
Details → [[KCL Tutorial (Wiimms Tools)]]
 
Details → [[KCL Tutorial (Wiimms Tools)]]

Revision as of 00:12, 4 July 2016

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. This tutorial covers the how to create a collision model and how to generate a KCL file.

Collision Models

Benefits

File:CollisionImage-RegularCourseModel.jpg
A house on the Rooster Island model. This is the regular version of the model, so the house is displayed in full detail.
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. To enable driving through the flowerbed, the flower surface has been lowered.

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.
  • You can fix problems like hitting edges that are below roads.
  • 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 that will prevent you from successfully generating a KCL.
  • You can use fewer textures when setting up your KCL, saving time.
  • 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.


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.)

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. (Tip: It's a good idea to change texture names before making the collision file.) It can be helpful to change the colors of textures on your collision model so you can easily identify each type of collision surface. This can be done easily by double-clicking any texture in the Materials Browser window, then adjusting the color options for that texture. To reset a texture's color, simply click reset color.

You can delete a lot of background geometry in your collision file. You can set up simple polygons nearby with a texture you want to use for out-of-bounds or solid fall so that players will respawn before hitting the deleted surfaces. Similarly, the upper parts of features that can be collided with, such as lamp posts, trees, and buildings, can be replaced with simpler surfaces and assigned a "wall" texture. 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.

If you are using a different 3D editor, the principles are the same. If you are using 3DS Max you can rename polygons, so it's recommended to give them descriptive names as well.

Easy methods to lower edges.

If your level has any walls that are directly underneath or bordering other drivable surfaces, you'll need to move the top edges of those surfaces downward at least 100 meters. This will prevent vehicles from striking an invisible boundary when driving on the surfaces above those walls. Click the image to the right for some tips.

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. Don't forget to explode all groups, and components before exporting. 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 the same change in your collision model too. To quickly update your collision model in SketchUp, 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. Delete the old surfaces you are replacing. If you have edited textures on your collision model, reset them before pasting, or apply the changed textures to the newly added surfaces.

Generating a KCL

Wiimms SZS Tools

Currently, the best method to create KCL is to use the wkclt tool of Wiimms SZS Tools. It creates an optimized KCL file directly from the exported OBJ file and does not need any other. It's also possible to export the KCL or to write small scripts to modify positions or the KCL flags in an algorithmic way.

Details → KCL Tutorial (Wiimms Tools)

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, 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 Koopa Cape (water_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 the editor becomes 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.