BSP data structure

From FreeSpace Wiki
Revision as of 13:58, 29 October 2009 by The E (talk | contribs) (More info from the DDN)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This info is copied from the Descent Developer's Network bsp_data page.

Introduction

The BSP data in FreeSpace in kinda similar to the Descent 1-3 BSP data (also called IDTA). Many deja-vu's here and there :). 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.

0 - EOF - Means end of tree reached

+ 0 int id = 0
+ 4 int 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.

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 {
 short vertnum[i]
 short 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.

<blockquote>+ 0 int id = 5
+ 4 int size
+ 8 vector min_point
+20 vector max_point