bsp

package
v0.0.0-...-62eada6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaskAll                  = ^Contents(0)
	MaskSolid                = ContentsSolid | ContentsMoveable | ContentsWindow | ContentsMonster | ContentsGrate
	MaskPlayerSolid          = MaskSolid | ContentsPlayerClip
	MaskNPCSolid             = MaskSolid | ContentsMonsterClip
	MaskNPCFluid             = MaskNPCSolid &^ ContentsGrate
	MaskWater                = ContentsWater | ContentsMoveable | ContentsSlime
	MaskOpaque               = ContentsSolid | ContentsMoveable | ContentsOpaque
	MaskOpaqueAndNPCs        = MaskOpaque | ContentsMonster
	MaskBlockLOS             = ContentsSolid | ContentsMoveable | ContentsBlockLOS
	MaskBlockLOSAndNPCs      = MaskBlockLOS | ContentsMonster
	MaskVisible              = MaskOpaque | ContentsIgnoreNoDrawOpaque
	MaskVisibleAndNPCs       = MaskOpaqueAndNPCs | ContentsIgnoreNoDrawOpaque
	MaskShot                 = ContentsSolid | ContentsMoveable | ContentsMonster | ContentsWindow | ContentsDebris | ContentsHitbox
	MaskShotBrushOnly        = ContentsSolid | ContentsMoveable | ContentsWindow | ContentsDebris
	MaskShotHull             = ContentsSolid | ContentsMoveable | ContentsMonster | ContentsWindow | ContentsDebris | ContentsGrate
	MaskShotPortal           = ContentsSolid | ContentsMoveable | ContentsWindow | ContentsMonster
	MaskSolidBrushOnly       = ContentsSolid | ContentsMoveable | ContentsWindow | ContentsGrate
	MaskPlayerSolidBrushOnly = MaskSolidBrushOnly | ContentsPlayerClip
	MaskNPCSolidBrushOnly    = MaskSolidBrushOnly | ContentsMonsterClip
	MaskNPCWorldStatic       = ContentsSolid | ContentsWindow | ContentsMonsterClip | ContentsGrate
	MaskNPCWorldStaticFluid  = ContentsSolid | ContentsWindow | ContentsMonsterClip
	MaskSplitAreaPortal      = ContentsWater | ContentsSlime
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Area

type Area struct {
	NumAreaPortals  int32
	FirstAreaPortal int32
}

type AreaPortal

type AreaPortal struct {
	PortalKey           uint16 // Entities have a key called portalnumber (and in vbsp a variable called areaportalnum) which is used to bind them to the area portals by comparing with this value.
	OtherArea           uint16 // The area this portal looks into.
	FirstClipPortalVert uint16 // Portal geometry.
	NumClipPortalVerts  uint16
	PlaneNum            int32
}

type Brush

type Brush struct {
	FirstSide int32
	NumSides  int32
	Contents  Contents
}

type BrushModel

type BrushModel struct {
	Mins, Maxs Vector
	Origin     Vector // for sounds or lights
	HeadNode   int32
	FirstFace  int32 // submodels just draw faces without walking the bsp tree
	NumFaces   int32
}

type BrushSide

type BrushSide struct {
	PlaneNum uint16 // facing out of the leaf
	TexInfo  int16
	DispInfo int16 // displacement info (BSPVERSION 7)
	Bevel    uint8 // is the side a bevel plane? (BSPVERSION 7)
	Thin     uint8 // is a thin side?
}

type Color32

type Color32 struct {
	R, G, B, A uint8
}

type ColorRGBExp32

type ColorRGBExp32 struct {
	R, G, B  uint8
	Exponent int8
}

type CompressedLightCube

type CompressedLightCube struct {
	Color [6]ColorRGBExp32
}

type Contents

type Contents uint32
const (
	ContentsEmpty              Contents = 0
	ContentsSolid              Contents = 0x1
	ContentsWindow             Contents = 0x2
	ContentsAux                Contents = 0x4
	ContentsGrate              Contents = 0x8
	ContentsSlime              Contents = 0x10
	ContentsWater              Contents = 0x20
	ContentsBlockLOS           Contents = 0x40
	ContentsOpaque             Contents = 0x80
	ContentsTestFogVolume      Contents = 0x100
	ContentsTeam1              Contents = 0x800
	ContentsTeam2              Contents = 0x1000
	ContentsIgnoreNoDrawOpaque Contents = 0x2000
	ContentsMoveable           Contents = 0x4000
	ContentsAreaPortal         Contents = 0x8000
	ContentsPlayerClip         Contents = 0x10000
	ContentsMonsterClip        Contents = 0x20000
	ContentsCurrent0           Contents = 0x40000
	ContentsCurrent90          Contents = 0x80000
	ContentsCurrent180         Contents = 0x100000
	ContentsCurrent270         Contents = 0x200000
	ContentsCurrentUp          Contents = 0x400000
	ContentsCurrentDown        Contents = 0x800000
	ContentsOrigin             Contents = 0x1000000
	ContentsMonster            Contents = 0x2000000
	ContentsDebris             Contents = 0x4000000
	ContentsDetail             Contents = 0x8000000
	ContentsTransluscent       Contents = 0x10000000
	ContentsLadder             Contents = 0x20000000
	ContentsHitbox             Contents = 0x40000000
)

type Cubemap

type Cubemap struct {
	Origin  [3]int32
	Size    uint8 // 0 - default; otherwise, 1<<(size-1)
	Padding [3]byte
}

type DetailProp

type DetailProp struct {
	Origin          Vector
	Angles          QAngle
	DetailModel     uint16 // either index into Names or Sprites
	Leaf            uint16
	Lighting        ColorRGBExp32
	LightStyles     uint32
	LightStyleCount uint8
	SwayAmount      uint8 // how much do the details sway
	ShapeAngle      uint8 // angle param for shaped sprites
	ShapeSize       uint8 // size param for shaped sprites
	Orientation     DetailPropOrientation
	Padding2        [3]byte
	Type            DetailPropType
	Padding3        [3]byte
	Scale           float32 // For sprites only currently
}

type DetailPropInfo

type DetailPropInfo struct {
	Names   []string
	Sprites []DetailSprite
	Props   []DetailProp
}

type DetailPropLighting

type DetailPropLighting struct {
	Lighting ColorRGBExp32
	Style    uint8
}

type DetailPropOrientation

type DetailPropOrientation uint8
const (
	OrientNormal                DetailPropOrientation = 0
	OrientScreenAligned         DetailPropOrientation = 1
	OrientScreenAlignedVertical DetailPropOrientation = 2
)

type DetailPropType

type DetailPropType uint8
const (
	DetailPropTypeModel      DetailPropType = 0
	DetailPropTypeSprite     DetailPropType = 1
	DetailPropTypeShapeCross DetailPropType = 2
	DetailPropTypeShapeTri   DetailPropType = 3
)

type DetailSprite

type DetailSprite struct {
	UL    Vector2D // Coordinate of upper left
	LR    Vector2D // Coordinate of lower right
	TexUL Vector2D // Texcoords of upper left
	TexLR Vector2D // Texcoords of lower left
}

type DispCornerNeighbors

type DispCornerNeighbors struct {
	Neighbors    [4]uint16 // indices of neighbors.
	NumNeighbors uint8
	Padding      [1]byte
}

type DispInfo

type DispInfo struct {
	StartPosition               Vector   // start position used for orientation -- (added BSPVERSION 6)
	DispVertStart               int32    // Index into DispVerts.
	DispTriStart                int32    // Index into DispTris.
	Power                       int32    // power - indicates size of map (2^power + 1)
	MinTess                     int32    // minimum tesselation allowed
	SmoothingAngle              float32  // lighting smoothing angle
	Contents                    Contents // surface contents
	MapFace                     uint16   // Which map face this displacement comes from.
	Padding                     [2]byte
	LightmapAlphaStart          int32                  // Index into ddisplightmapalpha. The count is m_pParent->lightmapTextureSizeInLuxels[0]*m_pParent->lightmapTextureSizeInLuxels[1].
	LightmapSamplePositionStart int32                  // Index into DispLightmapSamplePositions.
	EdgeNeighbors               [4]DispNeighbor        // Indexed by NeighborEdge enum.
	CornerNeighbors             [4]DispCornerNeighbors // Indexed by NeighborCorner enum.
	AllowedVerts                [10]uint32             // This is built based on the layout and sizes of our neighbors and tells us which vertices are allowed to be active.
}

type DispMultiBlend

type DispMultiBlend struct {
	MultiBlend       Vector4D
	AlphaBlend       Vector4D
	MultiBlendColors [4]Vector
}

type DispNeighbor

type DispNeighbor struct {
	SubNeighbors [2]DispSubNeighbor
}

type DispSubNeighbor

type DispSubNeighbor struct {
	Neighbor            uint16              // This indexes into DispInfo. 0xFFFF if there is no neighbor here.
	NeighborOrientation NeighborOrientation // (CCW) rotation of the neighbor wrt this displacement.
	Span                NeighborSpan        // Where the neighbor fits onto this side of our displacement.
	NeighborSpan        NeighborSpan        // Where we fit onto our neighbor.
	Padding             [1]byte
}

type DispTri

type DispTri struct {
	Flags DispTriFlags
}

type DispTriFlags

type DispTriFlags uint16
const (
	DispTriFlagSurface   DispTriFlags = 0x1
	DispTriFlagWalkable  DispTriFlags = 0x2
	DispTriFlagBuildable DispTriFlags = 0x4
	DispTriFlagSurfProp1 DispTriFlags = 0x8
	DispTriFlagSurfProp2 DispTriFlags = 0x10
	DispTriFlagSurfProp3 DispTriFlags = 0x20
	DispTriFlagSurfProp4 DispTriFlags = 0x40
)

type DispVert

type DispVert struct {
	Vector Vector  // Vector field defining displacement volume.
	Dist   float32 // Displacement distances.
	Alpha  float32 // "per vertex" alpha values.
}

type EPair

type EPair struct {
	Key   string
	Value string
}

type Edge

type Edge struct {
	Vertex [2]uint16
}

type Entity

type Entity struct {
	Pairs []EPair
}

type Face

type Face struct {
	PlaneNum                    uint16
	Side                        uint8 // faces opposite to the node's plane direction
	OnNode                      uint8 // 1 of on node, 0 if in leaf
	FirstEdge                   int32 // we must support > 64k edges
	NumEdges                    int16
	TexInfo                     int16
	DispInfo                    int16
	SurfaceFogVolumeID          int16
	Styles                      [4]uint8
	LightOfs                    int32 // start of [numstyles*surfsize] samples
	Area                        float32
	LightmapTextureMinsInLuxels [2]int32
	LightmapTextureSizeInLuxels [2]int32
	OrigFace                    int32  // reference the original face this face was derived from
	NumPrims                    uint16 // Top bit, if set, disables shadows on this surface
	FirstPrimID                 uint16
	SmoothingGroups             uint32
}

type FaceID

type FaceID struct {
	HammerID uint16
}

type File

type File struct {
	Entities []Entity
	PakFile  *zip.Reader
	Flags    MapFlags

	// world geometry
	Planes              []Plane
	Vertexes            []Vertex
	FaceIDs             []FaceID
	Edges               []Edge
	SurfEdges           []SurfEdge
	BrushModels         []BrushModel
	Brushes             []Brush
	BrushSides          []BrushSide
	OriginalFaces       []Face
	VertNormals         []Vector
	VertNormalIndices   []uint16
	Primitives          []Primitive
	PrimVerts           []PrimVert
	PrimIndices         []uint16
	Overlays            []Overlay
	WaterOverlays       []WaterOverlay
	OverlayFades        []OverlayFade
	OverlaySystemLevels []OverlaySystemLevel

	// displacements
	DispInfo                    []DispInfo
	DispVerts                   []DispVert
	DispLightmapSamplePositions []byte
	DispTris                    []DispTri
	DispMultiBlend              []DispMultiBlend
	PhysDisp                    [][]byte

	// texture data
	TexData       []TexData
	TexInfo       []TexInfo
	Cubemaps      []Cubemap
	TexNames      []string
	FaceTextureID []uint16

	// visibility data
	PV                 PotentialVisibilityInfo
	Occlusion          OcclusionInfo
	Nodes              []Node
	Leafs              []Leaf
	LeafFaces          []uint16
	LeafBrushes        []uint16
	Areas              []Area
	AreaPortals        []AreaPortal
	LeafWaterData      []LeafWaterData
	ClipPortalVerts    []Vector
	LeafMinDistToWater []uint16

	// lighting data
	LDR LightingInfo
	HDR LightingInfo

	// props
	StaticProps StaticPropInfo
	DetailProps DetailPropInfo
}

func (*File) ReadFrom

func (f *File) ReadFrom(r io.ReaderAt) error

type Leaf

type Leaf struct {
	Contents        Contents
	Cluster         int16
	AreaFlags       uint16   // top 9 bits area bottom 7 bits flags
	Mins            [3]int16 // for frustum culling
	Maxs            [3]int16
	FirstLeafFace   uint16
	NumLeafFaces    uint16
	FirstLeafBrush  uint16
	NumLeafBrushes  uint16
	LeafWaterDataID int16 // -1 for not in water
	Padding         [2]byte
}

type LeafAmbientIndex

type LeafAmbientIndex struct {
	AmbientSampleCount uint16
	FirstAmbientSample uint16
}

type LeafAmbientLighting

type LeafAmbientLighting struct {
	Cube     CompressedLightCube
	X, Y, Z  uint8 // fixed point fraction of leaf bounds
	Reserved byte
}

each leaf contains N samples of the ambient lighting each sample contains a cube of ambient light projected on to each axis and a sampling position encoded as a 0.8 fraction (mins=0,maxs=255) of the leaf's bounding box

type LeafWaterData

type LeafWaterData struct {
	SurfaceZ     float32
	MinZ         float32
	SurfaceTexID int16
	Padding      [2]byte
}

type LevelFlags

type LevelFlags uint32
const (
	LevelFlagsBakedStaticPropLightingNonHDR LevelFlags = 0x00000001 // was processed by vrad with -staticproplighting, no hdr data
	LevelFlagsBakedStaticPropLightingHDR    LevelFlags = 0x00000002 // was processed by vrad with -staticproplighting, in hdr
)

type LightingInfo

type LightingInfo struct {
	Faces               []Face
	Lighting            []ColorRGBExp32
	WorldLights         []WorldLight
	LeafAmbientIndex    []LeafAmbientIndex
	LeafAmbientLighting []LeafAmbientLighting
	DetailPropLighting  []DetailPropLighting
}

type MapFlags

type MapFlags struct {
	Level LevelFlags
}

type NeighborCorner

type NeighborCorner uint8
const (
	NeighborCornerLowerLeft  NeighborCorner = 0
	NeighborCornerUpperLeft  NeighborCorner = 1
	NeighborCornerUpperRight NeighborCorner = 2
	NeighborCornerLowerRight NeighborCorner = 3
)

type NeighborEdge

type NeighborEdge uint8
const (
	NeighborEdgeLeft   NeighborEdge = 0
	NeighborEdgeTop    NeighborEdge = 1
	NeighborEdgeRight  NeighborEdge = 2
	NeighborEdgeBottom NeighborEdge = 3
)

type NeighborOrientation

type NeighborOrientation uint8
const (
	OrientationCCW0   NeighborOrientation = 0
	OrientationCCW90  NeighborOrientation = 1
	OrientationCCW180 NeighborOrientation = 2
	OrientationCCW270 NeighborOrientation = 3
)

type NeighborSpan

type NeighborSpan uint8
const (
	CornerToCorner   NeighborSpan = 0
	CornerToMidpoint NeighborSpan = 1
	MidpointToCorner NeighborSpan = 2
)

type Node

type Node struct {
	PlaneNum  int32
	Children  [2]int32 // negative numbers are -(leafs+1), not nodes
	Mins      [3]int16 // for frustum culling
	Maxs      [3]int16
	FirstFace uint16
	NumFaces  uint16 // counting both sides
	Area      int16  // If all leaves below this node are in the same area, then this is the area index. If not, this is -1.
	Padding   [2]byte
}

type Occluder

type Occluder struct {
	Flags     int32
	FirstPoly int32 // index into Polys
	PolyCount int32
	Mins      Vector
	Maxs      Vector
	Area      int32
}

type OccluderPoly

type OccluderPoly struct {
	FirstVertexIndex int32 // index into VertIndices
	VertexCount      int32
	PlaneNum         int32
}

type OcclusionInfo

type OcclusionInfo struct {
	Occluders   []Occluder
	Polys       []OccluderPoly
	VertIndices []int32
}

type Overlay

type Overlay struct {
	ID                      int32
	TexInfo                 int16
	FaceCountAndRenderOrder uint16 // top 2 bits are render order
	Faces                   [64]int32
	U                       Vector2D
	V                       Vector2D
	UVPoints                [4]Vector
	Origin                  Vector
	BasisNormal             Vector
}

type OverlayFade

type OverlayFade struct {
	FadeDistMinSq float32
	FadeDistMaxSq float32
}

type OverlaySystemLevel

type OverlaySystemLevel struct {
	MinCPULevel uint8
	MaxCPULevel uint8
	MinGPULevel uint8
	MaxGPULevel uint8
}

type Plane

type Plane struct {
	Normal   Vector
	Distance float32
	Type     PlaneType
}

type PlaneType

type PlaneType int32
const (
	// 0-2 are axial planes
	PlaneX PlaneType = 0
	PlaneY PlaneType = 1
	PlaneZ PlaneType = 2

	// 3-5 are non-axial planes snapped to the nearest
	PlaneAnyX PlaneType = 3
	PlaneAnyY PlaneType = 4
	PlaneAnyZ PlaneType = 5
)

type PotentialVisibilityInfo

type PotentialVisibilityInfo struct {
	Clusters []VisClusterOffsets
	Bits     []byte
}

type PrimVert

type PrimVert struct {
	Position Vector
}

type Primitive

type Primitive struct {
	Type       PrimitiveType
	Padding    [1]byte
	FirstIndex uint16
	IndexCount uint16
	FirstVert  uint16
	VertCount  uint16
}

type PrimitiveType

type PrimitiveType uint8
const (
	PrimTriList  PrimitiveType = 0
	PrimTriStrip PrimitiveType = 1
)

type QAngle

type QAngle struct {
	Pitch, Yaw, Roll float32
}

type Solid

type Solid uint8
const (
	SolidNone     Solid = 0
	SolidBSP      Solid = 1
	SolidBBox     Solid = 2
	SolidVPhysics Solid = 6
)

type StaticProp

type StaticProp struct {
	Origin            Vector
	Angles            QAngle
	PropType          uint16
	FirstLeaf         uint16
	LeafCount         uint16
	Solid             Solid
	Flags             StaticPropFlags
	Skin              int32
	FadeMinDist       float32
	FadeMaxDist       float32
	LightingOrigin    Vector
	ForcedFadeScale   float32
	MinCPULevel       uint8
	MaxCPULevel       uint8
	MinGPULevel       uint8
	MaxGPULevel       uint8
	DiffuseModulation Color32 // per instance color and alpha modulation
	DisableX360       bool
	Padding           [3]byte
}

type StaticPropFlags

type StaticPropFlags uint8
const (
	StaticPropFades             StaticPropFlags = 0x1
	StaticPropUseLightingOrigin StaticPropFlags = 0x2
	StaticPropNoDraw            StaticPropFlags = 0x4
	SttaicPropIgnoreNormals     StaticPropFlags = 0x8
	StaticPropNoShadow          StaticPropFlags = 0x10
	StaticPropNoVertexLighting  StaticPropFlags = 0x40
	StaticPropNoSelfShadowing   StaticPropFlags = 0x80
)

type StaticPropInfo

type StaticPropInfo struct {
	Names   []string
	LeafIDs []uint16
	Props   []StaticProp
}

type Surf

type Surf uint16
const (
	SurfLight     Surf = 0x0001
	SurfSky2D     Surf = 0x0002
	SurfSky       Surf = 0x0004
	SurfWarp      Surf = 0x0008
	SurfTrans     Surf = 0x0010
	SurfNoPortal  Surf = 0x0020
	SurfTrigger   Surf = 0x0040
	SurfNoDraw    Surf = 0x0080
	SurfHint      Surf = 0x0100
	SurfSkip      Surf = 0x0200
	SurfNoLight   Surf = 0x0400
	SurfBumpLight Surf = 0x0800
	SurfNoShadows Surf = 0x1000
	SurfNoDecals  Surf = 0x2000
	SurfNoChop    Surf = 0x4000
	SurfHitbox    Surf = 0x8000
)

type SurfEdge

type SurfEdge struct {
	// positive refers to Edges[Edge].Vertex[0],
	// negative to Edges[-Edge].Vertex[1].
	Edge int32
}

type TexData

type TexData struct {
	Reflectivity          Vector
	NameStringTableID     int32
	Width, Height         int32
	ViewWidth, ViewHeight int32
}

type TexInfo

type TexInfo struct {
	TextureVecsTexelsPerWorldUnits  [2][4]float32 // [s/t][xyz offset]
	LightmapVecsLuxelsPerWorldUnits [2][4]float32 // [s/t][xyz offset] - length is in units of texels/area
	Flags                           int32         // miptex flags + overrides
	TexData                         int32         // Pointer to texture name, size, etc.
}

type Vector

type Vector struct {
	Vector2D
	Z float32
}

type Vector2D

type Vector2D struct {
	X, Y float32
}

type Vector4D

type Vector4D struct {
	Vector
	W float32
}

type Vertex

type Vertex struct {
	Point Vector
}

type VisClusterOffsets

type VisClusterOffsets struct {
	Visible int32
	Audible int32
}

type WaterOverlay

type WaterOverlay struct {
	ID                      int32
	TexInfo                 int16
	FaceCountAndRenderOrder uint16 // top 2 bits are render order
	Faces                   [256]int32
	U                       Vector2D
	V                       Vector2D
	UVPoints                [4]Vector
	Origin                  Vector
	BasisNormal             Vector
}

type WorldLight

type WorldLight struct {
	Origin           Vector
	Intensity        Vector
	Normal           Vector // for surfaces and spotlights
	ShadowCastOffset Vector // gets added to the light origin when this light is used as a shadow caster (only if DWL_FLAGS_CASTENTITYSHADOWS flag is set)
	Cluster          int32
	// 0 = emit_surface, 90 degree spotlight
	// 1 = emit_point, simple point light source
	// 2 = emit_spotlight, spotlight with penumbra
	// 3 = emit_skylight, directional light with no falloff (surface must trace to SKY texture)
	// 4 = emit_quakelight, linear falloff, non-lambertian
	// 5 = emit_skyambient, spherical light source with no falloff (surface must trace to SKY texture)
	Type     int32
	Style    int32
	StopDot  float32 // start of penumbra for emit_spotlight
	StopDot2 float32 // end of penumbra for emit_spotlight
	Exponent float32
	Radius   float32 // cutoff distance
	// falloff for emit_spotlight + emit_point:
	// 1 / (ConstantAttn + LinearAttn * dist + QuadraticAttn * dist^2)
	ConstantAttn  float32
	LinearAttn    float32
	QuadraticAttn float32
	Flags         int32 // Uses a combination of the DWL_FLAGS_ defines.
	TexInfo       int32
	Owner         int32 // entity that this light is relative to
}

Jump to

Keyboard shortcuts

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