bsp29a
Module¶
Source code: bsp29a.py
The bsp29a
module provides an Bsp
class which derives
from ReadWriteFile
and is used to read and write Quake
bsp29a data.
- vgio.quake.bsp.bsp29a.is_bspfile(filename)¶
Quickly see if a file is a bsp file by checking the magic number.
The filename argument may be a file for file-like object.
- Parameters
filename – File to check as string or file-like object.
- Returns
True if given file’s magic number is correct.
Bsp
Class¶
- class vgio.quake.bsp.bsp29a.Bsp¶
Class for working with Bsp files
Example
Basic usage:
from vgio.quake.bsp.bsp29a import Bsp b = Bsp.open('ad_sepulcher.bsp')
- version¶
Version of the map file. Vanilla Quake is 29.
- entities¶
A string containing the entity definitions.
- planes¶
A sequence of Planes used by the bsp tree data structure.
- miptextures¶
A sequence of Miptextures.
- vertexes¶
A sequence of Vertexes.
- visibilities¶
A sequence of ints representing visibility data.
- nodes¶
A sequence of Nodes used by the bsp tree data structure.
- texture_infos¶
A sequence of TextureInfo objects.
- faces¶
A sequence of Faces.
- lighting¶
A sequence of ints representing lighting data.
- clip_nodes¶
A sequence of ClipNodes used by the bsp tree data structure.
- leafs¶
A sequence of Leafs used by the bsp tree data structure.
- mark_surfaces¶
A sequence of ints representing lists of consecutive faces used by the Node objects.
- edges¶
A sequence of Edges.
- surf_edges¶
A sequence of ints representing list of consecutive edges used by the Face objects.
- models¶
A sequence of Models.
Note
The first model is the entire level.
- fp¶
The file-like object to read data from.
- mode¶
The file mode for the file-like object.
- Bsp.__init__()¶
Initializes a ReadWriteFile object. Derving classes must call this.
- classmethod Bsp.open(file, mode='r')¶
Open a ReadWriteFile object where file can be a path to a file (a string), or a file-like object.
The mode parameter should be ‘r’ to read an existing file, ‘w’ to truncate and write a new file, or ‘a’ to append to an existing file.
open() is also a context manager and supports the with statement:
with ReadWriteFile.open('file.ext') as file: file.save('file2.ext')
- Parameters
file – Either the path to the file, a file-like object, or bytes.
mode – An optional string that indicates which mode to open the file
- Returns
An ReadWriteFile object constructed from the information read from the file-like object.
- Raises
ValueError – If an invalid file mode is given.
TypeError – If attempting to write to a bytes object.
OSError – If the file argument is not a file-like object.
- Bsp.close()¶
Closes the file pointer if possible. If mode is ‘w’ or ‘a’, the file will be written to.
- Bsp.save(file)¶
Writes data to file.
- Parameters
file – Either the path to the file, or a file-like object.
- Raises
OSError – If file argument is not a file-like object.
Node
Class¶
- class vgio.quake.bsp.bsp29a.Node(plane_number, child_front, child_back, bounding_box_min_x, bounding_box_min_y, bounding_box_min_z, bounding_box_max_x, bounding_box_max_y, bounding_box_max_z, first_face, number_of_faces)¶
- Node.__init__(plane_number, child_front, child_back, bounding_box_min_x, bounding_box_min_y, bounding_box_min_z, bounding_box_max_x, bounding_box_max_y, bounding_box_max_z, first_face, number_of_faces)¶
Constructs a Node object.
- classmethod Node.read(file)¶
- classmethod Node.write(file, node)¶
Face
Class¶
- class vgio.quake.bsp.bsp29a.Face(plane_number, side, first_edge, number_of_edges, texture_info, style_0, style_1, style_2, style_3, light_offset)¶
- Face.__init__(plane_number, side, first_edge, number_of_edges, texture_info, style_0, style_1, style_2, style_3, light_offset)¶
Constructs a Face object.
- classmethod Face.read(file)¶
- classmethod Face.write(file, plane)¶
ClipNode
Class¶
- class vgio.quake.bsp.bsp29a.ClipNode(plane_number, child_front, child_back)¶
- ClipNode.__init__(plane_number, child_front, child_back)¶
Constructs a ClipNode object.
- classmethod ClipNode.read(file)¶
- classmethod ClipNode.write(file, clip_node)¶
Leaf
Class¶
- class vgio.quake.bsp.bsp29a.Leaf(contents, visibilitiy_offset, bounding_box_min_x, bounding_box_min_y, bounding_box_min_z, bounding_box_max_x, bounding_box_max_y, bounding_box_max_z, first_mark_surface, number_of_marked_surfaces, ambient_level_0, ambient_level_1, ambient_level_2, ambient_level_3)¶
- Leaf.__init__(contents, visibilitiy_offset, bounding_box_min_x, bounding_box_min_y, bounding_box_min_z, bounding_box_max_x, bounding_box_max_y, bounding_box_max_z, first_mark_surface, number_of_marked_surfaces, ambient_level_0, ambient_level_1, ambient_level_2, ambient_level_3)¶
Constructs a Leaf object.
- classmethod Leaf.read(file)¶
- classmethod Leaf.write(file, leaf)¶
Edge
Class¶
- class vgio.quake.bsp.bsp29a.Edge(vertex_0, vertex_1)¶
- Edge.__init__(vertex_0, vertex_1)¶
Constructs an Edge object.
- classmethod Edge.read(file)¶
- classmethod Edge.write(file, edge)¶