This is a simple library for parsing Quake's BSP file format. More...
Classes | |
struct | quake::lump_object_t |
an object in a lump. More... | |
struct | quake::entity_t |
a game entity in the bsp map More... | |
struct | quake::face_t |
a polygon face in the bsp map More... | |
struct | quake::node_t |
a node in the BSP tree Note that the indexing scheme is unusual:
| |
struct | quake::leaf_t |
a leaf in the BSP tree More... | |
struct | quake::leafface_t |
a leaf face in the BSP tree More... | |
struct | quake::meshvert_t |
a mesh vertex More... | |
struct | quake::plane_t |
a 2D plane in the BSP tree More... | |
struct | quake::texture_path_t |
texture information More... | |
struct | quake::color_t |
color struct TODO: centralize this somewhere? now redundant with glut::color_t More... | |
struct | quake::vertex_t |
vertex information More... | |
class | quake::Bsp |
The 3D space-partitioned map. More... | |
Enumerations | |
enum | quake::eFaceType { quake::eFace_Polygon = 1, quake::eFace_Patch = 2, quake::eFace_Mesh = 3, quake::eFace_Billboard = 4, quake::eFace_Invalid = 0 } |
polygon face type More... | |
Functions | |
virtual eLumpType | quake::lump_object_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
virtual int | quake::lump_object_t::getIndex (void) const throw () |
returns the index of this object as stored in its lump | |
eLumpType | quake::entity_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::face_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::node_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::leaf_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::leafface_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::meshvert_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::plane_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
eLumpType | quake::texture_path_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
void | quake::texture_path_t::dump (void) const throw () |
eLumpType | quake::vertex_t::getType (void) const throw () |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class. | |
virtual BspVersion | quake::Bsp::getVersion (void) const =0 throw () |
virtual const char * | quake::Bsp::getName (void) const =0 throw () |
virtual const vec_lump_type_t & | quake::Bsp::getLumps (void) const =0 throw () |
returns the list of lump types normally expected in BSP maps for this vendor. | |
virtual int | quake::Bsp::getLumpObjectCount (IN eLumpType type)=0 |
returns 0 if lump does not exist, or if lump exists but is empty. | |
virtual void | quake::Bsp::startLumpIteration (IN eLumpType type)=0 |
resets lump object iteration to the first of the specified type. | |
virtual const lump_object_t * | quake::Bsp::getNextLumpObject (void)=0 |
call this to iterate. | |
static smart_ptr< Bsp > | quake::Bsp::load (IN smart_ptr< nstream::Stream > &stream) |
Variables | |
int | quake::lump_object_t::index |
Dictionary | quake::entity_t::dictionary |
key/value pairs | |
int32_t | quake::face_t::texture |
index to texture path object | |
int32_t | quake::face_t::effect |
index to effect (or -1) | |
int32_t | quake::face_t::type |
face type (eFaceType, above) | |
int32_t | quake::face_t::vertex |
index of first vertex | |
int32_t | quake::face_t::nVertices |
number of vertices | |
int32_t | quake::face_t::meshvert |
index of first mesh vertex | |
int32_t | quake::face_t::nMeshverts |
number of mesh vertices | |
int32_t | quake::face_t::lmIndex |
light map index | |
int32_t | quake::face_t::lmStart [2] |
corner of this face's lightmap | |
int32_t | quake::face_t::lmSize [2] |
size of this face's lightmap | |
point3d_t | quake::face_t::origin |
origin of lightmap | |
point3d_t | quake::face_t::lmVecs [2] |
lightmap s and t vectors | |
point3d_t | quake::face_t::normal |
surface normal | |
int32_t | quake::face_t::size [2] |
patch dimensions | |
int32_t | quake::node_t::plane |
index to plane | |
int32_t | quake::node_t::children [2] |
left, right child | |
int32_t | quake::node_t::min [3] |
bounding box min xyz coords | |
int32_t | quake::node_t::max [3] |
bounding box max xyz coords | |
int32_t | quake::leaf_t::cluster |
cluster index | |
int32_t | quake::leaf_t::area |
map area (for portals?) | |
int32_t | quake::leaf_t::min [3] |
bounding box min xyz coords | |
int32_t | quake::leaf_t::max [3] |
bounding box max xyz coords | |
int32_t | quake::leaf_t::leafface |
first leaf face for leaf | |
int32_t | quake::leaf_t::n_leaffaces |
number of faces | |
int32_t | quake::leaf_t::leafbrush |
first leaf brush for leaf | |
int32_t | quake::leaf_t::n_leafbrushes |
number of brushes | |
int32_t | quake::leafface_t::face |
face index | |
int32_t | quake::meshvert_t::vertex |
vertex index | |
point3d_t | quake::plane_t::n |
plane normal | |
float | quake::plane_t::d |
distance from origin along normal | |
char | quake::texture_path_t::name [64] |
name | |
int32_t | quake::texture_path_t::flags |
int32_t | quake::texture_path_t::contents |
byte_t | quake::color_t::green |
byte_t | quake::color_t::blue |
byte_t | quake::color_t::alpha |
point3d_t | quake::vertex_t::position |
point3d_t | quake::vertex_t::normal |
float | quake::vertex_t::texcoord [2][2] |
color_t | quake::vertex_t::color |
| |
enum | quake::eBspVendor { quake::eBspVendor_Id = 1, quake::eBspVendor_Valve = 2, quake::eBspVendor_Invalid = 0 } |
enum | quake::eBspVersion { quake::eBspVersion_IdQuake3 = 1001, quake::eBspVersion_Invalid = 0 } |
enum | quake::eLumpType { quake::eLump_Entities = 1, quake::eLump_Textures = 2, quake::eLump_Planes = 3, quake::eLump_Nodes = 4, quake::eLump_Leafs = 5, quake::eLump_Leaffaces = 6, quake::eLump_Leafbrushes = 7, quake::eLump_Models = 8, quake::eLump_Brushes = 9, quake::eLump_Brushsides = 10, quake::eLump_Vertices = 11, quake::eLump_Meshverts = 12, quake::eLump_Effects = 13, quake::eLump_Faces = 14, quake::eLump_Lightmaps = 15, quake::eLump_Lightvols = 16, quake::eLump_Visdata = 17, quake::eLump_Invalid = 0 } |
types of lumps in BSP maps. More... | |
const char * | quake::getLumpName (IN eLumpType type) |
for debugging | |
int | quake::readInt (IO std::istream &stream) |
read an integer. These are stored as little-endian in BSP files. | |
float | quake::readFloat (IO std::istream &stream) |
read a float. These are stored as little-endian in BSP files. | |
point3d_t | quake::readPoint3d (IO std::istream &stream) |
read a vector/point (helper function using readFloat() above) | |
typedef std::vector< eLumpType > | quake::vec_lump_type_t |
This is a simple library for parsing Quake's BSP file format.
A BSP file contains a 3D map (BSP stands for Binary Space Partitioning). Typically the file contains several "lumps", and each lump contains a list of objects. Example lumps are textures, polygons, vertices, map entities, effects, etc.
How to use this parsing library: The library is designed to handle a wide range of BSP formats. In general, different vendors (game companies) have slightly different BSP formats. They'll use different lumps, and maybe even have slightly different objects in lumps with the same name.
This library will attempt to determine the vendor that created the BSP based on the BSP header, then allow the caller to iterate over available lumps, and likewise iterate over objects in each lump. You should write your code to expect some common lumps always (nodes, faces, textures, ...) but treat other vendor-specific lumps as optional. The more flexible you are, the more likely it is you can handle BSP files from multiple vendors.
Warning: do not use the objects defined here (texture_t, face_t, etc.) in your rendering code. These objects are defined for convenience and safety in parsing, not high-speed rendering. For instance, they have a high per-object overhead due to vtables. Just use these objects for parsing, and have your own simple structs to store thousands of vertices, for instance.
See these links for references on the BSP format:
typedef std::vector<eLumpType> quake::vec_lump_type_t |
Definition at line 98 of file bsp-version.h.
enum quake::eBspVendor |
eBspVendor_Id |
Id Software, magic = "IBSP". |
eBspVendor_Valve |
Valve Softare, magic = "VBSP". |
eBspVendor_Invalid |
Definition at line 48 of file bsp-version.h.
enum quake::eFaceType |
enum quake::eBspVersion |
Definition at line 58 of file bsp-version.h.
enum quake::eLumpType |
types of lumps in BSP maps.
There are many types of lumps, and no vendor seems to 100% agree on what they are! Some examples:
Definition at line 74 of file bsp-version.h.
virtual eLumpType quake::lump_object_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented in quake::entity_t, quake::face_t, quake::node_t, quake::leaf_t, quake::leafface_t, quake::meshvert_t, quake::plane_t, quake::texture_path_t, and quake::vertex_t.
virtual int quake::lump_object_t::getIndex | ( | void | ) | const throw () [inline, virtual, inherited] |
eLumpType quake::entity_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::face_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::node_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::leaf_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::leafface_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::meshvert_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::plane_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
eLumpType quake::texture_path_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
void quake::texture_path_t::dump | ( | void | ) | const throw () [inline, inherited] |
eLumpType quake::vertex_t::getType | ( | void | ) | const throw () [inline, virtual, inherited] |
what sort of lump object is this really? Can use this information to perform a dynamic cast to the correct leaf class.
Reimplemented from quake::lump_object_t.
virtual BspVersion quake::Bsp::getVersion | ( | void | ) | const throw () [pure virtual, inherited] |
virtual const char* quake::Bsp::getName | ( | void | ) | const throw () [pure virtual, inherited] |
virtual const vec_lump_type_t& quake::Bsp::getLumps | ( | void | ) | const throw () [pure virtual, inherited] |
returns the list of lump types normally expected in BSP maps for this vendor.
Sometimes the lumps are empty or missing anyway.
virtual int quake::Bsp::getLumpObjectCount | ( | IN eLumpType | type | ) | [pure virtual, inherited] |
returns 0 if lump does not exist, or if lump exists but is empty.
returns -1 if lump exists but contains an unknown number of objects.
virtual void quake::Bsp::startLumpIteration | ( | IN eLumpType | type | ) | [pure virtual, inherited] |
resets lump object iteration to the first of the specified type.
Will silently fail if lump type does not exist.
virtual const lump_object_t* quake::Bsp::getNextLumpObject | ( | void | ) | [pure virtual, inherited] |
call this to iterate.
Returns NULL at end of iteration. Returns NULL immediately if lump does not exist or is empty.
smart_ptr< Bsp > quake::Bsp::load | ( | IN smart_ptr< nstream::Stream > & | stream | ) | [static, inherited] |
const char * quake::getLumpName | ( | IN eLumpType | type | ) |
for debugging
int32_t quake::readInt | ( | IO std::istream & | in | ) |
read an integer. These are stored as little-endian in BSP files.
float quake::readFloat | ( | IO std::istream & | in | ) |
read a float. These are stored as little-endian in BSP files.
point3d_t quake::readPoint3d | ( | IO std::istream & | in | ) |
read a vector/point (helper function using readFloat() above)
int quake::lump_object_t::index [inherited] |
Dictionary quake::entity_t::dictionary [inherited] |
int32_t quake::face_t::texture [inherited] |
int32_t quake::face_t::effect [inherited] |
int32_t quake::face_t::type [inherited] |
int32_t quake::face_t::vertex [inherited] |
int32_t quake::face_t::nVertices [inherited] |
int32_t quake::face_t::meshvert [inherited] |
int32_t quake::face_t::nMeshverts [inherited] |
int32_t quake::face_t::lmIndex [inherited] |
int32_t quake::face_t::lmStart[2] [inherited] |
int32_t quake::face_t::lmSize[2] [inherited] |
point3d_t quake::face_t::origin [inherited] |
point3d_t quake::face_t::lmVecs[2] [inherited] |
point3d_t quake::face_t::normal [inherited] |
int32_t quake::face_t::size[2] [inherited] |
int32_t quake::node_t::plane [inherited] |
int32_t quake::node_t::children[2] [inherited] |
int32_t quake::node_t::min[3] [inherited] |
int32_t quake::node_t::max[3] [inherited] |
int32_t quake::leaf_t::cluster [inherited] |
int32_t quake::leaf_t::area [inherited] |
int32_t quake::leaf_t::min[3] [inherited] |
int32_t quake::leaf_t::max[3] [inherited] |
int32_t quake::leaf_t::leafface [inherited] |
int32_t quake::leaf_t::n_leaffaces [inherited] |
int32_t quake::leaf_t::leafbrush [inherited] |
int32_t quake::leaf_t::n_leafbrushes [inherited] |
int32_t quake::leafface_t::face [inherited] |
int32_t quake::meshvert_t::vertex [inherited] |
point3d_t quake::plane_t::n [inherited] |
float quake::plane_t::d [inherited] |
char quake::texture_path_t::name[64] [inherited] |
int32_t quake::texture_path_t::flags [inherited] |
int32_t quake::texture_path_t::contents [inherited] |
byte_t quake::color_t::green [inherited] |
byte_t quake::color_t::blue [inherited] |
byte_t quake::color_t::alpha [inherited] |
point3d_t quake::vertex_t::position [inherited] |
point3d_t quake::vertex_t::normal [inherited] |
float quake::vertex_t::texcoord[2][2] [inherited] |
color_t quake::vertex_t::color [inherited] |