Crate qbsp

Crate qbsp 

Source
Expand description

§QBSP

crates.io docs.rs

Rust crate for parsing, and operating with Quake 1, 2, and GoldSrc BSP files.

§Features

  • Parsing .bsp files with the BSP29 BSP2, BSP30 BSP38, and Qbism formats.
  • Structured easy access to the bsp data.
  • BSP raycasting.
  • Mesh generation.
  • Lightmap atlas generation either per-style or per-slot (.lit supported).
  • BSPX support, including built-in structures for the RGBLIGHTING, LIGHTGRID_OCTREE, BRUSHLIST, and DECOUPLED_LM lumps.

§Quickstart

use qbsp::prelude::*;

let _ = BspData::parse(BspParseInput {
    bsp: &[], // Data of the bsp file.
    lit: None, // Optional lit file for colored lighting if no `RGBLIGHTING` BSPX lump is present.
    settings: BspParseSettings::default(),
});

§Feature wishlist

I might work on these at a later date, but if anyone wants to help out or just give some ideas, they’re more than welcome to!

  • More flexible meshing API
  • BSP writing

Re-exports§

pub use data::bspx;
pub use data::texture::Palette;
pub use glam;
pub use image;
pub use smallvec;

Modules§

data
Datatype definitions for lumps within a BSP file.
mesh
Module for turning BspData into a renderable mesh.
prelude
Module that re-exports common/necessary imports to make the user experience that much nicer.
query
Module for various more advanced queries into BspData, such as raycasting, potentially visible set, and potentially audible set.
reader
Module containing the core of reading a binary BSP file and interpreting it into structured data.
util
Various utilities that don’t fit cleanly into other modules, but are too small to warrant their own.

Structs§

BspData
A BSP files contents parsed into structures for easy access.
BspParseInput
BspParseSettings

Enums§

BspFormat
The format of a BSP file. This is determined by the magic number made up of the first 4 bytes of the file, and governs how the rest of the file attempts to parse.
BspParseError

Statics§

QUAKE_PALETTE
The default quake palette.

Traits§

BspParseResultDoingJobExt

Functions§

read_lump
Helper function to read an array of data of type T from a lump. Takes in the BSP file data, the lump directory, and the lump to read from.
read_mip_texture_lump
The texture lump is more complex than just a vector of the same type of item, so it needs its own function.

Type Aliases§

BspResult

Derive Macros§

BspValue
Automatically implements BspValue on structs in the order of the fields, or unit enums with #[repr(...)] and explicit discriminants (e.g. Foo = 1).
BspVariableValue
Automatically implement BspVariableValue on single-field tuple structs. Note: This will additionally implement From<T> where (inner field type): From<T> for the type, in order to convert from the individual format types, and will implement {Deref,DerefMut}<Target = (inner field type)>. Specify the variant types per BSP format with #[bsp2(..)], #[bsp29(..)], #[bsp30(..)] and #[bsp38(..)] annotations respectively. All format variants must be specified, if a field does not exist in a format use NoField and implement From<NoField> for the inner field type.