binary_serialization_api.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. .. _doc_binary_serialization_api:
  2. Binary serialization API
  3. ========================
  4. Introduction
  5. ------------
  6. Godot has a simple serialization API based on Variant. It's used for
  7. converting data types to an array of bytes efficiently. This API is used
  8. in the functions ``get_var`` and ``store_var`` of :ref:`class_File`
  9. as well as the packet APIs for :ref:`class_PacketPeer`. This format
  10. is *not* used for binary scenes and resources.
  11. Packet specification
  12. --------------------
  13. The packet is designed to be always padded to 4 bytes. All values are
  14. little-endian-encoded. All packets have a 4-byte header representing an
  15. integer, specifying the type of data:
  16. +--------+--------------------------+
  17. | Type | Value |
  18. +========+==========================+
  19. | 0 | null |
  20. +--------+--------------------------+
  21. | 1 | bool |
  22. +--------+--------------------------+
  23. | 2 | integer |
  24. +--------+--------------------------+
  25. | 3 | float |
  26. +--------+--------------------------+
  27. | 4 | string |
  28. +--------+--------------------------+
  29. | 5 | vector2 |
  30. +--------+--------------------------+
  31. | 6 | rect2 |
  32. +--------+--------------------------+
  33. | 7 | vector3 |
  34. +--------+--------------------------+
  35. | 8 | transform2d |
  36. +--------+--------------------------+
  37. | 9 | plane |
  38. +--------+--------------------------+
  39. | 10 | quat |
  40. +--------+--------------------------+
  41. | 11 | aabb |
  42. +--------+--------------------------+
  43. | 12 | basis |
  44. +--------+--------------------------+
  45. | 13 | transform |
  46. +--------+--------------------------+
  47. | 14 | color |
  48. +--------+--------------------------+
  49. | 15 | node path |
  50. +--------+--------------------------+
  51. | 16 | rid |
  52. +--------+--------------------------+
  53. | 17 | object |
  54. +--------+--------------------------+
  55. | 18 | dictionary |
  56. +--------+--------------------------+
  57. | 19 | array |
  58. +--------+--------------------------+
  59. | 20 | raw array |
  60. +--------+--------------------------+
  61. | 21 | int32 array |
  62. +--------+--------------------------+
  63. | 22 | int64 array |
  64. +--------+--------------------------+
  65. | 23 | float32 array |
  66. +--------+--------------------------+
  67. | 24 | float64 array |
  68. +--------+--------------------------+
  69. | 25 | string array |
  70. +--------+--------------------------+
  71. | 26 | vector2 array |
  72. +--------+--------------------------+
  73. | 27 | vector3 array |
  74. +--------+--------------------------+
  75. | 28 | color array |
  76. +--------+--------------------------+
  77. | 29 | max |
  78. +--------+--------------------------+
  79. Following this is the actual packet contents, which varies for each type of
  80. packet. Note that this assumes Godot is compiled with single-precision floats,
  81. which is the default. If Godot was compiled with double-precision floats, the
  82. length of "Float" fields within data structures should be 8, and the offset
  83. should be ``(offset - 4) * 2 + 4``. The "float" type itself always uses double
  84. precision.
  85. 0: null
  86. ~~~~~~~
  87. 1: :ref:`bool<class_bool>`
  88. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. +----------+-------+-----------+---------------------------+
  90. | Offset | Len | Type | Description |
  91. +==========+=======+===========+===========================+
  92. | 4 | 4 | Integer | 0 for False, 1 for True |
  93. +----------+-------+-----------+---------------------------+
  94. 2: :ref:`int<class_int>`
  95. ~~~~~~~~~~~~~~~~~~~~~~~~
  96. +----------+-------+-----------+--------------------------+
  97. | Offset | Len | Type | Description |
  98. +==========+=======+===========+==========================+
  99. | 4 | 8 | Integer | 64-bit signed integer |
  100. +----------+-------+-----------+--------------------------+
  101. 3: :ref:`float<class_float>`
  102. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103. +----------+-------+---------+-----------------------------------+
  104. | Offset | Len | Type | Description |
  105. +==========+=======+=========+===================================+
  106. | 4 | 8 | Float | IEEE 754 double-precision float |
  107. +----------+-------+---------+-----------------------------------+
  108. 4: :ref:`String<class_string>`
  109. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110. +----------+-------+-----------+----------------------------+
  111. | Offset | Len | Type | Description |
  112. +==========+=======+===========+============================+
  113. | 4 | 4 | Integer | String length (in bytes) |
  114. +----------+-------+-----------+----------------------------+
  115. | 8 | X | Bytes | UTF-8 encoded string |
  116. +----------+-------+-----------+----------------------------+
  117. This field is padded to 4 bytes.
  118. 5: :ref:`Vector2<class_vector2>`
  119. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  120. +----------+-------+---------+----------------+
  121. | Offset | Len | Type | Description |
  122. +==========+=======+=========+================+
  123. | 4 | 4 | Float | X coordinate |
  124. +----------+-------+---------+----------------+
  125. | 8 | 4 | Float | Y coordinate |
  126. +----------+-------+---------+----------------+
  127. 6: :ref:`Rect2<class_rect2>`
  128. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  129. +----------+-------+---------+----------------+
  130. | Offset | Len | Type | Description |
  131. +==========+=======+=========+================+
  132. | 4 | 4 | Float | X coordinate |
  133. +----------+-------+---------+----------------+
  134. | 8 | 4 | Float | Y coordinate |
  135. +----------+-------+---------+----------------+
  136. | 12 | 4 | Float | X size |
  137. +----------+-------+---------+----------------+
  138. | 16 | 4 | Float | Y size |
  139. +----------+-------+---------+----------------+
  140. 7: :ref:`Vector3<class_vector3>`
  141. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. +----------+-------+---------+----------------+
  143. | Offset | Len | Type | Description |
  144. +==========+=======+=========+================+
  145. | 4 | 4 | Float | X coordinate |
  146. +----------+-------+---------+----------------+
  147. | 8 | 4 | Float | Y coordinate |
  148. +----------+-------+---------+----------------+
  149. | 12 | 4 | Float | Z coordinate |
  150. +----------+-------+---------+----------------+
  151. 8: :ref:`Transform2D<class_transform2d>`
  152. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. +----------+-------+---------+---------------------------------------------------------------+
  154. | Offset | Len | Type | Description |
  155. +==========+=======+=========+===============================================================+
  156. | 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
  157. +----------+-------+---------+---------------------------------------------------------------+
  158. | 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
  159. +----------+-------+---------+---------------------------------------------------------------+
  160. | 12 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
  161. +----------+-------+---------+---------------------------------------------------------------+
  162. | 16 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
  163. +----------+-------+---------+---------------------------------------------------------------+
  164. | 20 | 4 | Float | The X component of the origin vector, accessed via [2][0] |
  165. +----------+-------+---------+---------------------------------------------------------------+
  166. | 24 | 4 | Float | The Y component of the origin vector, accessed via [2][1] |
  167. +----------+-------+---------+---------------------------------------------------------------+
  168. 9: :ref:`Plane<class_plane>`
  169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. +----------+-------+---------+---------------+
  171. | Offset | Len | Type | Description |
  172. +==========+=======+=========+===============+
  173. | 4 | 4 | Float | Normal X |
  174. +----------+-------+---------+---------------+
  175. | 8 | 4 | Float | Normal Y |
  176. +----------+-------+---------+---------------+
  177. | 12 | 4 | Float | Normal Z |
  178. +----------+-------+---------+---------------+
  179. | 16 | 4 | Float | Distance |
  180. +----------+-------+---------+---------------+
  181. 10: :ref:`Quat<class_quat>`
  182. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  183. +----------+-------+---------+---------------+
  184. | Offset | Len | Type | Description |
  185. +==========+=======+=========+===============+
  186. | 4 | 4 | Float | Imaginary X |
  187. +----------+-------+---------+---------------+
  188. | 8 | 4 | Float | Imaginary Y |
  189. +----------+-------+---------+---------------+
  190. | 12 | 4 | Float | Imaginary Z |
  191. +----------+-------+---------+---------------+
  192. | 16 | 4 | Float | Real W |
  193. +----------+-------+---------+---------------+
  194. 11: :ref:`AABB<class_aabb>`
  195. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196. +----------+-------+---------+----------------+
  197. | Offset | Len | Type | Description |
  198. +==========+=======+=========+================+
  199. | 4 | 4 | Float | X coordinate |
  200. +----------+-------+---------+----------------+
  201. | 8 | 4 | Float | Y coordinate |
  202. +----------+-------+---------+----------------+
  203. | 12 | 4 | Float | Z coordinate |
  204. +----------+-------+---------+----------------+
  205. | 16 | 4 | Float | X size |
  206. +----------+-------+---------+----------------+
  207. | 20 | 4 | Float | Y size |
  208. +----------+-------+---------+----------------+
  209. | 24 | 4 | Float | Z size |
  210. +----------+-------+---------+----------------+
  211. 12: :ref:`Basis<class_basis>`
  212. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213. +----------+-------+---------+---------------------------------------------------------------+
  214. | Offset | Len | Type | Description |
  215. +==========+=======+=========+===============================================================+
  216. | 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
  217. +----------+-------+---------+---------------------------------------------------------------+
  218. | 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
  219. +----------+-------+---------+---------------------------------------------------------------+
  220. | 12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] |
  221. +----------+-------+---------+---------------------------------------------------------------+
  222. | 16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
  223. +----------+-------+---------+---------------------------------------------------------------+
  224. | 20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
  225. +----------+-------+---------+---------------------------------------------------------------+
  226. | 24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] |
  227. +----------+-------+---------+---------------------------------------------------------------+
  228. | 28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] |
  229. +----------+-------+---------+---------------------------------------------------------------+
  230. | 32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] |
  231. +----------+-------+---------+---------------------------------------------------------------+
  232. | 36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] |
  233. +----------+-------+---------+---------------------------------------------------------------+
  234. 13: :ref:`Transform<class_transform>`
  235. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  236. +----------+-------+---------+---------------------------------------------------------------+
  237. | Offset | Len | Type | Description |
  238. +==========+=======+=========+===============================================================+
  239. | 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] |
  240. +----------+-------+---------+---------------------------------------------------------------+
  241. | 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] |
  242. +----------+-------+---------+---------------------------------------------------------------+
  243. | 12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] |
  244. +----------+-------+---------+---------------------------------------------------------------+
  245. | 16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] |
  246. +----------+-------+---------+---------------------------------------------------------------+
  247. | 20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] |
  248. +----------+-------+---------+---------------------------------------------------------------+
  249. | 24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] |
  250. +----------+-------+---------+---------------------------------------------------------------+
  251. | 28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] |
  252. +----------+-------+---------+---------------------------------------------------------------+
  253. | 32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] |
  254. +----------+-------+---------+---------------------------------------------------------------+
  255. | 36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] |
  256. +----------+-------+---------+---------------------------------------------------------------+
  257. | 40 | 4 | Float | The X component of the origin vector, accessed via [3][0] |
  258. +----------+-------+---------+---------------------------------------------------------------+
  259. | 44 | 4 | Float | The Y component of the origin vector, accessed via [3][1] |
  260. +----------+-------+---------+---------------------------------------------------------------+
  261. | 48 | 4 | Float | The Z component of the origin vector, accessed via [3][2] |
  262. +----------+-------+---------+---------------------------------------------------------------+
  263. 14: :ref:`Color<class_color>`
  264. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  265. +----------+-------+---------+--------------------------------------------------------------+
  266. | Offset | Len | Type | Description |
  267. +==========+=======+=========+==============================================================+
  268. | 4 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) |
  269. +----------+-------+---------+--------------------------------------------------------------+
  270. | 8 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) |
  271. +----------+-------+---------+--------------------------------------------------------------+
  272. | 12 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) |
  273. +----------+-------+---------+--------------------------------------------------------------+
  274. | 16 | 4 | Float | Alpha (0..1) |
  275. +----------+-------+---------+--------------------------------------------------------------+
  276. 15: :ref:`NodePath<class_nodepath>`
  277. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  278. +----------+-------+-----------+-----------------------------------------------------------------------------------------+
  279. | Offset | Len | Type | Description |
  280. +==========+=======+===========+=========================================================================================+
  281. | 4 | 4 | Integer | String length, or new format (val&0x80000000!=0 and NameCount=val&0x7FFFFFFF) |
  282. +----------+-------+-----------+-----------------------------------------------------------------------------------------+
  283. For old format:
  284. ^^^^^^^^^^^^^^^
  285. +----------+-------+---------+------------------------+
  286. | Offset | Len | Type | Description |
  287. +==========+=======+=========+========================+
  288. | 8 | X | Bytes | UTF-8 encoded string |
  289. +----------+-------+---------+------------------------+
  290. Padded to 4 bytes.
  291. For new format:
  292. ^^^^^^^^^^^^^^^
  293. +----------+-------+-----------+-------------------------------------+
  294. | Offset | Len | Type | Description |
  295. +==========+=======+===========+=====================================+
  296. | 4 | 4 | Integer | Sub-name count |
  297. +----------+-------+-----------+-------------------------------------+
  298. | 8 | 4 | Integer | Flags (absolute: val&1 != 0 ) |
  299. +----------+-------+-----------+-------------------------------------+
  300. For each Name and Sub-Name
  301. +----------+-------+-----------+------------------------+
  302. | Offset | Len | Type | Description |
  303. +==========+=======+===========+========================+
  304. | X+0 | 4 | Integer | String length |
  305. +----------+-------+-----------+------------------------+
  306. | X+4 | X | Bytes | UTF-8 encoded string |
  307. +----------+-------+-----------+------------------------+
  308. Every name string is padded to 4 bytes.
  309. 16: :ref:`RID<class_rid>` (unsupported)
  310. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  311. 17: :ref:`Object<class_object>` (unsupported)
  312. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  313. 18: :ref:`Dictionary<class_dictionary>`
  314. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315. +----------+-------+-----------+---------------------------------------------------------------------+
  316. | Offset | Len | Type | Description |
  317. +==========+=======+===========+=====================================================================+
  318. | 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) |
  319. +----------+-------+-----------+---------------------------------------------------------------------+
  320. Then what follows is, for amount of "elements", pairs of key and value,
  321. one after the other, using this same format.
  322. 19: :ref:`Array<class_array>`
  323. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  324. +----------+-------+-----------+---------------------------------------------------------------------+
  325. | Offset | Len | Type | Description |
  326. +==========+=======+===========+=====================================================================+
  327. | 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) |
  328. +----------+-------+-----------+---------------------------------------------------------------------+
  329. Then what follows is, for amount of "elements", values one after the
  330. other, using this same format.
  331. 20: :ref:`PackedByteArray<class_PackedByteArray>`
  332. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333. +---------------+-------+-----------+------------------------+
  334. | Offset | Len | Type | Description |
  335. +===============+=======+===========+========================+
  336. | 4 | 4 | Integer | Array length (Bytes) |
  337. +---------------+-------+-----------+------------------------+
  338. | 8..8+length | 1 | Byte | Byte (0..255) |
  339. +---------------+-------+-----------+------------------------+
  340. The array data is padded to 4 bytes.
  341. 21: :ref:`PackedInt32Array<class_PackedInt32Array>`
  342. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  343. +------------------+-------+-----------+---------------------------+
  344. | Offset | Len | Type | Description |
  345. +==================+=======+===========+===========================+
  346. | 4 | 4 | Integer | Array length (Integers) |
  347. +------------------+-------+-----------+---------------------------+
  348. | 8..8+length\*4 | 4 | Integer | 32-bit signed integer |
  349. +------------------+-------+-----------+---------------------------+
  350. 22: :ref:`PackedInt64Array<class_PackedInt64Array>`
  351. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352. +------------------+-------+-----------+---------------------------+
  353. | Offset | Len | Type | Description |
  354. +==================+=======+===========+===========================+
  355. | 4 | 8 | Integer | Array length (Integers) |
  356. +------------------+-------+-----------+---------------------------+
  357. | 8..8+length\*8 | 8 | Integer | 64-bit signed integer |
  358. +------------------+-------+-----------+---------------------------+
  359. 23: :ref:`PackedFloat32Array<class_PackedFloat32Array>`
  360. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  361. +------------------+-------+-----------+-------------------------------------------+
  362. | Offset | Len | Type | Description |
  363. +==================+=======+===========+===========================================+
  364. | 4 | 4 | Integer | Array length (Floats) |
  365. +------------------+-------+-----------+-------------------------------------------+
  366. | 8..8+length\*4 | 4 | Integer | 32-bit IEEE 754 single-precision float |
  367. +------------------+-------+-----------+-------------------------------------------+
  368. 24: :ref:`PackedFloat64Array<class_PackedFloat64Array>`
  369. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  370. +------------------+-------+-----------+-------------------------------------------+
  371. | Offset | Len | Type | Description |
  372. +==================+=======+===========+===========================================+
  373. | 4 | 4 | Integer | Array length (Floats) |
  374. +------------------+-------+-----------+-------------------------------------------+
  375. | 8..8+length\*8 | 8 | Integer | 64-bit IEEE 754 double-precision float |
  376. +------------------+-------+-----------+-------------------------------------------+
  377. 25: :ref:`PackedStringArray<class_PackedStringArray>`
  378. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  379. +----------+-------+-----------+--------------------------+
  380. | Offset | Len | Type | Description |
  381. +==========+=======+===========+==========================+
  382. | 4 | 4 | Integer | Array length (Strings) |
  383. +----------+-------+-----------+--------------------------+
  384. For each String:
  385. +----------+-------+-----------+------------------------+
  386. | Offset | Len | Type | Description |
  387. +==========+=======+===========+========================+
  388. | X+0 | 4 | Integer | String length |
  389. +----------+-------+-----------+------------------------+
  390. | X+4 | X | Bytes | UTF-8 encoded string |
  391. +----------+-------+-----------+------------------------+
  392. Every string is padded to 4 bytes.
  393. 26: :ref:`PackedVector2Array<class_PackedVector2Array>`
  394. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395. +-------------------+-------+-----------+----------------+
  396. | Offset | Len | Type | Description |
  397. +===================+=======+===========+================+
  398. | 4 | 4 | Integer | Array length |
  399. +-------------------+-------+-----------+----------------+
  400. | 8..8+length\*8 | 4 | Float | X coordinate |
  401. +-------------------+-------+-----------+----------------+
  402. | 8..12+length\*8 | 4 | Float | Y coordinate |
  403. +-------------------+-------+-----------+----------------+
  404. 27: :ref:`PackedVector3Array<class_PackedVector3Array>`
  405. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  406. +--------------------+-------+-----------+----------------+
  407. | Offset | Len | Type | Description |
  408. +====================+=======+===========+================+
  409. | 4 | 4 | Integer | Array length |
  410. +--------------------+-------+-----------+----------------+
  411. | 8..8+length\*12 | 4 | Float | X coordinate |
  412. +--------------------+-------+-----------+----------------+
  413. | 8..12+length\*12 | 4 | Float | Y coordinate |
  414. +--------------------+-------+-----------+----------------+
  415. | 8..16+length\*12 | 4 | Float | Z coordinate |
  416. +--------------------+-------+-----------+----------------+
  417. 28: :ref:`PackedColorArray<class_PackedColorArray>`
  418. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419. +--------------------+-------+-----------+--------------------------------------------------------------+
  420. | Offset | Len | Type | Description |
  421. +====================+=======+===========+==============================================================+
  422. | 4 | 4 | Integer | Array length |
  423. +--------------------+-------+-----------+--------------------------------------------------------------+
  424. | 8..8+length\*16 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) |
  425. +--------------------+-------+-----------+--------------------------------------------------------------+
  426. | 8..12+length\*16 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) |
  427. +--------------------+-------+-----------+--------------------------------------------------------------+
  428. | 8..16+length\*16 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) |
  429. +--------------------+-------+-----------+--------------------------------------------------------------+
  430. | 8..20+length\*16 | 4 | Float | Alpha (0..1) |
  431. +--------------------+-------+-----------+--------------------------------------------------------------+