From 91a5befd3e104f927eefc6fde452237c86272900 Mon Sep 17 00:00:00 2001 From: Galaco Date: Thu, 21 Mar 2019 12:14:36 +0000 Subject: [PATCH] Improved test coverage, better code comments --- README.md | 7 +- internal/versions/v20_test.go | 5 + lump.go | 4 +- lump_test.go | 44 ++++ lumps/game.go | 5 +- primitives/area/area.go | 5 +- primitives/areaportal/areaportal.go | 16 +- primitives/brush/brush.go | 8 +- primitives/brushside/brushside.go | 9 +- primitives/common/common.go | 121 ++++++---- primitives/cubemap/cubemap.go | 8 +- primitives/dispinfo/dispinfo.go | 56 +++-- primitives/disptris/disptris.go | 2 + primitives/dispvert/dispvert.go | 9 +- primitives/face/face.go | 48 ++-- primitives/faceid/faceid.go | 2 + .../facemacrotextureinfo.go | 2 + primitives/game/game.go | 28 ++- primitives/game/game_test.go | 17 ++ primitives/game/staticprop.go | 70 ++++-- primitives/game/staticpropv10.go | 2 +- primitives/game/staticpropv10_test.go | 208 +++++++++++++++++ primitives/game/staticpropv11.go | 2 +- primitives/game/staticpropv11_test.go | 210 ++++++++++++++++++ primitives/game/staticpropv4.go | 31 +-- primitives/game/staticpropv4_test.go | 202 +++++++++++++++++ primitives/game/staticpropv5_test.go | 203 +++++++++++++++++ primitives/game/staticpropv6_test.go | 203 +++++++++++++++++ primitives/game/staticpropv7_test.go | 204 +++++++++++++++++ primitives/game/staticpropv8.go | 2 +- primitives/game/staticpropv8_test.go | 208 +++++++++++++++++ primitives/game/staticpropv9.go | 2 +- primitives/game/staticpropv9_test.go | 209 +++++++++++++++++ primitives/leaf/flags.go | 11 + primitives/leaf/leaf.go | 54 +++-- primitives/leaf/leaf_test.go | 52 +++++ .../leafambientindex/leafambientindex.go | 3 + .../leafambientlighting.go | 16 +- primitives/leafwaterdata/leafwaterdata.go | 8 +- primitives/mapflags/mapflags.go | 2 + primitives/model/model.go | 17 +- primitives/node/node.go | 24 +- primitives/overlay/overlay.go | 8 +- primitives/overlayfade/overlayfade.go | 3 + primitives/physcollide/physcollide.go | 24 +- primitives/plane/plane.go | 10 +- primitives/portal/portal.go | 29 ++- primitives/primitive/primitive.go | 12 +- primitives/primvert/primvert.go | 2 + primitives/texdata/texdata.go | 18 +- primitives/texinfo/texinfo.go | 12 +- primitives/vertnormal/vertnormal.go | 3 +- primitives/visibility/visibility.go | 23 +- primitives/visibility/visibility_test.go | 11 + primitives/wateroverlay/wateroverlay.go | 1 + primitives/worldlight/worldlight.go | 71 ++++-- 56 files changed, 2326 insertions(+), 240 deletions(-) create mode 100644 primitives/game/game_test.go create mode 100644 primitives/game/staticpropv10_test.go create mode 100644 primitives/game/staticpropv11_test.go create mode 100644 primitives/game/staticpropv4_test.go create mode 100644 primitives/game/staticpropv5_test.go create mode 100644 primitives/game/staticpropv6_test.go create mode 100644 primitives/game/staticpropv7_test.go create mode 100644 primitives/game/staticpropv8_test.go create mode 100644 primitives/game/staticpropv9_test.go create mode 100644 primitives/leaf/flags.go create mode 100644 primitives/leaf/leaf_test.go create mode 100644 primitives/visibility/visibility_test.go diff --git a/README.md b/README.md index c574f62..f8df67a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![GoDoc](https://godoc.org/github.com/Galaco/bsp?status.svg)](https://godoc.org/github.com/Galaco/bsp) [![Go report card](https://goreportcard.com/badge/github.com/galaco/bsp)](https://goreportcard.com/badge/github.com/galaco/bsp) [![GolangCI](https://golangci.com/badges/github.com/galaco/bsp.svg)](https://golangci.com) -[![Build Status](https://travis-ci.com/Galaco/bsp.svg?branch=dev)](https://travis-ci.com/Galaco/bsp) +[![Build Status](https://travis-ci.com/Galaco/bsp.svg?branch=master)](https://travis-ci.com/Galaco/bsp) [![CircleCI](https://circleci.com/gh/Galaco/bsp.svg?style=svg)](https://circleci.com/gh/Galaco/bsp) # Bsp @@ -105,8 +105,9 @@ func main() { ``` ## Real World examples -* Replace game_text newline placeholder characters (avoids Hammer crash) as a compile step: [https://github.com/Galaco/CS-GO-game_text-newline-inserter/tree/golang](https://github.com/Galaco/CS-GO-game_text-newline-inserter/tree/golang) -* Proof of concept BSP viewer: [https://github.com/Galaco/Gource-Engine](https://github.com/Galaco/Gource-Engine) +* Insert game_text newline placeholder characters (avoids Hammer crash) as a compile step: [https://github.com/Galaco/CS-GO-game_text-newline-inserter/tree/golang](https://github.com/Galaco/CS-GO-game_text-newline-inserter/tree/golang) +* Bspzip filelist generator from a mountable resource directory: [https://github.com/Galaco/bspzip-traverser](https://github.com/Galaco/bspzip-traverser) +* Proof of concept BSP viewer: [https://github.com/Galaco/Lambda-Client](https://github.com/Galaco/Lambda-Client) # Contributing diff --git a/internal/versions/v20_test.go b/internal/versions/v20_test.go index a465c0c..4a332bd 100644 --- a/internal/versions/v20_test.go +++ b/internal/versions/v20_test.go @@ -13,4 +13,9 @@ func TestGetv20Lump(t *testing.T) { reflect.TypeOf(l), reflect.TypeOf(lumps.Visibility{})) } + + _, err := Getv20Lump(65) + if err == nil { + t.Error("invalid lump index provided, but not error returned") + } } diff --git a/lump.go b/lump.go index 840bd38..78d92ea 100644 --- a/lump.go +++ b/lump.go @@ -1,9 +1,9 @@ package bsp import ( + "fmt" "github.com/galaco/bsp/internal/versions" "github.com/galaco/bsp/lumps" - "log" ) // Container for a lump. Also includes metadata about the lump. @@ -58,7 +58,7 @@ func (l *Lump) GetLength() int32 { // Return an instance of a Lump for a given offset. func getReferenceLumpByIndex(index int, version int32) (lumps.ILump, error) { if index < 0 || index > 63 { - log.Fatalf("Invalid lump index: %d provided\n", index) + return nil, fmt.Errorf("invalid lump index: %d provided", index) } return versions.GetLumpForVersion(int(version), index) diff --git a/lump_test.go b/lump_test.go index 2f5d6aa..225d81a 100644 --- a/lump_test.go +++ b/lump_test.go @@ -14,6 +14,50 @@ func TestGetReferenceLumpByIndex(t *testing.T) { } } + _, err := getReferenceLumpByIndex(65, 20) + if err == nil { + t.Error("invalid lump provided, but no error returned") + } +} + +func TestLump_GetContents(t *testing.T) { + +} + +func TestLump_GetLength(t *testing.T) { + sut := Lump{} + sut.length = 32 + if sut.GetLength() != 32 { + t.Error("incorrect length returned for lump") + } +} + +func TestLump_GetRawContents(t *testing.T) { + t.Skip() +} + +func TestLump_SetContents(t *testing.T) { + t.Skip() +} + +func TestLump_SetId(t *testing.T) { + sut := Lump{} + sut.SetId(LumpPakfile) + + if sut.index != LumpPakfile { + t.Error("incorrect lump id") + } +} + +func TestLump_SetRawContents(t *testing.T) { + sut := Lump{} + data := []byte{0, 1, 4, 3, 2} + sut.SetRawContents(data) + for idx, b := range sut.GetRawContents() { + if data[idx] != b { + t.Error("raw lump data mismatch") + } + } } func getExpectedLump(index int) lumps.ILump { diff --git a/lumps/game.go b/lumps/game.go index 94d3d1e..f53fc2b 100644 --- a/lumps/game.go +++ b/lumps/game.go @@ -30,7 +30,7 @@ func (lump *Game) Unmarshall(raw []byte, length int32) { // First reconstruct the header to be of the right size lumpCount := binary.LittleEndian.Uint32(raw[:4]) - lump.Header = lump.Header.SetLumpCount(int32(lumpCount)) + lump.Header.SetLumpCount(int32(lumpCount)) // Read header lump.Header.GameLumps = make([]primitives.LumpDef, lumpCount) @@ -84,7 +84,7 @@ func (lump *Game) Marshall() ([]byte, error) { return buf.Bytes(), err } -// This update the lumps offsets to be relative to the lump, rather +// UpdateInternalOffsets updates the lumps offsets to be relative to the lump, rather // than the bsp start func (lump *Game) UpdateInternalOffsets(fileOffset int32) *Game { lump.LumpOffset = fileOffset @@ -92,6 +92,7 @@ func (lump *Game) UpdateInternalOffsets(fileOffset int32) *Game { return lump } +// GetStaticPropLump returns the staticprop lump func (lump *Game) GetStaticPropLump() *primitives.StaticPropLump { for i, gameLump := range lump.Header.GameLumps { if gameLump.Id == primitives.StaticPropLumpId { diff --git a/primitives/area/area.go b/primitives/area/area.go index cd25b12..45f03c3 100644 --- a/primitives/area/area.go +++ b/primitives/area/area.go @@ -1,6 +1,9 @@ package area +// Area type Area struct { - NumAreaPortals int32 + // NumAreaPortals number of AreaPortals in this area + NumAreaPortals int32 + // FirstAreaPortal index of first AreaPortal FirstAreaPortal int32 } diff --git a/primitives/areaportal/areaportal.go b/primitives/areaportal/areaportal.go index 0363c8d..838e9dd 100644 --- a/primitives/areaportal/areaportal.go +++ b/primitives/areaportal/areaportal.go @@ -1,10 +1,16 @@ package areaportal +// AreaPortal type AreaPortal struct { - PortalKey uint16 // Entities have a key called portal number (and in vbsp a variable called areaportalnum) to bind them to the area portals by comparing this value - OtherArea uint16 // The area this portal looks into - FirstClipPortalVert uint16 // Portal geometry - NumClipPortalVerts uint16 - + // PortalKey - entities have a key called portal number (and in vbsp a variable called areaportalnum) to bind + // them to the area portals by comparing this value + PortalKey uint16 + // OtherArea is the area this portal looks into + OtherArea uint16 + // FirstClipPortalVert Portal geometry + FirstClipPortalVert uint16 + // NumClipPortalVerts number of geometry verts + NumClipPortalVerts uint16 + // PlaneNum PlaneNum int32 } diff --git a/primitives/brush/brush.go b/primitives/brush/brush.go index 7e7e858..c1e9a09 100644 --- a/primitives/brush/brush.go +++ b/primitives/brush/brush.go @@ -1,7 +1,11 @@ package brush +// Brush type Brush struct { + // FirstSide index of first side of a brush FirstSide int32 - NumSides int32 - Contents int32 + // NumSides is number of sides this brush has + NumSides int32 + // Contents + Contents int32 } diff --git a/primitives/brushside/brushside.go b/primitives/brushside/brushside.go index 6672f30..3656591 100644 --- a/primitives/brushside/brushside.go +++ b/primitives/brushside/brushside.go @@ -1,8 +1,13 @@ package brushside +// BrushSide type BrushSide struct { + // PlaneNum is index into planes PlaneNum uint16 - TexInfo int16 + // TexInfo is index into TexInfo slice + TexInfo int16 + // DispInfo is index into DispInfo slice DispInfo int16 - Bevel int16 + // Bevel + Bevel int16 } diff --git a/primitives/common/common.go b/primitives/common/common.go index 7247048..77b5fcb 100644 --- a/primitives/common/common.go +++ b/primitives/common/common.go @@ -5,61 +5,100 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// ColorRGBExponent32 is a 4 byte color representation (RGBExp) type ColorRGBExponent32 struct { - R uint8 - G uint8 - B uint8 + // R red + R uint8 + // G green + G uint8 + // B blue + B uint8 + // Exponent exponent Exponent int8 } -const MAX_POINTS_ON_FIXED_WINDING = 12 - -//const MAX_DISPVERTS = 0 -//const MAX_DISPTRIS = 0 - +// Winding type Winding struct { - Original int32 // qboolean = int32 + // Original + Original int32 // qboolean = int32 + // NumPoints NumPoints int32 - Points []mgl32.Vec3 + // Points + Points []mgl32.Vec3 } +// Side type Side struct { - PlaneNum int32 - TexInfo int32 - MapDisp *MapDispInfo - Winding *Winding - Original *Side - Contents int32 - Surf int32 - Visible int32 - Tested int32 - Bevel int32 - Next *Side - OrigIndex int32 - Id int32 - SmoothingGroups uint32 - AOverlayIds []int32 - AWaterOverlayIds []int32 + // PlaneNum + PlaneNum int32 + // TexInfo + TexInfo int32 + // MapDisp + MapDisp *MapDispInfo + // Winding + Winding *Winding + // Original + Original *Side + // Contents + Contents int32 + // Surf + Surf int32 + // Visible + Visible int32 + // Tested + Tested int32 + // Bevel + Bevel int32 + // Next + Next *Side + // OrigIndex + OrigIndex int32 + // Id is side Id + Id int32 + // SmoothingGroups + SmoothingGroups uint32 + // AOverlayIds + AOverlayIds []int32 + // AWaterOverlayIds + AWaterOverlayIds []int32 + // DynamicShadowsEnabled are dynamic shadows enabled for this side DynamicShadowsEnabled bool } +// MapDispInfo type MapDispInfo struct { - Face face.Face - EntityNum int32 - Power int32 - MinTess int32 + // Face + Face face.Face + // EntityNum + EntityNum int32 + // Power is power of this displacement (normally 2-4) + Power int32 + // MinTess + MinTess int32 + // SmoothingAngle SmoothingAngle float32 - UAxis mgl32.Vec3 - VAxis mgl32.Vec3 - StartPosition mgl32.Vec3 - AlphaValues []float32 - MaxDispDist float32 - DispDists []float32 - VectorDisps []mgl32.Vec3 - VectorOffsets []mgl32.Vec3 - Contents int32 - BrushSideID int32 - Flags int32 + // UAxis + UAxis mgl32.Vec3 + // VAxis + VAxis mgl32.Vec3 + // StartPosition + StartPosition mgl32.Vec3 + // AlphaValues + AlphaValues []float32 + // MaxDispDist + MaxDispDist float32 + // DispDists + DispDists []float32 + // VectorDisps + VectorDisps []mgl32.Vec3 + // VectorOffsets + VectorOffsets []mgl32.Vec3 + // Contents + Contents int32 + // BrushSideID + BrushSideID int32 + // Flags + Flags int32 // #ifdef VSVMFIO // Elevation float32 diff --git a/primitives/cubemap/cubemap.go b/primitives/cubemap/cubemap.go index 8ad3c96..1dd988c 100644 --- a/primitives/cubemap/cubemap.go +++ b/primitives/cubemap/cubemap.go @@ -4,8 +4,12 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// CubemapSample type CubemapSample struct { - Origin mgl32.Vec3 - Size byte + // Origin is sample location + Origin mgl32.Vec3 + // Size + Size byte + // AlignmentPadding - probably unused, likely exists for ensure 4byte alignment during read/write. AlignmentPadding [3]byte } diff --git a/primitives/dispinfo/dispinfo.go b/primitives/dispinfo/dispinfo.go index cc737bd..cdcfefc 100644 --- a/primitives/dispinfo/dispinfo.go +++ b/primitives/dispinfo/dispinfo.go @@ -4,39 +4,63 @@ import ( "github.com/go-gl/mathgl/mgl32" ) -const MaxDispCornerNeightbours = 4 +// MaxDispCornerNeighbours maximum number of adjoining neigherbours per corner. +const MaxDispCornerNeighbours = 4 +// DispInfo type DispInfo struct { - StartPosition mgl32.Vec3 - DispVertStart int32 - DispTriStart int32 - Power int32 - MinTess int32 - SmoothingAngle float32 - Contents int32 - MapFace uint16 - _ [2]byte - LightmapAlphaStart int32 + // StartPosition + StartPosition mgl32.Vec3 + // DispVertStart + DispVertStart int32 + // DispTriStart + DispTriStart int32 + // Power + Power int32 + // MinTess + MinTess int32 + // SmoothingAngle + SmoothingAngle float32 + // Contents + Contents int32 + // MapFace + MapFace uint16 + _ [2]byte + // LightmapAlphaStart + LightmapAlphaStart int32 + // LightmapSampleStartPosition LightmapSampleStartPosition int32 - Ignore [32]uint32 + // Ignore contains bytes with unknown purpose and representation. This should be updated as purpose id discovered + Ignore [32]uint32 //EdgeNeighbors [4]DispNeighbor //CornerNeighbors [4]DispCornerNeighbors //AllowedVerts [8]uint32 } +// DispNeighbor type DispNeighbor struct { + // SubNeighbours SubNeighbours [2]DispSubNeighbor } +// DispSubNeighbor type DispSubNeighbor struct { - Index uint16 // 0xFFFF if no neighbor + // Index + // 0xFFFF if no neighbor + Index uint16 + // NeighborOrientation NeighborOrientation uint8 - Span uint8 - NeighborSpan uint8 + // Span + Span uint8 + // NeighborSpan + NeighborSpan uint8 } +// DispCornerNeighbors type DispCornerNeighbors struct { - Neighbors [MaxDispCornerNeightbours]uint16 + // Neighbors + Neighbors [MaxDispCornerNeighbours]uint16 + // NumNeighbors is number of neighbours NumNeighbors uint8 } diff --git a/primitives/disptris/disptris.go b/primitives/disptris/disptris.go index 9c3287e..fcc852e 100644 --- a/primitives/disptris/disptris.go +++ b/primitives/disptris/disptris.go @@ -1,5 +1,7 @@ package disptris +// DispTri type DispTri struct { + // Tags Tags uint16 } diff --git a/primitives/dispvert/dispvert.go b/primitives/dispvert/dispvert.go index 5920a9c..ea6958a 100644 --- a/primitives/dispvert/dispvert.go +++ b/primitives/dispvert/dispvert.go @@ -4,8 +4,13 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// DispVert represents a single vertex on a displacement face. It defines properties +// required to compute the correct position of the displacement vertex after transformation. type DispVert struct { - Vec mgl32.Vec3 - Dist float32 + // Vec is direction of vertex from its default computed position + Vec mgl32.Vec3 + // Dist is distance of vertex from its default computed position + Dist float32 + // Alpha is the alpha value of this vertex (normally used for blend materials) Alpha float32 } diff --git a/primitives/face/face.go b/primitives/face/face.go index 53a4d1e..fa24efa 100644 --- a/primitives/face/face.go +++ b/primitives/face/face.go @@ -1,21 +1,39 @@ package face +// Face type Face struct { - Planenum uint16 - Side byte - OnNode byte - FirstEdge int32 - NumEdges int16 - TexInfo int16 - DispInfo int16 - SurfaceFogVolumeID int16 - Styles [4]byte - Lightofs int32 - Area float32 + // Planenum + Planenum uint16 + // Side + Side byte + // OnNode + OnNode byte + // FirstEdge is index into the edges lump data + FirstEdge int32 + // NumEdges is the number of edges that make up this face + NumEdges int16 + // TexInfo is index into texinfos lump + TexInfo int16 + // DispInfo is index into dispinfos lump + DispInfo int16 + // SurfaceFogVolumeID + SurfaceFogVolumeID int16 + // Styles + Styles [4]byte + // Lightofs is offset into lighting lump (-1 if unlit) + Lightofs int32 + // Area is total size of this side (units^2) + Area float32 + // LightmapTextureMinsInLuxels LightmapTextureMinsInLuxels [2]int32 + // LightmapTextureSizeInLuxels is XY size of lightmap data LightmapTextureSizeInLuxels [2]int32 - OrigFace int32 - NumPrims uint16 - FirstPrimID uint16 - SmoothingGroups uint32 + // OrigFace + OrigFace int32 + // NumPrims + NumPrims uint16 + // FirstPrimID + FirstPrimID uint16 + // SmoothingGroups + SmoothingGroups uint32 } diff --git a/primitives/faceid/faceid.go b/primitives/faceid/faceid.go index 190f699..a100acd 100644 --- a/primitives/faceid/faceid.go +++ b/primitives/faceid/faceid.go @@ -1,5 +1,7 @@ package faceid +// FaceId type FaceId struct { + // HammerFaceId HammerFaceId uint16 } diff --git a/primitives/facemacrotextureinfo/facemacrotextureinfo.go b/primitives/facemacrotextureinfo/facemacrotextureinfo.go index 2945f97..92f4935 100644 --- a/primitives/facemacrotextureinfo/facemacrotextureinfo.go +++ b/primitives/facemacrotextureinfo/facemacrotextureinfo.go @@ -1,5 +1,7 @@ package facemacrotextureinfo +// FaceMacroTextureInfo type FaceMacroTextureInfo struct { + // MacroTextureNameId MacroTextureNameId uint16 } diff --git a/primitives/game/game.go b/primitives/game/game.go index fdc894f..abaedf1 100644 --- a/primitives/game/game.go +++ b/primitives/game/game.go @@ -1,27 +1,43 @@ package game +// StaticPropLumpId is the identifier of the staticprop lump stored const StaticPropLumpId = 1936749168 +// Header type Header struct { + // LumpCount is the number of data lumps contained in the game lump LumpCount int32 - GameLumps []LumpDef // Slice length must equal lumpCount. Validation to be added + // GameLumps contains location and metadata about contained lumps + // Slice length must equal lumpCount. Validation to be added + GameLumps []LumpDef } -func (header Header) SetLumpCount(num int32) Header { +// SetLumpCount set number of lumps +func (header *Header) SetLumpCount(num int32) *Header { header.LumpCount = num header.GameLumps = make([]LumpDef, header.LumpCount) return header } +// LumpDef contains meta and location info about a lump contained within the game +// lump type LumpDef struct { - Id int32 - Flags uint16 - Version uint16 + // Id is lump id + Id int32 + // Flags is lump flags + Flags uint16 + // Versionis lump version + Version uint16 + // FileOffset is absolute offset into whole bsp FileOffset int32 + // FileLength is length of lump FileLength int32 } +// GenericGameLump represents a game lump with unknown/unmappable data type GenericGameLump struct { + // Length is length in bytes Length int32 - Data []byte + // Datais byte representation of lump data + Data []byte } diff --git a/primitives/game/game_test.go b/primitives/game/game_test.go new file mode 100644 index 0000000..a62006e --- /dev/null +++ b/primitives/game/game_test.go @@ -0,0 +1,17 @@ +package game + +import "testing" + +func TestHeader_SetLumpCount(t *testing.T) { + sut := Header{} + + sut.SetLumpCount(11) + + if sut.LumpCount != 11 { + t.Error("incorrect lump count for header") + } + + if len(sut.GameLumps) != 11 { + t.Error("failed to allocate correct number of lumps") + } +} diff --git a/primitives/game/staticprop.go b/primitives/game/staticprop.go index 7ff0a40..a177d5c 100644 --- a/primitives/game/staticprop.go +++ b/primitives/game/staticprop.go @@ -4,54 +4,94 @@ import ( "github.com/go-gl/mathgl/mgl32" ) -// Staticprop lump contains all information +// StaticPropLump contains all information // relating to staticprop entries type StaticPropLump struct { - DictLump StaticPropDictLump - LeafLump StaticPropLeafLump + // DictLump + DictLump StaticPropDictLump + // LeafLump + LeafLump StaticPropLeafLump + // PropLumps PropLumps []IStaticPropDataLump } -// Flat array that consists of a unique list of all +// StaticPropDictLump is a flat array that consists of a unique list of all // model filename+paths used by staticprops type StaticPropDictLump struct { + // DictEntries DictEntries int32 - Name []string // Slice length must equal dictEntries. Validation to be added + // Name + Name []string // Slice length must equal dictEntries. Validation to be added } -// Represents a flat array of leaf indexes for all staticprops. +// StaticPropLeafLump represents a flat array of leaf indexes for all staticprops. // A staticprop will have an offset and number on entries into the array that // specify what leafs a given staticprop is contained in. type StaticPropLeafLump struct { + // LeafEntries LeafEntries int32 - Leaf []uint16 // Slice length must equal leafEntries. Validation to be added + // Leaf + Leaf []uint16 // Slice length must equal leafEntries. Validation to be added } -// There are many different staticprop versions +// IStaticPropDataLump There are many different staticprop versions // This interface should be up to date with all possible properties // for any version. // Missing properties across version should return 0,false,"" etc type IStaticPropDataLump interface { + // GetOrigin Origin of object in world GetOrigin() mgl32.Vec3 + // GetAngles Rotation of object in world GetAngles() mgl32.Vec3 - GetUniformScale() float32 // v11 onwards + // GetUniformScale Uniform scale of object in world + // v11 onwards + GetUniformScale() float32 + // GetPropType GetPropType() uint16 + // GetFirstLeaf Index into StaticPropLeafLump GetFirstLeaf() uint16 + // GetLeafCount Number of leafs this prop is in GetLeafCount() uint16 + // GetSolid GetSolid() uint8 + // GetFlags GetFlags() uint8 + // GetSkin Skin index of this prop GetSkin() int32 + // GetFadeMinDist GetFadeMinDist() float32 + // GetFadeMaxDist GetFadeMaxDist() float32 + // GetLightingOrigin World position to sample light from. GetLightingOrigin() mgl32.Vec3 - GetForcedFadeScale() float32 // v5 onwards - GetMinDXLevel() uint16 // v6+7 only - GetMaxDXLevel() uint16 // v6+7 only + // GetForcedFadeScale + // v5 onwards + GetForcedFadeScale() float32 + // GetMinDXLevel Minimum directx level to render this prop + // v6+7 only + GetMinDXLevel() uint16 + // GetMaxDXLevel Maximum directx level to render this prop + // v6+7 only + GetMaxDXLevel() uint16 + // GetMinCPULevel Minimum CPU type to render this prop + // v8 onwards GetMinCPULevel() uint8 + // GetMaxCPULevel Maximum CPU type to render this prop + // v8 onwards GetMaxCPULevel() uint8 + // GetMinGPULevel + // v8 onwards GetMinGPULevel() uint8 + // GetMaxGPULevel + // v8 onwards GetMaxGPULevel() uint8 - GetDiffuseModulation() float32 // v7 onwards - GetUnknown() float32 // v10 onwards - GetDisableXBox360() bool // v9 onwards + // GetDiffuseModulation + // v7 onwards + GetDiffuseModulation() float32 + // GetUnknown + // v10 onwards + GetUnknown() float32 + // GetDisableXBox360 Should be disabled on xbox 360? + // v9 onwards + GetDisableXBox360() bool } diff --git a/primitives/game/staticpropv10.go b/primitives/game/staticpropv10.go index 0721c3d..0723d0a 100644 --- a/primitives/game/staticpropv10.go +++ b/primitives/game/staticpropv10.go @@ -101,7 +101,7 @@ func (l *StaticPropV10) GetMaxDXLevel() uint16 { } func (l *StaticPropV10) GetMinCPULevel() uint8 { - return l.MaxCPULevel + return l.MinCPULevel } func (l *StaticPropV10) GetMaxCPULevel() uint8 { diff --git a/primitives/game/staticpropv10_test.go b/primitives/game/staticpropv10_test.go new file mode 100644 index 0000000..c0eb0ed --- /dev/null +++ b/primitives/game/staticpropv10_test.go @@ -0,0 +1,208 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV10_GetAngles(t *testing.T) { + sut := getStaticPropV10() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV10_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV10() + if sut.GetDiffuseModulation() != 986 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV10_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV10() + if sut.GetDisableXBox360() != true { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV10_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV10() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV10_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV10() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV10_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV10() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV10_GetFlags(t *testing.T) { + sut := getStaticPropV10() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV10_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV10() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV10_GetLeafCount(t *testing.T) { + sut := getStaticPropV10() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV10_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV10() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV10_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMaxCPULevel() != 31 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV10_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV10_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMaxGPULevel() != 14 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV10_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMinCPULevel() != 1 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV10_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV10_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV10() + if sut.GetMinGPULevel() != 6 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV10_GetOrigin(t *testing.T) { + sut := getStaticPropV10() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV10_GetPropType(t *testing.T) { + sut := getStaticPropV10() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV10_GetSkin(t *testing.T) { + sut := getStaticPropV10() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV10_GetSolid(t *testing.T) { + sut := getStaticPropV10() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV10_GetUniformScale(t *testing.T) { + sut := getStaticPropV10() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV10_GetUnknown(t *testing.T) { + sut := getStaticPropV10() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV10() *StaticPropV10 { + return &StaticPropV10{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + MinCPULevel: 1, + MaxCPULevel: 31, + MinGPULevel: 6, + MaxGPULevel: 14, + DiffuseModulation: 986, + } +} diff --git a/primitives/game/staticpropv11.go b/primitives/game/staticpropv11.go index f071c6e..5d2bcd9 100644 --- a/primitives/game/staticpropv11.go +++ b/primitives/game/staticpropv11.go @@ -102,7 +102,7 @@ func (l *StaticPropV11) GetMaxDXLevel() uint16 { } func (l *StaticPropV11) GetMinCPULevel() uint8 { - return l.MaxCPULevel + return l.MinCPULevel } func (l *StaticPropV11) GetMaxCPULevel() uint8 { diff --git a/primitives/game/staticpropv11_test.go b/primitives/game/staticpropv11_test.go new file mode 100644 index 0000000..8e93179 --- /dev/null +++ b/primitives/game/staticpropv11_test.go @@ -0,0 +1,210 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV11_GetAngles(t *testing.T) { + sut := getStaticPropV11() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV11_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV11() + if sut.GetDiffuseModulation() != 986 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV11_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV11() + if sut.GetDisableXBox360() != true { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV11_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV11() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV11_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV11() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV11_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV11() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV11_GetFlags(t *testing.T) { + sut := getStaticPropV11() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV11_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV11() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV11_GetLeafCount(t *testing.T) { + sut := getStaticPropV11() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV11_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV11() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV11_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMaxCPULevel() != 31 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV11_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV11_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMaxGPULevel() != 14 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV11_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMinCPULevel() != 1 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV11_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV11_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV11() + if sut.GetMinGPULevel() != 6 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV11_GetOrigin(t *testing.T) { + sut := getStaticPropV11() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV11_GetPropType(t *testing.T) { + sut := getStaticPropV11() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV11_GetSkin(t *testing.T) { + sut := getStaticPropV11() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV11_GetSolid(t *testing.T) { + sut := getStaticPropV11() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV11_GetUniformScale(t *testing.T) { + sut := getStaticPropV11() + if sut.GetUniformScale() != 82 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV11_GetUnknown(t *testing.T) { + sut := getStaticPropV11() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV11() *StaticPropV11 { + return &StaticPropV11{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + MinCPULevel: 1, + MaxCPULevel: 31, + MinGPULevel: 6, + MaxGPULevel: 14, + DiffuseModulation: 986, + DisableXBox360: true, + UniformScale: 82, + } +} diff --git a/primitives/game/staticpropv4.go b/primitives/game/staticpropv4.go index c75fee1..d6ac2a9 100644 --- a/primitives/game/staticpropv4.go +++ b/primitives/game/staticpropv4.go @@ -4,7 +4,7 @@ import ( "github.com/go-gl/mathgl/mgl32" ) -// StaticProp v4 type +// StaticPropV4 v4 type type StaticPropV4 struct { Origin mgl32.Vec3 Angles mgl32.Vec3 @@ -19,32 +19,33 @@ type StaticPropV4 struct { LightingOrigin mgl32.Vec3 } -// Origin of object in world +// GetOrigin Origin of object in world func (l *StaticPropV4) GetOrigin() mgl32.Vec3 { return l.Origin } -// Rotation of object in world +// GetAngles Rotation of object in world func (l *StaticPropV4) GetAngles() mgl32.Vec3 { return l.Angles } -// Uniform scale of object in world +// GetUniformScale Uniform scale of object in world // Not defined in v4 func (l *StaticPropV4) GetUniformScale() float32 { return 1 } +// GetPropType func (l *StaticPropV4) GetPropType() uint16 { return l.PropType } -// Index into StaticPropLeafLump +// GetFirstLeaf Index into StaticPropLeafLump func (l *StaticPropV4) GetFirstLeaf() uint16 { return l.FirstLeaf } -// Number of leafs this prop is in +// GetLeafCount Number of leafs this prop is in func (l *StaticPropV4) GetLeafCount() uint16 { return l.LeafCount } @@ -57,22 +58,22 @@ func (l *StaticPropV4) GetFlags() uint8 { return l.Flags } -// Skin index of this prop +// GetSkin Skin index of this prop func (l *StaticPropV4) GetSkin() int32 { return l.Skin } -// Distance from prop that it starts to fade +// GetFadeMinDist Distance from prop that it starts to fade func (l *StaticPropV4) GetFadeMinDist() float32 { return l.FadeMinDist } -// Distance from prop that it is fully invisible/not rendered +// GetFadeMaxDist Distance from prop that it is fully invisible/not rendered func (l *StaticPropV4) GetFadeMaxDist() float32 { return l.FadeMaxDist } -// World position to sample light from. +// GetLightingOrigin World position to sample light from. // This may differ from prop origin func (l *StaticPropV4) GetLightingOrigin() mgl32.Vec3 { return l.LightingOrigin @@ -83,25 +84,25 @@ func (l *StaticPropV4) GetForcedFadeScale() float32 { return 0 } -// Minimum directx level to render this prop +// GetMinDXLevel Minimum directx level to render this prop // Not defined in v4 func (l *StaticPropV4) GetMinDXLevel() uint16 { return 0 } -// Maximum directx level to render this prop +// GetMaxDXLevel Maximum directx level to render this prop // Not defined in v4 func (l *StaticPropV4) GetMaxDXLevel() uint16 { return 0 } -// Minimum CPU type to render this prop +// GetMinCPULevel Minimum CPU type to render this prop // Not defined in v4 func (l *StaticPropV4) GetMinCPULevel() uint8 { return 0 } -// Maximum CPU type to render this prop +// GetMaxCPULevel Maximum CPU type to render this prop // Not defined in v4 func (l *StaticPropV4) GetMaxCPULevel() uint8 { return 0 @@ -127,7 +128,7 @@ func (l *StaticPropV4) GetUnknown() float32 { return 0 } -// Should be disabled on xbox 360 +// GetDisableXBox360 Should be disabled on xbox 360 // Not defined in v4 func (l *StaticPropV4) GetDisableXBox360() bool { return false diff --git a/primitives/game/staticpropv4_test.go b/primitives/game/staticpropv4_test.go new file mode 100644 index 0000000..4740961 --- /dev/null +++ b/primitives/game/staticpropv4_test.go @@ -0,0 +1,202 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV4_GetAngles(t *testing.T) { + sut := getStaticPropV4() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV4_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV4() + if sut.GetDiffuseModulation() != 0 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV4_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV4() + if sut.GetDisableXBox360() != false { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV4_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV4() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV4_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV4() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV4_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV4() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV4_GetFlags(t *testing.T) { + sut := getStaticPropV4() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV4_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV4() + if sut.GetForcedFadeScale() != 0 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV4_GetLeafCount(t *testing.T) { + sut := getStaticPropV4() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV4_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV4() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV4_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMaxCPULevel() != 0 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV4_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV4_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMaxGPULevel() != 0 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV4_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMinCPULevel() != 0 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV4_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV4_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV4() + if sut.GetMinGPULevel() != 0 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV4_GetOrigin(t *testing.T) { + sut := getStaticPropV4() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV4_GetPropType(t *testing.T) { + sut := getStaticPropV4() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV4_GetSkin(t *testing.T) { + sut := getStaticPropV4() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV4_GetSolid(t *testing.T) { + sut := getStaticPropV4() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV4_GetUniformScale(t *testing.T) { + sut := getStaticPropV4() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV4_GetUnknown(t *testing.T) { + sut := getStaticPropV4() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV4() *StaticPropV4 { + return &StaticPropV4{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + } +} diff --git a/primitives/game/staticpropv5_test.go b/primitives/game/staticpropv5_test.go new file mode 100644 index 0000000..b458405 --- /dev/null +++ b/primitives/game/staticpropv5_test.go @@ -0,0 +1,203 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV5_GetAngles(t *testing.T) { + sut := getStaticPropV5() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV5_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV5() + if sut.GetDiffuseModulation() != 0 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV5_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV5() + if sut.GetDisableXBox360() != false { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV5_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV5() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV5_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV5() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV5_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV5() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV5_GetFlags(t *testing.T) { + sut := getStaticPropV5() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV5_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV5() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV5_GetLeafCount(t *testing.T) { + sut := getStaticPropV5() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV5_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV5() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV5_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMaxCPULevel() != 0 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV5_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV5_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMaxGPULevel() != 0 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV5_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMinCPULevel() != 0 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV5_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV5_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV5() + if sut.GetMinGPULevel() != 0 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV5_GetOrigin(t *testing.T) { + sut := getStaticPropV5() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV5_GetPropType(t *testing.T) { + sut := getStaticPropV5() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV5_GetSkin(t *testing.T) { + sut := getStaticPropV5() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV5_GetSolid(t *testing.T) { + sut := getStaticPropV5() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV5_GetUniformScale(t *testing.T) { + sut := getStaticPropV5() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV5_GetUnknown(t *testing.T) { + sut := getStaticPropV5() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV5() *StaticPropV5 { + return &StaticPropV5{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + } +} diff --git a/primitives/game/staticpropv6_test.go b/primitives/game/staticpropv6_test.go new file mode 100644 index 0000000..bf5859a --- /dev/null +++ b/primitives/game/staticpropv6_test.go @@ -0,0 +1,203 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV6_GetAngles(t *testing.T) { + sut := getStaticPropV6() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV6_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV6() + if sut.GetDiffuseModulation() != 0 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV6_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV6() + if sut.GetDisableXBox360() != false { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV6_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV6() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV6_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV6() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV6_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV6() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV6_GetFlags(t *testing.T) { + sut := getStaticPropV6() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV6_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV6() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV6_GetLeafCount(t *testing.T) { + sut := getStaticPropV6() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV6_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV6() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV6_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMaxCPULevel() != 0 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV6_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV6_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMaxGPULevel() != 0 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV6_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMinCPULevel() != 0 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV6_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV6_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV6() + if sut.GetMinGPULevel() != 0 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV6_GetOrigin(t *testing.T) { + sut := getStaticPropV6() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV6_GetPropType(t *testing.T) { + sut := getStaticPropV6() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV6_GetSkin(t *testing.T) { + sut := getStaticPropV6() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV6_GetSolid(t *testing.T) { + sut := getStaticPropV6() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV6_GetUniformScale(t *testing.T) { + sut := getStaticPropV6() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV6_GetUnknown(t *testing.T) { + sut := getStaticPropV6() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV6() *StaticPropV6 { + return &StaticPropV6{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + } +} diff --git a/primitives/game/staticpropv7_test.go b/primitives/game/staticpropv7_test.go new file mode 100644 index 0000000..28073a0 --- /dev/null +++ b/primitives/game/staticpropv7_test.go @@ -0,0 +1,204 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV7_GetAngles(t *testing.T) { + sut := getStaticPropV7() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV7_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV7() + if sut.GetDiffuseModulation() != 986 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV7_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV7() + if sut.GetDisableXBox360() != false { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV7_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV7() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV7_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV7() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV7_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV7() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV7_GetFlags(t *testing.T) { + sut := getStaticPropV7() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV7_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV7() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV7_GetLeafCount(t *testing.T) { + sut := getStaticPropV7() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV7_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV7() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV7_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMaxCPULevel() != 0 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV7_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV7_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMaxGPULevel() != 0 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV7_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMinCPULevel() != 0 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV7_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV7_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV7() + if sut.GetMinGPULevel() != 0 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV7_GetOrigin(t *testing.T) { + sut := getStaticPropV7() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV7_GetPropType(t *testing.T) { + sut := getStaticPropV7() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV7_GetSkin(t *testing.T) { + sut := getStaticPropV7() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV7_GetSolid(t *testing.T) { + sut := getStaticPropV7() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV7_GetUniformScale(t *testing.T) { + sut := getStaticPropV7() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV7_GetUnknown(t *testing.T) { + sut := getStaticPropV7() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV7() *StaticPropV7 { + return &StaticPropV7{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + DiffuseModulation: 986, + } +} diff --git a/primitives/game/staticpropv8.go b/primitives/game/staticpropv8.go index 6e9c9a3..c77f891 100644 --- a/primitives/game/staticpropv8.go +++ b/primitives/game/staticpropv8.go @@ -98,7 +98,7 @@ func (l *StaticPropV8) GetMaxDXLevel() uint16 { } func (l *StaticPropV8) GetMinCPULevel() uint8 { - return l.MaxCPULevel + return l.MinCPULevel } func (l *StaticPropV8) GetMaxCPULevel() uint8 { diff --git a/primitives/game/staticpropv8_test.go b/primitives/game/staticpropv8_test.go new file mode 100644 index 0000000..904e836 --- /dev/null +++ b/primitives/game/staticpropv8_test.go @@ -0,0 +1,208 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV8_GetAngles(t *testing.T) { + sut := getStaticPropV8() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV8_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV8() + if sut.GetDiffuseModulation() != 986 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV8_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV8() + if sut.GetDisableXBox360() != false { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV8_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV8() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV8_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV8() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV8_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV8() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV8_GetFlags(t *testing.T) { + sut := getStaticPropV8() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV8_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV8() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV8_GetLeafCount(t *testing.T) { + sut := getStaticPropV8() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV8_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV8() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV8_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMaxCPULevel() != 31 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV8_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV8_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMaxGPULevel() != 14 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV8_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMinCPULevel() != 1 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV8_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV8_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV8() + if sut.GetMinGPULevel() != 6 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV8_GetOrigin(t *testing.T) { + sut := getStaticPropV8() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV8_GetPropType(t *testing.T) { + sut := getStaticPropV8() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV8_GetSkin(t *testing.T) { + sut := getStaticPropV8() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV8_GetSolid(t *testing.T) { + sut := getStaticPropV8() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV8_GetUniformScale(t *testing.T) { + sut := getStaticPropV8() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV8_GetUnknown(t *testing.T) { + sut := getStaticPropV8() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV8() *StaticPropV8 { + return &StaticPropV8{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + MinCPULevel: 1, + MaxCPULevel: 31, + MinGPULevel: 6, + MaxGPULevel: 14, + DiffuseModulation: 986, + } +} diff --git a/primitives/game/staticpropv9.go b/primitives/game/staticpropv9.go index 2dea1af..ce8b33b 100644 --- a/primitives/game/staticpropv9.go +++ b/primitives/game/staticpropv9.go @@ -99,7 +99,7 @@ func (l *StaticPropV9) GetMaxDXLevel() uint16 { } func (l *StaticPropV9) GetMinCPULevel() uint8 { - return l.MaxCPULevel + return l.MinCPULevel } func (l *StaticPropV9) GetMaxCPULevel() uint8 { diff --git a/primitives/game/staticpropv9_test.go b/primitives/game/staticpropv9_test.go new file mode 100644 index 0000000..5c13537 --- /dev/null +++ b/primitives/game/staticpropv9_test.go @@ -0,0 +1,209 @@ +package game + +import ( + "github.com/go-gl/mathgl/mgl32" + "testing" +) + +func TestStaticPropV9_GetAngles(t *testing.T) { + sut := getStaticPropV9() + if sut.GetAngles().X() != 2 && + sut.GetAngles().Y() != 5 && + sut.GetAngles().Z() != 8 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV9_GetDiffuseModulation(t *testing.T) { + sut := getStaticPropV9() + if sut.GetDiffuseModulation() != 986 { + t.Error("unexpected value for diffuseModulation property") + } + +} + +func TestStaticPropV9_GetDisableXBox360(t *testing.T) { + sut := getStaticPropV9() + if sut.GetDisableXBox360() != true { + t.Error("unexpected value for unknown property") + } + +} + +func TestStaticPropV9_GetFadeMaxDist(t *testing.T) { + sut := getStaticPropV9() + if sut.GetFadeMaxDist() != 256 { + t.Error("unexpected value for fadeMaxDist property") + } + +} + +func TestStaticPropV9_GetFadeMinDist(t *testing.T) { + sut := getStaticPropV9() + if sut.GetFadeMinDist() != 84.5 { + t.Error("unexpected value for fadeMinDist property") + } + +} + +func TestStaticPropV9_GetFirstLeaf(t *testing.T) { + sut := getStaticPropV9() + if sut.GetFirstLeaf() != 21 { + t.Error("unexpected value for firstLeaf property") + } + +} + +func TestStaticPropV9_GetFlags(t *testing.T) { + sut := getStaticPropV9() + if sut.GetFlags() != 85 { + t.Error("unexpected value for flags property") + } + +} + +func TestStaticPropV9_GetForcedFadeScale(t *testing.T) { + sut := getStaticPropV9() + if sut.GetForcedFadeScale() != 65 { + t.Error("unexpected value for forcedFadeScale property") + } + +} + +func TestStaticPropV9_GetLeafCount(t *testing.T) { + sut := getStaticPropV9() + if sut.GetLeafCount() != 65 { + t.Error("unexpected value for leafCount property") + } + +} + +func TestStaticPropV9_GetLightingOrigin(t *testing.T) { + sut := getStaticPropV9() + if sut.GetLightingOrigin().X() != 32 && + sut.GetLightingOrigin().Y() != 64 && + sut.GetLightingOrigin().Z() != 128 { + t.Error("unexpected value for angles property") + } +} + +func TestStaticPropV9_GetMaxCPULevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMaxCPULevel() != 31 { + t.Error("unexpected value for maxCPULevel property") + } + +} + +func TestStaticPropV9_GetMaxDXLevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMaxDXLevel() != 0 { + t.Error("unexpected value for maxDXLevel property") + } + +} + +func TestStaticPropV9_GetMaxGPULevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMaxGPULevel() != 14 { + t.Error("unexpected value for maxGPULevel property") + } + +} + +func TestStaticPropV9_GetMinCPULevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMinCPULevel() != 1 { + t.Error("unexpected value for minCPULevel property") + } + +} + +func TestStaticPropV9_GetMinDXLevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMinDXLevel() != 0 { + t.Error("unexpected value for minDXLevel property") + } + +} + +func TestStaticPropV9_GetMinGPULevel(t *testing.T) { + sut := getStaticPropV9() + if sut.GetMinGPULevel() != 6 { + t.Error("unexpected value for minGPULevel property") + } + +} + +func TestStaticPropV9_GetOrigin(t *testing.T) { + sut := getStaticPropV9() + + if sut.GetOrigin().X() != 1 && + sut.GetOrigin().Y() != 3 && + sut.GetOrigin().Z() != 6 { + t.Error("unexpected value for origin property") + } +} + +func TestStaticPropV9_GetPropType(t *testing.T) { + sut := getStaticPropV9() + if sut.GetPropType() != 11 { + t.Error("unexpected value for propType property") + } + +} + +func TestStaticPropV9_GetSkin(t *testing.T) { + sut := getStaticPropV9() + if sut.GetSkin() != 2 { + t.Error("unexpected value for skin property") + } + +} + +func TestStaticPropV9_GetSolid(t *testing.T) { + sut := getStaticPropV9() + if sut.GetSolid() != 1 { + t.Error("unexpected value for solid property") + } + +} + +func TestStaticPropV9_GetUniformScale(t *testing.T) { + sut := getStaticPropV9() + if sut.GetUniformScale() != 1 { + t.Error("unexpected value for uniformScale property") + } + +} + +func TestStaticPropV9_GetUnknown(t *testing.T) { + sut := getStaticPropV9() + if sut.GetUnknown() != 0 { + t.Error("unexpected value for unknown property") + } + +} + +func getStaticPropV9() *StaticPropV9 { + return &StaticPropV9{ + Origin: mgl32.Vec3{1, 3, 6}, + Angles: mgl32.Vec3{2, 5, 8}, + PropType: 11, + FirstLeaf: 21, + LeafCount: 65, + Solid: 1, + Flags: 85, + Skin: 2, + FadeMinDist: 84.5, + FadeMaxDist: 256, + LightingOrigin: mgl32.Vec3{32, 64, 128}, + ForcedFadeScale: 65, + MinCPULevel: 1, + MaxCPULevel: 31, + MinGPULevel: 6, + MaxGPULevel: 14, + DiffuseModulation: 986, + DisableXBox360: true, + } +} diff --git a/primitives/leaf/flags.go b/primitives/leaf/flags.go new file mode 100644 index 0000000..f8b9bc7 --- /dev/null +++ b/primitives/leaf/flags.go @@ -0,0 +1,11 @@ +package leaf + +// NOTE: Only 7-bits stored!!! +const ( + // LeafFlagsSky This leaf has 3D sky in its PVS + LeafFlagsSky = 0x01 + // LeafFlagsRadial This leaf culled away some portals due to radial vis + LeafFlagsRadial = 0x02 + // LeafFlagsSky2D This leaf has 2D sky in its PVS + LeafFlagsSky2D = 0x04 +) diff --git a/primitives/leaf/leaf.go b/primitives/leaf/leaf.go index c4e79a5..9553771 100644 --- a/primitives/leaf/leaf.go +++ b/primitives/leaf/leaf.go @@ -1,45 +1,51 @@ package leaf -const BITMASK_LOWER9 = 0x1FF // 511 (2^9 - 1) -const BITMASK_LOWER7 = 0x7F // 127 (2^7 - 1) - -// NOTE: Only 7-bits stored!!! -const LEAF_FLAGS_SKY = 0x01 // This leaf has 3D sky in its PVS -const LEAF_FLAGS_RADIAL = 0x02 // This leaf culled away some portals due to radial vis -const LEAF_FLAGS_SKY2D = 0x04 // This leaf has 2D sky in its PVS +const bitmaskLower9 = 0x1FF // 511 (2^9 - 1) +const bitmaskLower7 = 0x7F // 127 (2^7 - 1) +// Leaf type Leaf struct { - Contents int32 - Cluster int16 - BitField int16 //C Union of char Name || Area:9 && Flags:7 - Mins [3]int16 - Maxs [3]int16 - FirstLeafFace uint16 - NumLeafFaces uint16 - FirstLeafBrush uint16 - NumLeafBrushes uint16 + // Contents + Contents int32 + // Cluster that this leaf is a part of + Cluster int16 + // BitField is a C Union of char Name || Area:9 && Flags:7 + BitField int16 + // Mins is this leafs bounding volumes minimum + Mins [3]int16 + // Maxs is this leafs bounding volumes maximum + Maxs [3]int16 + // FirstLeafFace index into LeafFaces lump data + FirstLeafFace uint16 + // NumLeafFaces is number of LeafFaces in this Leaf + NumLeafFaces uint16 + // FirstLeafBrush is index into LeafBrushes lump data + FirstLeafBrush uint16 + // NumLeafBrushes is number of LeafBrushes in this Leaf + NumLeafBrushes uint16 + // LeafWaterDataID LeafWaterDataID int16 _ [2]byte } -// Get area (first 9 bits) +// Flags returns flags (second 7 bits) func (b *Leaf) Area() int16 { - return int16((b.BitField >> 9) & BITMASK_LOWER9) + return int16((b.BitField) & bitmaskLower7) } -// Set area (first 9 bits) +// SetArea sets area (first 9 bits) func (b *Leaf) SetArea(area int16) { v := b.BitField - b.BitField = int16((v & BITMASK_LOWER9) | (area)) + b.BitField = int16((v & bitmaskLower9) | (area)) } -// Get flags (second 7 bits) +// Area returns area (first 9 bits) func (b *Leaf) Flags() int16 { - return int16((b.BitField) & BITMASK_LOWER7) + return int16((b.BitField >> 9) & bitmaskLower9) } -// Set flags (second 7 bits) +// SetFlags sets flags (second 7 bits) func (b *Leaf) SetFlags(flags int16) { v := b.BitField - b.BitField = int16((v & BITMASK_LOWER7) | (int16(flags) << 9)) + b.BitField = int16((v & bitmaskLower7) | (int16(flags) << 9)) } diff --git a/primitives/leaf/leaf_test.go b/primitives/leaf/leaf_test.go new file mode 100644 index 0000000..246191b --- /dev/null +++ b/primitives/leaf/leaf_test.go @@ -0,0 +1,52 @@ +package leaf + +import ( + "log" + "testing" +) + +func TestLeaf_Area(t *testing.T) { + sut := getPrimitive() + if sut.Area() != 61 { + log.Println(sut.Area()) + t.Error("incorrect area value") + } +} + +func TestLeaf_Flags(t *testing.T) { + sut := getPrimitive() + if sut.Flags() != 46 { + log.Println(sut.Flags()) + t.Error("incorrect flags value") + } +} + +func TestLeaf_SetArea(t *testing.T) { + TestLeaf_Area(t) +} + +func TestLeaf_SetFlags(t *testing.T) { + TestLeaf_Flags(t) +} + +func getPrimitive() Leaf { + l := Leaf{} + l.Contents = 1 + l.Cluster = 2 + //l.Name = 61 // ("a")[0] + l.SetArea(61) + l.SetFlags(46) + l.Mins[0] = 3 + l.Mins[1] = 7 + l.Mins[2] = 14 + l.Maxs[0] = 13 + l.Maxs[1] = 36 + l.Maxs[2] = 51 + l.FirstLeafFace = 32 + l.NumLeafFaces = 11 + l.FirstLeafBrush = 21 + l.NumLeafBrushes = 76 + l.LeafWaterDataID = 621 + + return l +} diff --git a/primitives/leafambientindex/leafambientindex.go b/primitives/leafambientindex/leafambientindex.go index 9f64a12..a55c9a6 100644 --- a/primitives/leafambientindex/leafambientindex.go +++ b/primitives/leafambientindex/leafambientindex.go @@ -1,6 +1,9 @@ package leafambientindex +// LeafAmbientIndex type LeafAmbientIndex struct { + // AmbientSampleCount AmbientSampleCount uint16 + // FirstAmbientSample FirstAmbientSample uint16 } diff --git a/primitives/leafambientlighting/leafambientlighting.go b/primitives/leafambientlighting/leafambientlighting.go index 800d167..a43e13c 100644 --- a/primitives/leafambientlighting/leafambientlighting.go +++ b/primitives/leafambientlighting/leafambientlighting.go @@ -2,14 +2,22 @@ package leafambientlighting import primitives "github.com/galaco/bsp/primitives/common" +// LeafAmbientLighting type LeafAmbientLighting struct { + // Cube Cube CompressedLightCube - X byte - Y byte - Z byte - Pad byte + // X x + X byte + // Y y + Y byte + // Z z + Z byte + // Pad is padding to 4 bytes (any other purpose unknown) + Pad byte } +// CompressedLightCube type CompressedLightCube struct { + // Color Color [6]primitives.ColorRGBExponent32 } diff --git a/primitives/leafwaterdata/leafwaterdata.go b/primitives/leafwaterdata/leafwaterdata.go index 9d6c6c4..f3d2d84 100644 --- a/primitives/leafwaterdata/leafwaterdata.go +++ b/primitives/leafwaterdata/leafwaterdata.go @@ -1,8 +1,12 @@ package leafwaterdata +// LeafWaterData type LeafWaterData struct { - SurfaceZ float32 - MinZ float32 + // SurfaceZ + SurfaceZ float32 + // MinZ + MinZ float32 + // SurfaceTexInfoID SurfaceTexInfoID int16 _ int16 // Because struct is 4byte aligned } diff --git a/primitives/mapflags/mapflags.go b/primitives/mapflags/mapflags.go index f2c9b5d..55d6e66 100644 --- a/primitives/mapflags/mapflags.go +++ b/primitives/mapflags/mapflags.go @@ -1,5 +1,7 @@ package mapflags +// MapFlags represents flags set per map type MapFlags struct { + // LevelFlags contains all set flags LevelFlags uint32 } diff --git a/primitives/model/model.go b/primitives/model/model.go index af600a2..45050ea 100644 --- a/primitives/model/model.go +++ b/primitives/model/model.go @@ -4,11 +4,18 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// Model is a BSP root node. type Model struct { - Mins mgl32.Vec3 - Maxs mgl32.Vec3 - Origin mgl32.Vec3 - HeadNode int32 + // Mins is bounding volume smallest value corner + Mins mgl32.Vec3 + // Maxs is bounding volume largest value corner + Maxs mgl32.Vec3 + // Origin is the center/specified origin position + Origin mgl32.Vec3 + // HeadNode + HeadNode int32 + // FirstFace is index into the faces lump FirstFace int32 - NumFaces int32 + // NumFaces is number of faces in this model + NumFaces int32 } diff --git a/primitives/node/node.go b/primitives/node/node.go index 348bd42..312368e 100644 --- a/primitives/node/node.go +++ b/primitives/node/node.go @@ -1,12 +1,22 @@ package node +// Node is a bsp node that has 2 children, because it was splittable along a plane. +// It represents a convex volume with child volumes type Node struct { - PlaneNum int32 - Children [2]int32 - Mins [3]int16 - Maxs [3]int16 + // PlaneNum is index of splitting place + PlaneNum int32 + // Children are indexes of children that resulted from the split. It can reference either other Nodes or Leafs + Children [2]int32 + // Mins is bounding volume min + Mins [3]int16 + // Maxs is bounding volume maxs + Maxs [3]int16 + // FirstFace is index into faces lump data FirstFace uint16 - NumFaces uint16 - Area int16 - Padding int16 + // NumFaces is number of faces in this node + NumFaces uint16 + // Area + Area int16 + // Padding pads this structure to 4byte alignment (no other documented purpose) + Padding int16 } diff --git a/primitives/overlay/overlay.go b/primitives/overlay/overlay.go index 35f4a22..d2434c4 100644 --- a/primitives/overlay/overlay.go +++ b/primitives/overlay/overlay.go @@ -26,8 +26,12 @@ public: Vector vecBasisNormal; }; */ +// Overlay type Overlay struct { - NId int32 - NTexInfo int16 + // NId + NId int32 + // NTexInfo + NTexInfo int16 + // AlignmentPadding AlignmentPadding int16 } diff --git a/primitives/overlayfade/overlayfade.go b/primitives/overlayfade/overlayfade.go index bb51e2d..844331a 100644 --- a/primitives/overlayfade/overlayfade.go +++ b/primitives/overlayfade/overlayfade.go @@ -1,6 +1,9 @@ package overlayfade +// OverlayFade type OverlayFade struct { + // FadeDistMinSq is distance to start fading in FadeDistMinSq float32 + // FadeDistMaxSq is distance to fully fade in FadeDistMaxSq float32 } diff --git a/primitives/physcollide/physcollide.go b/primitives/physcollide/physcollide.go index 6952a4f..17d96bf 100644 --- a/primitives/physcollide/physcollide.go +++ b/primitives/physcollide/physcollide.go @@ -1,19 +1,31 @@ package physcollide +// PhysCollideEntry type PhysCollideEntry struct { + // ModelHeader ModelHeader PhysModel - Solids []Solid - TextBuffer string + // Solids + Solids []Solid + // TextBuffer + TextBuffer string } +// PhysModel type PhysModel struct { - ModelIndex int32 - DataSize int32 + // ModelIndex + ModelIndex int32 + // DataSize + DataSize int32 + // KeydataSize KeydataSize int32 - SolidCount int32 + // SolidCount + SolidCount int32 } +// Solid type Solid struct { - Size int32 + // Size + Size int32 + // CollisionBinary CollisionBinary []int32 } diff --git a/primitives/plane/plane.go b/primitives/plane/plane.go index 4ad2b79..a6cc311 100644 --- a/primitives/plane/plane.go +++ b/primitives/plane/plane.go @@ -4,8 +4,12 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// Plane represents an arbitrary plane of infinite length. type Plane struct { - Normal mgl32.Vec3 // normal vector - Distance float32 // distance from origin - AxisType int32 // plane axis identifier + // Normal is normal vector + Normal mgl32.Vec3 // normal vector + // Distance is distance from origin + Distance float32 + // AxisType is plane axis identifier + AxisType int32 } diff --git a/primitives/portal/portal.go b/primitives/portal/portal.go index d00e3c3..496b78c 100644 --- a/primitives/portal/portal.go +++ b/primitives/portal/portal.go @@ -7,16 +7,27 @@ import ( "github.com/galaco/bsp/primitives/plane" ) -const MAX_PORTALS = 65536 +// MaxPortals is the maximum number of portals that can be generated +const MaxPortals = 65536 +// Portal type Portal struct { - Id int32 - Plane plane.Plane - OnNode *node.Node - Nodes [2]*node.Node - Next [2]*Portal - Winding *common.Winding + // Id portal id + Id int32 + // Plane + Plane plane.Plane + // OnNode + OnNode *node.Node + // Nodes + Nodes [2]*node.Node + // Next + Next [2]*Portal + // Winding + Winding *common.Winding + // SideFound SideFound int32 //qboolean = int32 - Side *common.Side - Face [2]*face.Face + // Side + Side *common.Side + // Face + Face [2]*face.Face } diff --git a/primitives/primitive/primitive.go b/primitives/primitive/primitive.go index 465f738..24a308a 100644 --- a/primitives/primitive/primitive.go +++ b/primitives/primitive/primitive.go @@ -1,9 +1,15 @@ package primitive +// Primitive type Primitive struct { - Type byte + // Type + Type byte + // FirstIndex FirstIndex uint16 + // IndexCount IndexCount uint16 - FirstVert uint16 - VertCount uint16 + // FirstVert + FirstVert uint16 + // VertCount + VertCount uint16 } diff --git a/primitives/primvert/primvert.go b/primitives/primvert/primvert.go index d97e05a..9b2627c 100644 --- a/primitives/primvert/primvert.go +++ b/primitives/primvert/primvert.go @@ -4,6 +4,8 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// PrimVert type PrimVert struct { + // Pos is vertex position Pos mgl32.Vec3 } diff --git a/primitives/texdata/texdata.go b/primitives/texdata/texdata.go index 3c623ee..16ec801 100644 --- a/primitives/texdata/texdata.go +++ b/primitives/texdata/texdata.go @@ -4,12 +4,18 @@ import ( "github.com/go-gl/mathgl/mgl32" ) -// Texture properties +// TexData contains texture properties type TexData struct { - Reflectivity mgl32.Vec3 + // Reflectivity is reflectivity vector + Reflectivity mgl32.Vec3 + // NameStringTableID NameStringTableID int32 - Width int32 - Height int32 - ViewWidth int32 - ViewHeight int32 + // Width is texture width + Width int32 + // Height is texture height + Height int32 + // ViewWidth + ViewWidth int32 + // ViewHeight + ViewHeight int32 } diff --git a/primitives/texinfo/texinfo.go b/primitives/texinfo/texinfo.go index 2833d40..1e6e197 100644 --- a/primitives/texinfo/texinfo.go +++ b/primitives/texinfo/texinfo.go @@ -1,10 +1,14 @@ package texinfo -// Texture information for a face +// TexInfo contains texture information for a face // (tex, uv info, and lightmap info) type TexInfo struct { - TextureVecsTexelsPerWorldUnits [2][4]float32 + // TextureVecsTexelsPerWorldUnits is texture scale + TextureVecsTexelsPerWorldUnits [2][4]float32 + // LightmapVecsLuxelsPerWorldUnits is lightmap scale LightmapVecsLuxelsPerWorldUnits [2][4]float32 - Flags int32 - TexData int32 + // Flags + Flags int32 + // TexData is index into TexData lump data + TexData int32 } diff --git a/primitives/vertnormal/vertnormal.go b/primitives/vertnormal/vertnormal.go index d464306..ff1b3c0 100644 --- a/primitives/vertnormal/vertnormal.go +++ b/primitives/vertnormal/vertnormal.go @@ -4,7 +4,8 @@ import ( "github.com/go-gl/mathgl/mgl32" ) -// Normal for a single vertex +// VertNormal is normal for a single vertex type VertNormal struct { + // Pos is Normal for vertex Pos mgl32.Vec3 } diff --git a/primitives/visibility/visibility.go b/primitives/visibility/visibility.go index 2639bd4..cd110e3 100644 --- a/primitives/visibility/visibility.go +++ b/primitives/visibility/visibility.go @@ -1,11 +1,18 @@ package visibility -const MAX_MAP_VISIBILITY = 0x1000000 -const DVIS_PVS = 0 -const DVIS_PAS = 1 -const MAX_CLUSTER_SIZE_PER_VIS = 8 +// MaxMapVisibility +const MaxMapVisibility = 0x1000000 -// Visibility data for clusters +// VisPVS index +const VisPVS = 0 + +// VisPAS index +const VisPAS = 1 + +// MaxClusterSizePerVIS +const MaxClusterSizePerVIS = 8 + +// Vis contains visibility data for clusters // Includes both PVS (Potential Visible Set) and PAS (Potential Audible Set) type Vis struct { NumClusters int32 @@ -13,7 +20,7 @@ type Vis struct { BitVectors []byte // Compressed bit vectors, contains run-length compression PVS data } -// Get all visible clusters ids for a given cluster +// GetVisibleClusters returns all visible clusters ids for a given cluster func (vis *Vis) GetVisibleClusters(clusterId int16) (visibleClusters []int16) { pvs := vis.GetPVSForCluster(clusterId) @@ -26,11 +33,11 @@ func (vis *Vis) GetVisibleClusters(clusterId int16) (visibleClusters []int16) { return visibleClusters } -// Decompress vis data for a given cluster +// GetPVSForCluster decompresses vis data for a given cluster // see https://developer.valvesoftware.com/wiki/Source_BSP_File_Format#Visibility for more func (vis *Vis) GetPVSForCluster(clusterId int16) []bool { visibleClusterIds := make([]bool, vis.NumClusters) - v := vis.ByteOffset[clusterId][0] // pvs offset for cluster + v := vis.ByteOffset[clusterId][VisPVS] // pvs offset for cluster for currentClusterIdx := int32(0); currentClusterIdx < vis.NumClusters; v++ { if int(vis.BitVectors[v]) == 0 { diff --git a/primitives/visibility/visibility_test.go b/primitives/visibility/visibility_test.go new file mode 100644 index 0000000..04df3d0 --- /dev/null +++ b/primitives/visibility/visibility_test.go @@ -0,0 +1,11 @@ +package visibility + +import "testing" + +func TestVis_GetVisibleClusters(t *testing.T) { + t.Skip() +} + +func TestVis_GetPVSForCluster(t *testing.T) { + t.Skip() +} diff --git a/primitives/wateroverlay/wateroverlay.go b/primitives/wateroverlay/wateroverlay.go index 33c02cb..9a0494a 100644 --- a/primitives/wateroverlay/wateroverlay.go +++ b/primitives/wateroverlay/wateroverlay.go @@ -33,5 +33,6 @@ public: }; */ +// WaterOverlay type WaterOverlay struct { } diff --git a/primitives/worldlight/worldlight.go b/primitives/worldlight/worldlight.go index e7b11bf..dc0aff2 100644 --- a/primitives/worldlight/worldlight.go +++ b/primitives/worldlight/worldlight.go @@ -4,33 +4,58 @@ import ( "github.com/go-gl/mathgl/mgl32" ) +// EmitType light emission mode. type EmitType uint8 // assumed this is 1 byte.. -const EMIT_SURFACE EmitType = 0 // 90 degree spotlight -const EMIT_POINT EmitType = 1 // simple point light source -const EMIT_SPOTLIGHT EmitType = 2 // spotlight with penumbra -const EMIT_SKYLIGHT EmitType = 3 // directional light with no falloff (surface must trace to SKY texture) -const EMIT_QUAKELIGHT EmitType = 4 // linear falloff, non-lambertian -const EMIT_SKYAMBIENT EmitType = 5 // spherical light source with no falloff (surface must trace to SKY texture) +const ( + // EmitSurface 90 degree spotlight + EmitSurface EmitType = 0 + // EmitPoint simple point light source + EmitPoint EmitType = 1 + // EmitSpotLight spotlight with penumbra + EmitSpotLight EmitType = 2 + // EmitSkyLight directional light with no falloff (surface must trace to SKY texture) + EmitSkyLight EmitType = 3 + // EmitQuakeLight linear falloff, non-lambertian + EmitQuakeLight EmitType = 4 + // EmitSkyAmbient spherical light source with no falloff (surface must trace to SKY texture) + EmitSkyAmbient EmitType = 5 +) -// A single light in the world +// WorldLight is a single light in the world // This data may also be stored in entdata type WorldLight struct { - Origin mgl32.Vec3 - Intensity mgl32.Vec3 - Normal mgl32.Vec3 - Cluster int32 - Type EmitType //Think for alignments sake with is uint8. May be 3 bytes padding... - _ [3]byte - Style int32 - Stopdot float32 - Stopdot2 float32 - Exponent float32 - Radius float32 - ConstantAttenuation float32 - LinearAttenuation float32 + // Origin is position in the world + Origin mgl32.Vec3 + // Intensity + Intensity mgl32.Vec3 + // Normal + Normal mgl32.Vec3 + // Cluster + Cluster int32 + // Type + Type EmitType //Think for alignments sake with is uint8. May be 3 bytes padding... + _ [3]byte + // Style + Style int32 + // Stopdot + Stopdot float32 + // Stopdot2 + Stopdot2 float32 + // Exponent + Exponent float32 + // Radius + Radius float32 + // ConstantAttenuation + ConstantAttenuation float32 + // LinearAttenuation + LinearAttenuation float32 + // QuadraticAttenuation QuadraticAttenuation float32 - Flags int32 - TexInfo int32 - Owner int32 + // Flags + Flags int32 + // TexInfo + TexInfo int32 + // Owner + Owner int32 }