Havok: Difference between revisions

3,066 bytes added ,  5 years ago
Add description for data sections / pointer sections
imported>Zephenryus
m (→‎Header: Updated headings to be more consistent)
imported>HailToDodongo
(Add description for data sections / pointer sections)
Line 63: Line 63:


==== hkrb ====
==== hkrb ====
{{Empty section}}
{{Empty section}}Used in actors.


==== hkcl ====
==== hkcl ====
Line 72: Line 72:


==== hksc ====
==== hksc ====
{{Empty section}}
{{Empty section}}Used in shrines and the field sections.


==== hktmrb ====
==== hktmrb ====
Line 279: Line 279:


=== Relative Offsets ===
=== Relative Offsets ===
The relative offsets point to different large structures within the section. There are usually a few unique offsets and then multiple duplicated offsets. It is unknown if only unique offsets are significant at this time.
The relative offsets point to different large structures within the section.


For example, given the following section header:
For example, given the following section header:
Line 287: Line 287:
00 00 3C 10 00 00 3C 20 00 00 3C 20 00 00 3C 20 | ..<...< ..< ..<  
00 00 3C 10 00 00 3C 20 00 00 3C 20 00 00 3C 20 | ..<...< ..< ..<  
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF | ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF | ................
</syntaxhighlight>The section name is <code>__data__</code>. The absolute offset is <code>0x160</code> with the relative offsets
</syntaxhighlight>The section name is <code>__data__</code>.  
 
The absolute offset is the beginning of the data section, right after the class names.


* <code>0x3c00</code>
This following tables shows to which sections the offsets are pointing:
* <code>0x3c10</code>
{| class="wikitable"
* <code>0x3c10</code>
|+Data Header Specification
* <code>0x3c20</code>
!Offset (h)
* <code>0x3c20</code>
!Size
* <code>0x3c20</code>
!Data Type
!Description / Section
|-
|<code>0x00</code>
|20
|String
|Section name
|-
|<code>0x14</code>
|4
|Unsigned Int
|Beginning of data section
|-
|<code>0x18</code>
|4
|Unsigned Int
|Pointer - Data Pointer
|-
|<code>0x1c</code>
|4
|Unsigned Int
|Pointer - Linked Entries
|-
|<code>0x20</code>
|4
|Unsigned Int
|Pointer - Class Mapping
|-
|<code>0x24</code>
|4
|Unsigned Int
|EOF
|-
|<code>0x28</code>
|4
|Unsigned Int
|EOF
|-
|<code>0x2c</code>
|4
|Unsigned Int
|EOF
|}
<br />


== Class Names Section ==
== Class Names Section ==
Line 329: Line 374:


== Data Section ==
== Data Section ==
[[File:Havok-data-structure.png|thumb|390x390px|Data structure]]
=== Data ===
The bulk of the file is devoted to the data section which is divided into smaller segments dependent on the file type.
All files follow a general structure as you can see in the picture.
Right after the header begins the data section which contains multiple chunks, luckily, the four first chunks are always the same.
After that, the several more chunks can be found depending on the file.
=== Pointer ===
The next section, at the end of the file, contains three different pointer arrays.
It is used to connect the whole file together, and should be used as an entry point while reading the file.
The offsets to these three sections can be found in the header.
==== Data Pointer ====
An array of offsets relative to the beginning of the data section, pointing into various chunks.
Which offsets ends up in this list, depends completely on the chunks used in the data section.
However, since the first four classes are always the same, the first 14 offsets will be the constant.
[[File:Havok data pointer.png|none|thumb|Data Pointer]]
<br />
==== Linked Entries ====
Contains pointer-pairs to connect chunks together.
Each pair has the following format:
{| class="wikitable"
|+Pointer Pair
!Offset (h)
!Size
!Type
!Name
!Description
|-
|0x00
|4
|Unsigned Int
|base
|Offset somewhere in the parent chunk
|-
|0x04
|4
|Unsigned Int
|flags
|Unknown (always <code>0x00000002)</code>
|-
|0x08
|4
|Unsigned Int
|target
|Target chunk (always beginning of the chunk)
|}
To connect a chunk with another, a base pointer somewhere inside the base-chunk (depending on the class/type) is used as the first pointer.
Then, the target pointer is the offset of the beginning of the target chunk.
[[File:Havok pointer linked.png|none|thumb|Linked Entries]]
<br />
==== Class Mapping ====
The last section contains the mapping between the chunks and the classes they are using.
They, again, use pointer pairs:
{| class="wikitable"
|+Class Mapping Pointer
!Offset (h)
!Size
!Type
!Name
!Description
|-
|0x00
|4
|Unsigned Int
|data
|Offset to the start of an chunk, relative to data-section
|-
|0x04
|4
|Unsigned Int
|flags
|Unknown (always <code>0x00000000)</code>
|-
|0x08
|4
|Unsigned Int
|class
|Offset to the class name, relative to class-section
|}
To link a chunk to a class, the data pointer is set to the beginning of the chunk.
The class pointer is set to the first character of the class name found in the header section.
[[File:Havok class mapping.png|none|thumb|Class Mapping]]
This also marks the end of the file, if the offset is not aligned to 16 bytes, the rest is filled with <code>0xFF</code>.
== Data Classes ==
{{Expand section}}
{{Expand section}}
The bulk of the file is devoted to the data section which is divided into smaller segments dependent on the file type.
All known class that chunks can used are listed here:
<br />
<references />
<references />
[[Category:File formats]]
[[Category:File formats]]