Difference between revisions of "BSP data structure"
m (Slight correction to reflect *actual* usage, as opposed to the theory) |
(→3D model data) |
||
Line 8: | Line 8: | ||
==3D model data== | ==3D model data== | ||
The first byte defines the block now following (0-5, see below). After a block the following byte defines the data of the next block, etc. | The first byte defines the block now following (0-5, see below). After a block the following byte defines the data of the next block, etc. | ||
+ | [[Media:Bsp_chunk.png]] | ||
0 - EOF - Means end of tree reached | 0 - EOF - Means end of tree reached | ||
<blockquote><pre>+ 0 int id = 0 | <blockquote><pre>+ 0 int id = 0 | ||
+ 4 int size</pre></blockquote> | + 4 int size</pre></blockquote> | ||
+ | ** Note: EOF size is read as 0, but is actually 8 (id+size). | ||
+ | |||
1 - DEFPOINTS - Defines the vertices | 1 - DEFPOINTS - Defines the vertices | ||
<blockquote><pre>+ 0 int id = 1 | <blockquote><pre>+ 0 int id = 1 | ||
Line 20: | Line 23: | ||
+20 n_verts*char norm_counts | +20 n_verts*char norm_counts | ||
+offset vertex_data // Each vertex n is a point followed by norm_counts[n] normals.</pre></blockquote> | +offset vertex_data // Each vertex n is a point followed by norm_counts[n] normals.</pre></blockquote> | ||
+ | ** Note: DEFPOINTS is the only type of chunk on bsp_data that could be unaligned. The offset to vertex data must be divisible by 4. This is a mayor cause of bus errors on ARM arch. | ||
2 - FLATPOLY - Flat (non-textured) polygon | 2 - FLATPOLY - Flat (non-textured) polygon | ||
<blockquote><pre>+ 0 int id = 2 | <blockquote><pre>+ 0 int id = 2 |
Revision as of 01:37, 6 December 2019
This info is copied from the Descent Developer's Network bsp_data page.
Introduction
The BSP data in FreeSpace in similar to the Descent 1-3 BSP data (also called IDTA). In FreeSpace, the BSP data is located in the POF files.
This document was written by John Slagel from Volition Inc., with revisions and bugfixing from Garry Knudson and Francis "Pastel" Avila.
3D model data
The first byte defines the block now following (0-5, see below). After a block the following byte defines the data of the next block, etc. Media:Bsp_chunk.png
0 - EOF - Means end of tree reached
+ 0 int id = 0 + 4 int size
- Note: EOF size is read as 0, but is actually 8 (id+size).
1 - DEFPOINTS - Defines the vertices
+ 0 int id = 1 + 4 int size + 8 int n_verts +12 int n_norms +16 int offset // from start of chunk to vertex data +20 n_verts*char norm_counts +offset vertex_data // Each vertex n is a point followed by norm_counts[n] normals.
- Note: DEFPOINTS is the only type of chunk on bsp_data that could be unaligned. The offset to vertex data must be divisible by 4. This is a mayor cause of bus errors on ARM arch.
2 - FLATPOLY - Flat (non-textured) polygon
+ 0 int id = 2 + 4 int size + 8 vector normal +20 vector center +32 float radius +36 int nverts +40 byte red +41 byte green +42 byte blue +43 byte pad for each vertex, i { short vertnum[i] short normnum[i] }
3 - TMAPPOLY - Textured polygons
+ 0 int id = 3 + 4 int size + 8 vector normal +20 vector center +32 float radius +36 int nverts +40 int tmap_num for each vertex, i { ushort vertnum[i] ushort normnum[i] float u[i] float v[i] }
4 - SORTNORM - Sortnorms are planes that split the model recursively
+ 0 int id = 4 + 4 int size + 8 vector plane_normal +20 vector plane_point +32 int reserved // set to 0 +36 int front_offset // Only recurse into this if non-zero. +40 int back_offset // Only recurse into this if non-zero. +44 int prelist_offset // Only recurse into this if non-zero. +48 int postlist_offset // Only recurse into this if non-zero. +52 int online_offset // Only recurse into this if non-zero. +56 vector min_bounding_box_point // of all polys under here +68 vector max_bounding_box_point // of all polys under here
5 - BOUNDBOX - Bounding boxes are used to speed up lighting and collision calculations.
+ 0 int id = 5 + 4 int size + 8 vector min_point +20 vector max_point