Documentation ¶
Overview ¶
Package bsptracer implements Ray-Tracing / Ray-Casting on top of github.com/Galaco/bsp. This is a port of https://github.com/ReactiioN1337/valve-bsp-parser.
Index ¶
Examples ¶
Constants ¶
const ( SolidNone = 0 SolidBSP = 1 SolidBBox = 2 SolidOBB = 3 SolidOBBYaw = 4 SolidCustom = 5 SolidVPhysics = 6 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a loaded BSP map.
func LoadMap ¶
LoadMap loads a map from a BSP file and VPKs. May return MissingModelsError if models can't be found - this is not fatal and the map can still be used.
func LoadMapFromFileSystem ¶
LoadMapFromFileSystem loads a BSP map from the file system. vpkPaths is a list of paths to either single or multi VPKs to load models, in order of priority. for CS:GO, vpkPaths should be paths to ("SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo/pak01", "SteamLibrary/steamapps/common/Counter-Strike Global Offensive/platform/platform_pak01") See also LoadMap()
func (Map) IsVisible ¶
IsVisible returns true if destination is visible from origin, as computed by a ray trace.
Example ¶
package main import ( "fmt" "os" "github.com/go-gl/mathgl/mgl32" "github.com/saiko-tech/bsp-tracer/pkg/bsptracer" ) func main() { csgoDir := os.Getenv("CSGO_DIR") // should point to "SteamLibrary/steamapps/common/Counter-Strike Global Offensive" m, err := bsptracer.LoadMapFromFileSystem(csgoDir+"/csgo/maps/de_cache.bsp", csgoDir+"/csgo/pak01", csgoDir+"/platform/platform_pak01") if err != nil { panic(err) } fmt.Println("A site -> A site, open:", m.IsVisible(mgl32.Vec3{-12, 1444, 1751}, mgl32.Vec3{-233, 1343, 1751})) // true fmt.Println("T spawn -> A site:", m.IsVisible(mgl32.Vec3{3306, 431, 1723}, mgl32.Vec3{-233, 1343, 1751})) // false fmt.Println("mid through box:", m.IsVisible(mgl32.Vec3{-94, 452, 1677}, mgl32.Vec3{138, 396, 1677})) // false fmt.Println("T spawn -> T spawn:", m.IsVisible(mgl32.Vec3{3306, 431, 1723}, mgl32.Vec3{3300, 400, 1720})) // true }
Output:
type MissingModelsError ¶
type MissingModelsError struct {
// contains filtered or unexported fields
}
func (MissingModelsError) Error ¶
func (m MissingModelsError) Error() string