User Tools

Site Tools


kirby64_the_crystal_shards:level_settings_blocks

This is an old revision of the document!


Level Settings Block

Every Area has its own Level Settings Block defined inside the Main Stage Table (see: Levels). The level settings block defines the camera, collision, and entities spawned inside the stage. The Basic Structure of the Level Settings Block is as follows.

Level Settings Layout

  1. Main Header
  2. Vertices (s16 triplets)
  3. Triangles (20 bytes each)
  4. Surface Normals
  5. Triangle Groups/Cells
  6. Surface Normals Groups/Cells
  7. Unkown Floats (possibly for star blocks/breakable geo)
  8. Unk halfs (possibly for star blocks/breakable geo)
  9. Unk halfs 2 (mostly zeroes, ends with 9999)
  10. Unk halfs 3 (Breaking star blocks?)
  11. Collision Header (referred to by Header[0])
  12. Camera Defines of some sort (referred to by Header[1])
  13. Entity List (referred to by Header[2])

Main Header

The main header contains references to the three main sections of the level settings block: Collision, Camera and the Entity List.

struct Main_Header{
   0x00: u32 Pointer to Collision Header
   0x04: u32 Pointer to Camera Header
   0x08: u32 Pointer to Entity IDs
   }

Collision

Collision is handled by several different lists that combine to create the level geometry.

Vertices

Vertices are made up of unsorted s16 tripets of x, y and z position.

Triangles

Triangles are made by connecting 3 vertices referenced by their index. (e.g. 0,1,2 is made up of vertices 0,1 and 2 in the list). Every Triangle has a struct that has additional parameters telling the game how to handle collision.

struct Triangle{
0x0:	u16	Vertex[2]
0x6:	u16	Quads #not sure
0x8:	u16	Collision_Type_1 #(1 forward norm, 2 back norm, 4 no shadow, 8 non solid/warp related?)
0xA:	u16	Destructable Group Index
0xC:	u16	Break_Particle #(seen in DEDEDE hammer break)
0xE:	u16	Halt_Movement #warp related? Maybe dest (kirby cant move while on top of this if 1)
0x10:	s16	Col_Param1 #Amount to move kirby while on certain col types or Break Condition
0x12:	u16	Collision_Type_2 #see col type list
}

The following is a list of Collision_Type_2 values known.

  • 0x1 - wall ladder
  • 0x2 - rope
  • 0x3 - death floor
  • 0x4 - Platform you can jump through/Fall Through
  • 0x8 - warp
  • 0x9 - STAR BLOCK/Breakable Blocks
  • 0xD - Breakable Ceiling/Breaks when launched through
  • 0x10 - DEDEDE hammer break
  • 0x12 - move kirby backwards while on top
  • 0x13 - move kirby forwards while on top
  • 0x14 - Platform with custom movement (seems to be in some sort of object list separate from normal level geometry)

Triangle Normals

Triangle normals are stored as a F32 array of 4 values. The first three values are the surface normals while the last is the origin offset. Together the normals should solve the plane equation (see:link).

The list of normals always starts with (-1,-2,-3,-4) and this is used to refer to walls. The actual value of the first set of normal is not known to have any significance. Redundant normals are not repeated, but are just referenced multiple times (e.g. two triangles with norm Y==1 and offset==0 share their normal).

Triangle Groups

The triangle groups is a pre-sorted list that references each triangle by its index. The triangle group list begins with a flag of 0x8192 and ends with 0x9999. The triangle group starts searching for the right triangle starting at the bottom, and keeps going until it finds the right triangle, or it finds an index with the MSB set.

There should be an equal amount of items in the triangle list and triangle group list.

Normal Groups

The normal groups is a list that matches each normal to a triangle. It is formed in pairs with the first item being the index of the normal, and the second item being the index of the triangle.

Normal groups are sorted by level H-Position. Only floors & ceilings are referenced by the normal groups, walls are given the first index of the normals list (-1,-2,-3,-4).

Destructable groups

comes in three u16s 1- Number of times it loops in list 2- Index inside Dustructable indices list (0x30 in col header) 3- Unk Index

Destructable indices list

Each Index is a half that points to the triangle that is being destroyed.

Basic idea is that 0x2C contains the index inside the tri index list and length/num of triangles being deleted. Then in 0x30, there is a list of all the triangles that get destroyed.

The destructable group to reference is found from 0xA in the Tri Struct

Collision Header

The collision header is referred to by the first index inside the main header. The collision header has the following format.

struct Collision_Header{
	0x0: Triangles Offset
	0x4: Number of Triangles
	0x8: Vertices offset
	0xC: Number of Vertices
	0x10: Triangle Normals $3 Norms, then a NegDot/offset from origin.
	0x14: Number of Norms #processed by 0x80101400
	0x18: Triangle Groups (cells) Offset #processed by 0x80102570?
	0x1C: Number of Triangle Groups
	0x20: Triangle Norms Cells #processed by 0x80101400. Sorted by H position.
	0x24: Number Tri Norm Cells #Sorted by H position.
	0x28: Size of Unk
	0x2C: Destructable_Groups
	0x30: Destructable Indices
	0x34: Optional Param
	0x38: Optional Param
	0x3C: Optional Param
	0x40: Optional Param
}

Camera

The camera is referred to by the second index in the main header.

kirby64_the_crystal_shards/level_settings_blocks.1580075215.txt.gz · Last modified: 2020/01/26 21:46 by jesusyoshi54