OBD:OTLF: Difference between revisions

From OniGalore
Jump to navigation Jump to search
No edit summary
m (duh; cel-shade doesn't need lightmapping)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Main Page]] >> [[OBD:Oni Binary Data|Oni Binary Data]] >> [[OBD:File types|File Types]] >> OTLF File
{{OBD_File_Header | type=OTLF | prev=OTIT | next=PLEA | name=Oct Tree Leaf Node Array | family=Level | align=center}}




<CENTER>[[OBD:OTIT|<==]] <FONT SIZE=5>OTLF File</FONT> [[OBD:PLEA|==>]]<BR>
[[image:otlf_a.gif]]
<FONT SIZE=2>Oct Tree Leaf Node Array - Level File</FONT></CENTER>




http://www6.fh-eberswalde.de/user/dkriesch/onistuff/images/otlf_a.gif
{{Table}}
 
{{OBDth}}
 
{{OBDtr| 0x00 | res_id  |FF0000| 01 45 02 00 | 581             | 00581-.OTLF }}
{| BORDER=1 WIDTH=100% CELLPADDING=2 CELLSPACING=0
{{OBDtr| 0x04 | lev_id  |FFFF00| 01 00 00 06 | 3               | level 3 }}
|- ALIGN=CENTER BGCOLOR="#FFDDBB"
{{OBDtr| 0x08 | char[20] |00FF00| AD DE       | dead             | unused }}
| WIDTH=15% | <B>Hex</B>
{{OBDtr| 0x1C | int32    |00FFFF| 03 49 00 00 | 18691           | array size }}
| WIDTH=15% | <B>Translation</B>
{{OBDtrBK}}
| WIDTH=70% | <B>Meaning</B>
{{OBDtr| 0x00 | int12-20 |FFC8C8| 00 00 00 00 | 0, 0             | bits 0-11 (12 bits) contain the number of gunk quads that intersect this leaf, bits 12-31 (20 bits) contain the index of the gunk quad list; see details below }}
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
{{OBDtr| 0x04 | int32hb  |FFFFC8| FF FF FF FF | -1               | negative x neighbour }}
| BGCOLOR="#FF0000" | 01 45 02 00
{{OBDtr| 0x08 | int32hb  |C8FFC8| 01 00 00 80 | 1, high bit     | positive x neighbour }}
| 581
{{OBDtr| 0x0C | int32hb  |C8FFFF| FF FF FF FF | -1               | negative y neighbour }}
| ALIGN=LEFT | 00581-.OTLF
{{OBDtr| 0x10 | int32hb  |FFC8FF| 02 00 00 80 | 2, high bit     | positive y neighbour }}
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
{{OBDtr| 0x14 | int32hb  |FFC800| FF FF FF FF | -1               | negative z neighbour }}
| BGCOLOR="#FFFF00" | 01 00 00 06
{{OBDtr| 0x18 | int32hb  |C800C8| 04 00 00 80 | 4, high bit     | positive z neighbour }}
| 3
{{OBDtr| 0x1C |int9-9-9-5|C87C64| 7F FE FC 39 | 127, 127, 127, 7 | bits 0-8 (9 bits) contain the index of max x, bits 9-17 (9 bits) contain the index of max y, bits 18-26 (9 bits) contain the index of max z and bits 27-31 (5 bits) contain the index of the size of this leaf; see details below }}
| ALIGN=LEFT | level 3
{{OBDtr| 0x20 | int8-24  |B0C3D4| 00 00 00 00 | 0, 0            | bits 0-7 (8 bits) intersected BNV count, bits 8-31 (24 bits) BNV list index; see details below }}
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#00FF00" | AD DE
| dead
| ALIGN=LEFT | not used
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#00FFFF" | 03 49 00 00
| 18691
| ALIGN=LEFT | 18691 packages follow (one package is edged in black)
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#000000"
| COLSPAN=3 | <FONT SIZE=2 COLOR="#FFFFFF">Below follows the first package.</FONT>
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#FFC8C8" | 00 00 00 00
| 0, 0
| ALIGN=LEFT | Bits 0-11 (12 bits) contain the number of gunk quads that intersect this leaf, bits 12-31 (20 bits) contain the index of the gunk quad list. See details below.
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#FFFFC8" | FF FF FF FF
| -1
| ALIGN=LEFT | negative x neighbour  
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#C8FFC8" | 01 00 00 80
| 1, high bit
| ALIGN=LEFT | positive x neighbour
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#C8FFFF" | FF FF FF FF
| -1
| ALIGN=LEFT | negative y neighbour
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#FFC8FF" | 02 00 00 80
| 2, high bit
| ALIGN=LEFT | positive y neighbour
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#FFC800" | FF FF FF FF
| -1
| ALIGN=LEFT | negative z neighbour
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#C800C8" | 04 00 00 80
| 4, high bit
| ALIGN=LEFT | positive z neighbour
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#C87C64" | 7F FE FC 39
| 7, 127, 127, 127
| ALIGN=LEFT | Bits 0-8 (9 bits) contain the index of max x, bits 9-17 (9 bits) contain the index of max y, bits 18-26 (9 bits) contain the index of max z and bits 27-31 (5 bits) contain the index of the size of this leaf. See details below.
|- ALIGN=CENTER VALIGN=TOP BGCOLOR="#FFEEDD"
| BGCOLOR="#B0C3D4" | 00 00 00 00
| 0
| ALIGN=LEFT | Bits 0-7 (8 bits) count of something, bits 8-31 (24 bits) index of something. See details below.
|}
|}


[[Image:Penny_Arcade_-_EvilCorp_Too.png|thumb|300px]]
;Intersected gunk quads
;Intersected gunk quads
:An octtree leaf (OTLF) stores its size and position and the gunk quads that intersect it. The first field contains an index/count pair that is used to access the first IDXA field that is stored in the [[OBD:AKOT|AKOT]] that owns this leaf. This IDXA contains the gunk quad numbers that intersect the leaf.
:An octtree leaf (OTLF) stores its size and position and the gunk quads that intersect it. The first field contains an index/count pair that is used to access the first [[OBD:IDXA|IDXA]] field that is stored in the [[OBD:AKOT|AKOT]] that owns this leaf. This [[OBD:IDXA|IDXA]] contains the gunk quad numbers that intersect the leaf. In theory there can be at most 4095 gunk quads that intersect a leaf but in practice this number is much lower (max is 462). In addition the threshold limit used to build the octree seems to be 19 gunk quads per leaf. I.e., in Oni's levels, only the smallest leaves (with size 16x16x16) have more than 19 quads; larger leaves containing 20 and more quads are subdivided into "other, smaller boxes".
:The last field also contains an index/count pair and that one is used to access the second IDXA field of AKOT but what this IDXA contains is currently unknown.
;Intersected BNVs
:An octtree leaf can intersect some BNVs (see [[OBD:AKVA|AKVA]]). The last field contains the index and count of this list in the second [[OBD:IDXA|IDXA]] field of [[OBD:AKOT|AKOT]].
;Position and size
;Position and size
:The position (of leaf's positive corner) is stored as three 9 bit fields. These values are not the x, y and z coordinates themselfs but they are indexes into a constant table. This constant table has 512 entries starting with -4080.0 and going up to 4096.0 in 16 units increments. The size of leaf is stored in a 5 bit field and it is and index into another constant table. This table has 9 entries starting with 16.0 and going up to 4096.0 (each entry is double the previous one). All this leads to the facts that the maximum environment size is (8192.0, 8192.0, 8192.0), the minimum coordinate is (-4096.0, -4096.0, -4096.0) and the maximum coordinate is (4096.0, 4096.0, 4096.0). The minimum leaf size is 16.0 and the maximum leaf size is 4096.0 (this means that there will always be at least 8 leafs because the size of the environment is double).
:The position (of leaf's positive corner) is stored as three 9 bit fields. These values are not the x, y and z coordinates themselves but they are indices into a constant table. This constant table has 512 entries starting with -4080.0 and going up to 4096.0 in 16 units increments.  
:The size of leaf is stored in a 5 bit field and it is and index into another constant table. This table has 9 entries starting with 16.0 and going up to 4096.0 (each entry is double the previous one).  
:*Maximum environment size is (8192.0, 8192.0, 8192.0)
:*Minimum coordinate is (-4096.0, -4096.0, -4096.0)  
:*Maximum coordinate is (4096.0, 4096.0, 4096.0)
:*Minimum leaf size is 16.0
:*Maximum leaf size is 4096.0 (this means that there will always be at least 8 leaves because the size of the environment is double).
;Neighbours
;Neighbours
:A leaf can have 6 neighbours (one for each face). If a face does not have a neighbour (it's on an environment border) then the coresponding field is -1. If a neighbour field value has its high bit set then the value (without the high bit) is the index of another octtree leaf (this is the case when when the neighbour leaf is equal to or larger than the leaf). If the high bit is not set then the value is an index into a quadtree node array (the [[OBD:QTNA|QTNA]] field of [[OBD:AKOT|AKOT]]) (this is the case when there is more than one leaf neighbour for a face).
:A leaf can have 6 neighbours (one for each face). If a face does not have a neighbour (it's on an environment border) then the coresponding field is -1. If a neighbour field value has its high bit set then the value (without the high bit) is the index of another octtree leaf (this is the case when when the neighbour leaf is equal to or larger than the leaf). If the high bit is not set then the value is an index into a quadtree node array (the [[OBD:QTNA|QTNA]] field of [[OBD:AKOT|AKOT]]) (this is the case when there is more than one leaf neighbour for a face).
;Example
;Example
:The above leaf does not intersect any quads, has its maximum corner at (-2048.0, -2048.0, -2048.0), a size of 2048.0, no neighbours for all negative faces (its right in the negative corner of the environment) and positive faces have leafs as neighbours (no quadtree nodes here).
:The above leaf does not intersect any quads, has its maximum corner at (-2048.0, -2048.0, -2048.0), a size of 2048.0, no neighbours for all negative faces (it's right in the negative corner of the environment) and positive faces have leaves as neighbours (no quadtree nodes here).
<HR>
;Theoretical limits
<CENTER>[[OBD:OTIT|<==]] <B>OTLF File</B> [[OBD:PLEA|==>]]</CENTER>
:If the environment (size 8192x8192x8192) is subdivided into minimal cubes (size 16x16x16) in all three directions, the total number of leaves is 512x512x512 = 134,217,728, and with a maximum of 4095 quads per leaf one could expect a theoretical maximum of 549,621,596,160 distinct quads per level. (Half a trillion quads, or a trillion triangles. That's ''crazy'' much.)
<HR>
:However, the maximum size of the AKOT's first IDXA that can be referenced through a leaf's 0x00 field is actually 1,052,670 (a combination of the 20-bit index to the start of a leaf's quad list and the 12-bit length of that list). Thus the maximum number of distinct quads in a level (properly referenced by oct-tree leaves) can not exceed 1,052,670, which is much more comfortable sanity-wise (two million triangles is fairly common for game environments nowadays).
:In practice, though, the engine imposes even more modest limitations:
:*only up to 8192 environment triangles are expected to be ''visible'' (rendered) at any given time (they can be packed as 4096 quads, or as 8192 actual triangles, or any combination of tris and quads).
:*:If you attempt to view more than 8192 triangles at once, Oni will ''not'' crash, but:
:*:*it will complain with the dev-console message "Exceeded max visible GQs #", where # is the number of ''triangles'' in excess of 8192;
:*:*it will start dropping random triangles from the rendering pipeline;
:*:*collision will start to fail on the "dropped" triangles.
:*:The amount of other visible geometry (characters, particles etc) does not affect this limit.
:*only up to 262140 triangles (e.g., as 131070 quads) are allowed in a level's environment. Attempting to load a level with 262141 environment triangles (as any combination of triangles and quads) will cause Oni to [[Blam]].
:*:(N.B. This has been identified as a bug that will be fixed in future versions, so that the theoretical maximum of 1,052,670 quads (2,105,340‬ triangles) can be reached: if you cut a level into "sections" ("rooms" or "scenes") where you can view no more than 8192 triangles at once, then basically you are allowed to have 256 such "sections" in a level. If you add an extra set of environment polygons for cel-shading and/or lightmapping, then the limit will be cut in 2 or 3.)
 


{{OBD_File_Footer | type=OTLF | prev=OTIT | next=PLEA | name=Oct Tree Leaf Node Array | family=Level}}


[[Main Page]] >> [[OBD:Oni Binary Data|Oni Binary Data]] >> [[OBD:File types|File Types]] >> OTLF File
{{OBD}}

Latest revision as of 08:49, 26 August 2022

ONI BINARY DATA
OTIT << Other file types >> PLEA
OTLF : Oct Tree Leaf Node Array
switch to XML:OTLF page
Overview @ Oni Stuff
OBD.png


Otlf a.gif


Offset Type Raw Hex Value Description
0x00 res_id 01 45 02 00 581 00581-.OTLF
0x04 lev_id 01 00 00 06 3 level 3
0x08 char[20] AD DE dead unused
0x1C int32 03 49 00 00 18691 array size
First element (black outline)
0x00 int12-20 00 00 00 00 0, 0 bits 0-11 (12 bits) contain the number of gunk quads that intersect this leaf, bits 12-31 (20 bits) contain the index of the gunk quad list; see details below
0x04 int32hb FF FF FF FF -1 negative x neighbour
0x08 int32hb 01 00 00 80 1, high bit positive x neighbour
0x0C int32hb FF FF FF FF -1 negative y neighbour
0x10 int32hb 02 00 00 80 2, high bit positive y neighbour
0x14 int32hb FF FF FF FF -1 negative z neighbour
0x18 int32hb 04 00 00 80 4, high bit positive z neighbour
0x1C int9-9-9-5 7F FE FC 39 127, 127, 127, 7 bits 0-8 (9 bits) contain the index of max x, bits 9-17 (9 bits) contain the index of max y, bits 18-26 (9 bits) contain the index of max z and bits 27-31 (5 bits) contain the index of the size of this leaf; see details below
0x20 int8-24 00 00 00 00 0, 0 bits 0-7 (8 bits) intersected BNV count, bits 8-31 (24 bits) BNV list index; see details below
Penny Arcade - EvilCorp Too.png
Intersected gunk quads
An octtree leaf (OTLF) stores its size and position and the gunk quads that intersect it. The first field contains an index/count pair that is used to access the first IDXA field that is stored in the AKOT that owns this leaf. This IDXA contains the gunk quad numbers that intersect the leaf. In theory there can be at most 4095 gunk quads that intersect a leaf but in practice this number is much lower (max is 462). In addition the threshold limit used to build the octree seems to be 19 gunk quads per leaf. I.e., in Oni's levels, only the smallest leaves (with size 16x16x16) have more than 19 quads; larger leaves containing 20 and more quads are subdivided into "other, smaller boxes".
Intersected BNVs
An octtree leaf can intersect some BNVs (see AKVA). The last field contains the index and count of this list in the second IDXA field of AKOT.
Position and size
The position (of leaf's positive corner) is stored as three 9 bit fields. These values are not the x, y and z coordinates themselves but they are indices into a constant table. This constant table has 512 entries starting with -4080.0 and going up to 4096.0 in 16 units increments.
The size of leaf is stored in a 5 bit field and it is and index into another constant table. This table has 9 entries starting with 16.0 and going up to 4096.0 (each entry is double the previous one).
  • Maximum environment size is (8192.0, 8192.0, 8192.0)
  • Minimum coordinate is (-4096.0, -4096.0, -4096.0)
  • Maximum coordinate is (4096.0, 4096.0, 4096.0)
  • Minimum leaf size is 16.0
  • Maximum leaf size is 4096.0 (this means that there will always be at least 8 leaves because the size of the environment is double).
Neighbours
A leaf can have 6 neighbours (one for each face). If a face does not have a neighbour (it's on an environment border) then the coresponding field is -1. If a neighbour field value has its high bit set then the value (without the high bit) is the index of another octtree leaf (this is the case when when the neighbour leaf is equal to or larger than the leaf). If the high bit is not set then the value is an index into a quadtree node array (the QTNA field of AKOT) (this is the case when there is more than one leaf neighbour for a face).
Example
The above leaf does not intersect any quads, has its maximum corner at (-2048.0, -2048.0, -2048.0), a size of 2048.0, no neighbours for all negative faces (it's right in the negative corner of the environment) and positive faces have leaves as neighbours (no quadtree nodes here).
Theoretical limits
If the environment (size 8192x8192x8192) is subdivided into minimal cubes (size 16x16x16) in all three directions, the total number of leaves is 512x512x512 = 134,217,728, and with a maximum of 4095 quads per leaf one could expect a theoretical maximum of 549,621,596,160 distinct quads per level. (Half a trillion quads, or a trillion triangles. That's crazy much.)
However, the maximum size of the AKOT's first IDXA that can be referenced through a leaf's 0x00 field is actually 1,052,670 (a combination of the 20-bit index to the start of a leaf's quad list and the 12-bit length of that list). Thus the maximum number of distinct quads in a level (properly referenced by oct-tree leaves) can not exceed 1,052,670, which is much more comfortable sanity-wise (two million triangles is fairly common for game environments nowadays).
In practice, though, the engine imposes even more modest limitations:
  • only up to 8192 environment triangles are expected to be visible (rendered) at any given time (they can be packed as 4096 quads, or as 8192 actual triangles, or any combination of tris and quads).
    If you attempt to view more than 8192 triangles at once, Oni will not crash, but:
    • it will complain with the dev-console message "Exceeded max visible GQs #", where # is the number of triangles in excess of 8192;
    • it will start dropping random triangles from the rendering pipeline;
    • collision will start to fail on the "dropped" triangles.
    The amount of other visible geometry (characters, particles etc) does not affect this limit.
  • only up to 262140 triangles (e.g., as 131070 quads) are allowed in a level's environment. Attempting to load a level with 262141 environment triangles (as any combination of triangles and quads) will cause Oni to Blam.
    (N.B. This has been identified as a bug that will be fixed in future versions, so that the theoretical maximum of 1,052,670 quads (2,105,340‬ triangles) can be reached: if you cut a level into "sections" ("rooms" or "scenes") where you can view no more than 8192 triangles at once, then basically you are allowed to have 256 such "sections" in a level. If you add an extra set of environment polygons for cel-shading and/or lightmapping, then the limit will be cut in 2 or 3.)


ONI BINARY DATA
OTIT << Other file types >> PLEA
OTLF : Oct Tree Leaf Node Array
Level file