bsp

package
v1.0.302 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Magic          = (('P' << 24) + ('S' << 16) + ('B' << 8) + 'I')
	HeaderLen      = 160 // magic + version + lump metadata
	EntityLump     = 0
	PlanesLump     = 1 // 20 bytes each
	VerticesLump   = 2 // 12 bytes each (3 floats)
	VisibilityLump = 3 // 4 bytes PVS, 4 bytes PHS
	NodesLump      = 4 // 28 bytes each
	TextureLump    = 5 // 76 bytes each
	FacesLump      = 6 // 20 bytes each
	LightMapLump   = 7
	LeavesLump     = 8
	LeafFaceTable  = 9
	LeafBrushTable = 10
	EdgesLump      = 11
	FaceEdgeTable  = 12
	ModelsLump     = 13
	BrushesLump    = 14
	BrushSidesLump = 15
	POPLump        = 16
	AreasLump      = 17
	AreaPortals    = 18
	TextureLen     = 76 // 40 bytes of origins and angles + 36 for textname
)
View Source
const (
	BSPPlaneSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BSPEntity

type BSPEntity struct {
	Class  string
	Values map[string]string
}

type BSPFile

type BSPFile struct {
	Name       string // just the filename minus extension (ex: "q2dm1")
	Filename   string // including any path prefix and .bsp extension
	Handle     *os.File
	Header     m.Buffer
	LumpMeta   [19]BSPLumpMeta
	LumpData   [19]BSPLumpData
	Ents       []BSPEntity
	Planes     []BSPPlane
	Vertices   []Vertex
	Visibility []Visibility
}

represents a binary space partitioning map file

func OpenBSPFile

func OpenBSPFile(f string) (*BSPFile, error)

func (*BSPFile) BuildEntityString

func (bsp *BSPFile) BuildEntityString() string

func (*BSPFile) Close

func (b *BSPFile) Close()

func (*BSPFile) FetchEntities

func (bsp *BSPFile) FetchEntities() []BSPEntity

func (*BSPFile) FetchEntityString

func (bsp *BSPFile) FetchEntityString() string

func (*BSPFile) FetchPlanes

func (bsp *BSPFile) FetchPlanes() []BSPPlane

func (*BSPFile) FetchTextures

func (bsp *BSPFile) FetchTextures() []BSPTexture

Get a slice of textures TODO: parse the location and orientation data too

func (*BSPFile) FetchVertices

func (bsp *BSPFile) FetchVertices() []Vertex

func (*BSPFile) FetchVisibility

func (bsp *BSPFile) FetchVisibility() []Visibility

func (*BSPFile) ParseLumpData

func (bsp *BSPFile) ParseLumpData() error

func (*BSPFile) ParseLumpMetadata

func (bsp *BSPFile) ParseLumpMetadata()

find all the locations/sizes of the various lumps. There are always 18 of them.

func (*BSPFile) Validate

func (bsp *BSPFile) Validate() bool

Make sure the first 4 bytes match the magic number

type BSPLumpData

type BSPLumpData struct {
	Data m.Buffer
}

type BSPLumpMeta

type BSPLumpMeta struct {
	// contains filtered or unexported fields
}

Collections of data are organized into "lumps" within the file

type BSPPlane

type BSPPlane struct {
	Normal   types.Vector3
	Distance int
	Type     int
}

type BSPTexture

type BSPTexture struct {
	File string // max 64 chars
}

type Vertex

type Vertex types.Vector3

type Visibility

type Visibility struct {
	PVS int // visible
	PHS int // audible
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL