<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wexosmk.xyz/index.php?action=history&amp;feed=atom&amp;title=KCL_%28File_Format%29%2FWii_U</id>
	<title>KCL (File Format)/Wii U - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wexosmk.xyz/index.php?action=history&amp;feed=atom&amp;title=KCL_%28File_Format%29%2FWii_U"/>
	<link rel="alternate" type="text/html" href="https://wiki.wexosmk.xyz/index.php?title=KCL_(File_Format)/Wii_U&amp;action=history"/>
	<updated>2026-05-06T17:56:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.wexosmk.xyz/index.php?title=KCL_(File_Format)/Wii_U&amp;diff=370&amp;oldid=prev</id>
		<title>Wexos: New file name of prism figure</title>
		<link rel="alternate" type="text/html" href="https://wiki.wexosmk.xyz/index.php?title=KCL_(File_Format)/Wii_U&amp;diff=370&amp;oldid=prev"/>
		<updated>2024-05-01T20:18:53Z</updated>

		<summary type="html">&lt;p&gt;New file name of prism figure&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:18, 1 May 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l106&quot;&gt;Line 106:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 106:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;KCL Prism Description&lt;/del&gt;.png|400px|thumb|left|A collision prism.]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Kcl-prism-description&lt;/ins&gt;.png|400px|thumb|left|A collision prism.]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wexos_wiki:diff:1.41:old-216:rev-370:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Wexos</name></author>
	</entry>
	<entry>
		<id>https://wiki.wexosmk.xyz/index.php?title=KCL_(File_Format)/Wii_U&amp;diff=216&amp;oldid=prev</id>
		<title>Wexos: Imported from avsys wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.wexosmk.xyz/index.php?title=KCL_(File_Format)/Wii_U&amp;diff=216&amp;oldid=prev"/>
		<updated>2024-05-01T17:37:11Z</updated>

		<summary type="html">&lt;p&gt;Imported from avsys wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;KCL&amp;#039;&amp;#039;&amp;#039; files are collision files, which is the model the game runs collision against. KCL files has been used since at least [[Mario Kart DS]], but this documentation is about the format used in [[Wii U]] and [[Nintendo Switch]]. For other formats, see [[KCL (File Format)]].&lt;br /&gt;
&lt;br /&gt;
KCL stores prisms, a triangle with a depth, in a format which allows fast access and collision calculation, and has an octree which splits the world space into many sub spaces, to make the game test collision on less prisms, which allows for much faster collision detection.&lt;br /&gt;
&lt;br /&gt;
= File Format =&lt;br /&gt;
== Header ==&lt;br /&gt;
The file begins with the following header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Offset !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00 || Byte[4] || &amp;#039;&amp;#039;&amp;#039;Version number&amp;#039;&amp;#039;&amp;#039;. Always 2.2.0.0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Division Info|Division info]] offset&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Model|Model]] offset table offset&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || UInt32 || &amp;#039;&amp;#039;&amp;#039;Number of [[#Model|models]]&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || Float[3] || &amp;#039;&amp;#039;&amp;#039;Minimal coordinate&amp;#039;&amp;#039;&amp;#039; for all [[#Model|models]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || Float[3] || &amp;#039;&amp;#039;&amp;#039;Maximal coordinate&amp;#039;&amp;#039;&amp;#039; for all [[#Model|models]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || Int32[3] || &amp;#039;&amp;#039;&amp;#039;Area width shift&amp;#039;&amp;#039;&amp;#039;. Defines the size of the space where collision data is stored.&lt;br /&gt;
|-&lt;br /&gt;
| 0x34 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Total number of [[#Prism|prisms]]&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Division Info ===&lt;br /&gt;
The collision files of [[Mario Kart 8]] actually hold multiple [[#Model|models]] in the format of those found in [[Mario Kart Wii]]. This was required because one of such models can only hold a maximum of 16384 prisms, because each prism requires four normal vectors, and it can only link to 65536 normals.&lt;br /&gt;
&lt;br /&gt;
Instead of increasing the size used to store a prism index, multiple such models are stored, of which each represents the prisms available in one, or multiple, cubes of the whole course space. To divide the course space into such cubes referencing the models, a new global division follows the header. It works similar to the [[#Octree|octree]] of one of such models, but instead of looking up prisms, models are looked up with it.&lt;br /&gt;
&lt;br /&gt;
The division info consists of at least 8 integers, representing the division keys of the 8 cubes the course space is initially divided into. Depending on the flags set in the upper two bits of the key, either the remainder points to an index of a model in the model array which data will be used for this cube, divides the cube further into 8 subcubes, or denotes no data being available in this cube.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Set Flags (0-based) !! Remaining Data !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Model Index || [[#Model|Model]] index which is part of this space.&lt;br /&gt;
|-&lt;br /&gt;
| 31 &amp;amp; 30 || Unused (being 0) || No model is used for this cube, as no data is present in this part of space.&lt;br /&gt;
|-&lt;br /&gt;
| else || Child Nodes Offset || Divides this cube into 8 more subcubes. The value is an offset, which is multiplied by 4 to get the actual offset, relative to the start of the current node.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Model ==&lt;br /&gt;
Each model in the file has a format almost identical to KCL files in [[Mario Kart Wii]]. The model consists of a header, and four data sections. The header is a 0x3C byte structure as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Offset !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00 || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Vertex Position|Vertex position]] offset&amp;#039;&amp;#039;&amp;#039;, relative to the start of this structure.&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Normals|Normal]] offset&amp;#039;&amp;#039;&amp;#039;, relative to the start of this structure.&lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Prisms|Prism]] offset&amp;#039;&amp;#039;&amp;#039;, relative to the start of this structure.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || UInt32 || &amp;#039;&amp;#039;&amp;#039;[[#Octree|Octree]] offset&amp;#039;&amp;#039;&amp;#039;, relative to the start of this structure.&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || Float || &amp;#039;&amp;#039;&amp;#039;Prism thickness&amp;#039;&amp;#039;&amp;#039;. Defines the depth of the prisms created by the triangles.&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || Float[3] || &amp;#039;&amp;#039;&amp;#039;Minimum coordinates of this model&amp;#039;&amp;#039;&amp;#039;, which also is the [[#Octree|octree]] origin&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || UInt32 || &amp;#039;&amp;#039;&amp;#039;X width mask&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Y width mask&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Z width mask&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || UInt32 || &amp;#039;&amp;#039;&amp;#039;Block width shift&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Blocks X shift&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x34 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Blocks XY shift&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x38 || Float|| {{Unknown-left|&amp;#039;&amp;#039;&amp;#039;Sphere radius&amp;#039;&amp;#039;&amp;#039;. Unknown usage.}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Vertex Position ===&lt;br /&gt;
This section is an array of vertex positions, each represents as three floats, X, Y and Z. The number of elements is not stored.&lt;br /&gt;
&lt;br /&gt;
=== Normals ===&lt;br /&gt;
This section is an array of normals, each represents as three floats, X, Y and Z. The number of elements is not stored.&lt;br /&gt;
&lt;br /&gt;
=== Prisms ===&lt;br /&gt;
The third section is the section containing the actual model information. The structure of each entry in this section is a 0x14 byte structure given below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Offset !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00 || Float || &amp;#039;&amp;#039;&amp;#039;Triangle height&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || UInt16 || The index of the &amp;#039;&amp;#039;&amp;#039;base vertex position&amp;#039;&amp;#039;&amp;#039; into the [[#Vertex Positions|vertex array]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || UInt16 || The index of the &amp;#039;&amp;#039;&amp;#039;triangle normal&amp;#039;&amp;#039;&amp;#039; into the [[#Normals|normal array]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || UInt16 || The index of the &amp;#039;&amp;#039;&amp;#039;prism side A normal&amp;#039;&amp;#039;&amp;#039; into the [[#Normals|normal array]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || UInt16 || The index of the &amp;#039;&amp;#039;&amp;#039;prism side B normal&amp;#039;&amp;#039;&amp;#039; into the [[#Normals|normal array]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || UInt16 || The index of the &amp;#039;&amp;#039;&amp;#039;prism side C normal&amp;#039;&amp;#039;&amp;#039; into the [[#Normals|normal array]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || UInt16 || &amp;#039;&amp;#039;&amp;#039;Collision attribute&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Global prism index&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[File:KCL Prism Description.png|400px|thumb|left|A collision prism.]]&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below contains the calculation needed to convert three vertices into the needed values. This method assumes the vertices are arranged anti-clockwise when viewed from the collidable side.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Position = Vertex1&lt;br /&gt;
Direction = Normalize(Cross(Vertex2 - Vertex1, Vertex3 - Vertex1 ))&lt;br /&gt;
DirectionA = Normalize(Cross(Normal, Vertex3 - Vertex1 ))&lt;br /&gt;
DirectionB = Normalize(-Cross(Normal, Vertex2 - Vertex1 ))&lt;br /&gt;
DirectionC = Normalize(Cross(Normal, Vertex2 - Vertex3 ))&lt;br /&gt;
Length = Dot(Vertex2 - Vertex1, DirectionC )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Octree ===&lt;br /&gt;
The octree subdivides the world space into cubes, to allow much faster prism collision detection. The number of root [[#Node|nodes]] can be calculated by the following algorithm:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NrRootNodes = (MaskWidthX &amp;gt;&amp;gt; BlockWidthShift + 1) * (~MaskWidthY &amp;gt;&amp;gt; BlockWidthShift + 1) * (~MaskWidthZ &amp;gt;&amp;gt; BlockWidthShift + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then the number of root nodes are written to the file. These nodes link to more nodes or prism lists.&lt;br /&gt;
&lt;br /&gt;
==== Node ====&lt;br /&gt;
Each node has the following structure:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Offset !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00 || UInt32 || &amp;#039;&amp;#039;&amp;#039;Flag&amp;#039;&amp;#039;&amp;#039;: &amp;#039;&amp;#039;&amp;#039;ABBB BBBB BBBB BBBB BBBB BBBB BBBB BBBB&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;A&amp;#039;&amp;#039;&amp;#039;: 1 means it&amp;#039;s a leaf. See below.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;B&amp;#039;&amp;#039;&amp;#039;: Offset to next structure, relative to the parent node, or start of octree data if the node is a root node.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the node is a leaf, then it means it isn&amp;#039;t subdivided anymore and it contains a prism list. This prism  list is terminated by 0xFFFF, and contains indices of the [[#Prisms|prisms]] that are present in this subspace. If it&amp;#039;s not a leaf, then this node is subdivided into 8 more nodes, which the offset into the structure links to.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
The following tools can handle KCL files:&lt;br /&gt;
* [[Wexos&amp;#039;s Toolbox]], by [[Wexos]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Switch File Formats]]&lt;br /&gt;
[[Category:Wii U File Formats]]&lt;/div&gt;</summary>
		<author><name>Wexos</name></author>
	</entry>
</feed>