Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:bsp2_format [2012/12/22 13:49] – Spirit | tools:bsp2_format [2015/08/28 18:11] (current) – moved to http://quakewiki.org/wiki/BSP2 Spirit | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== The BSP2 Format ====== | + | Moved to http://quakewiki.org/wiki/BSP2 |
- | + | ||
- | When the Remakequake project' | + | |
- | + | ||
- | The finalised BSP2 format uses the magic number BSP2 and has the following limits: TODO, why are those numbers nowhere to be found :( | + | |
- | + | ||
- | First map releases (TODO which RMQ demos?) used an early version with the magic number 2PSB and still had node BBox sizes being '' | + | |
- | + | ||
- | ==== Engines with BSP2 support ==== | + | |
- | * Darkplaces | + | |
- | * FTEQW | + | |
- | * Quakeforge | + | |
- | + | ||
- | ==== Compilers with BSP2 support ==== | + | |
- | * hmap2 uses BSP2 automatically if needed. | + | |
- | <WRAP center round todo 60%> | + | |
- | Does this create PSB2 or BSP2? | + | |
- | * RMQ's TxQBSP2, WVisBSP2 and LightBSP2. Available in http://icculus.org/remakequake/RMQSDKJan2012.zip | + | |
- | </ | + | |
- | + | ||
- | ==== Adding support to your engine/ | + | |
- | MH has written "BSP2 for Engine Coders.txt" | + | |
- | + | ||
- | < | + | |
- | + | ||
- | The objective of BSP2 is to address some limits in the stock BSP29 format. | + | |
- | + | ||
- | Alternatives such as Half-Life BSP, Quake II BSP, Quake III BSP or others were considered but rejected on grounds of legal issues, not actually doing anything to fix this problem, enforcing too many changes in the content creation pipeline (such as changing your map editor) and enforcing too many (and too complex) changes in engine | + | |
- | code. | + | |
- | + | ||
- | BSP2 will coexist peacefully with BSP29 so far as is possible; minimal changes are required to engine code (the largest by far being in the loader), the .map format remains exactly the same, and - while new map compiling tools are needed - the changes to these tools are also extremely minimal and can be made in the order of 30 minutes or so per tool. | + | |
- | + | ||
- | BSP2 is not a radical revision of the format. | + | |
- | who's authors choose to do so is as eased as is possible, and dependencies on other features (such as RGB lightmaps) are not an obstacle. | + | |
- | + | ||
- | -------------------------------------------------------------------------------------------------------------- | + | |
- | + | ||
- | This document outlines the requirements for implementing RMQ BSP2 support in your engine. | + | |
- | + | ||
- | The basic steps are: | + | |
- | + | ||
- | - Change the in-memory formats for certain BSP structs.\\ | + | |
- | - Detect the version.\\ | + | |
- | - Implement the loaders. | + | |
- | + | ||
- | -------------------------------------------------------------------------------------------------------------- | + | |
- | Changing the in-memory formats | + | |
- | + | ||
- | This is a simple matter of switching the in-memory formats from using short (or unsigned short) to int (or unsigned int) as appropriate. | + | |
- | + | ||
- | In general, an on-disk struct name is prefixed by " | + | |
- | + | ||
- | You will need to implement your own mclipnode_t struct as stock ID Quake uses dclipnode_t for both on-disk and in-memory. | + | |
- | + | ||
- | One side-effect of this is that some ASM code in world.c will need to be switched to the equivalent C function; this should not cause a noticeable performance hit for most people. | + | |
- | + | ||
- | -------------------------------------------------------------------------------------------------------------- | + | |
- | Detecting the version | + | |
- | + | ||
- | The BSP2 version is defined as ((' | + | |
- | + | ||
- | Once we have identified this we are almost ready to load the file, but first we must define some new structs in bspfile.h (Note that the use of " | + | |
- | + | ||
- | typedef struct | + | |
- | { | + | |
- | int planenum; | + | |
- | int children[2]; | + | |
- | short mins[3]; | + | |
- | short maxs[3]; | + | |
- | unsigned int firstface; | + | |
- | unsigned int numfaces; | + | |
- | } dnode29a_t; | + | |
- | + | ||
- | typedef struct | + | |
- | { | + | |
- | int planenum; | + | |
- | int children[2]; | + | |
- | } dclipnode29a_t; | + | |
- | + | ||
- | typedef struct | + | |
- | { | + | |
- | unsigned int v[2]; | + | |
- | } dedge29a_t; | + | |
- | + | ||
- | typedef struct | + | |
- | { | + | |
- | int planenum; | + | |
- | int side; | + | |
- | + | ||
- | int firstedge; | + | |
- | int numedges; | + | |
- | int texinfo; | + | |
- | + | ||
- | // lighting info | + | |
- | byte styles[MAXLIGHTMAPS]; | + | |
- | int lightofs; | + | |
- | } dface29a_t; | + | |
- | + | ||
- | typedef struct | + | |
- | { | + | |
- | int contents; | + | |
- | int visofs; | + | |
- | + | ||
- | short mins[3]; | + | |
- | short maxs[3]; | + | |
- | + | ||
- | unsigned int firstmarksurface; | + | |
- | unsigned int nummarksurfaces; | + | |
- | + | ||
- | byte ambient_level[NUM_AMBIENTS]; | + | |
- | } dleaf29a_t; | + | |
- | + | ||
- | -------------------------------------------------------------------------------------------------------------- | + | |
- | Implementing the Loaders | + | |
- | + | ||
- | From here the only major remaining change is to implement new versions of certain brushmodel loading functions to support BSP2. The functions that need new versions are: | + | |
- | + | ||
- | - Mod_LoadEdges\\ | + | |
- | - Mod_LoadFaces\\ | + | |
- | - Mod_LoadNodes\\ | + | |
- | - Mod_LoadLeafs\\ | + | |
- | - Mod_LoadClipnodes\\ | + | |
- | - Mod_LoadMarksurfaces | + | |
- | + | ||
- | For each of these functions the " | + | |
- | + | ||
- | You may find it easier and cleaner to split some functions into two or even three separate parts, with different parts being common for both versions, dedicated to BSP29 or dedicated to BSP2. This is almost certainly the case with Mod_LoadFaces. | + | |
- | + | ||
- | -------------------------------------------------------------------------------------------------------------- | + | |
- | License | + | |
- | + | ||
- | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. | + | |
- | + | ||
- | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | |
- | + | ||
- | See the GNU General Public License for more details. | + | |
- | + | ||
- | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | + | |
- | </ | + | |
- | + | ||
- | Sources: | + | |
- | + | ||
- | * http:// | + | |
- | * #qc | + |