Difference between revisions of "BSP data structure"

From FreeSpace Wiki
Jump to: navigation, search
(3D model data)
Line 71: Line 71:
 
+ 8 vector min_point
 
+ 8 vector min_point
 
+20 vector max_point</pre></blockquote>
 
+20 vector max_point</pre></blockquote>
 +
6 - TMAP2POLY - Textured polygons with increased vertex limit
 +
<blockquote><pre>+ 0 int id = 3
 +
+ 4 int size
 +
+ 8 vector normal
 +
+20 uint nverts
 +
+24 int tmap_num
 +
+28 for each vertex, i {
 +
uint vertnum[i]
 +
uint normnum[i]
 +
float u[i]
 +
float v[i]
 +
}</pre></blockquote>
 +
** Note: TMAP2POLY increases the vertex and normal limit for subobjects, which is the main distinction from TMAPPOLY.
  
 
[[Category:File Types]]
 
[[Category:File Types]]

Revision as of 18:07, 16 April 2022

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 chunk lacks the size int after the ID, it should be considered as size 4 due to the rule of other chunks.

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

6 - TMAP2POLY - Textured polygons with increased vertex limit

+ 0 int id = 3
+ 4 int size
+ 8 vector normal
+20 uint nverts
+24 int tmap_num
+28 for each vertex, i {
 uint vertnum[i]
 uint normnum[i]
 float u[i]
 float v[i]
}
    • Note: TMAP2POLY increases the vertex and normal limit for subobjects, which is the main distinction from TMAPPOLY.