maps

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LMID_AMBIENT byte = 0
	LMID_AMBIENT1
	LMID_BRIGHT
	LMID_BRIGHT1
	LMID_DARK
	LMID_DARK1
	LMID_RESERVED
)
View Source
const (
	LAYER_TOP    byte = (1 << 5)
	LAYER_BOTTOM      = (1 << 6)
	LAYER_DUP         = (1 << 7)
	LAYER_BLEND       = LAYER_TOP | LAYER_BOTTOM
	MAXFACEVERTS      = 15
)
View Source
const (
	ET_EMPTY        byte = iota
	ET_LIGHT             = iota
	ET_MAPMODEL          = iota
	ET_PLAYERSTART       = iota
	ET_ENVMAP            = iota
	ET_PARTICLES         = iota
	ET_SOUND             = iota
	ET_SPOTLIGHT         = iota
	ET_GAMESPECIFIC      = iota
)
View Source
const (
	OCTSAV_CHILDREN byte = iota
	OCTSAV_EMPTY         = iota
	OCTSAV_SOLID         = iota
	OCTSAV_NORMAL        = iota
	OCTSAV_LODCUB        = iota
)
View Source
const (
	VSLOT_SHPARAM  byte = iota
	VSLOT_SCALE         = iota
	VSLOT_ROTATION      = iota
	VSLOT_OFFSET        = iota
	VSLOT_SCROLL        = iota
	VSLOT_LAYER         = iota
	VSLOT_ALPHA         = iota
	VSLOT_COLOR         = iota
	VSLOT_NUM           = iota
)
View Source
const (
	MATF_INDEX_SHIFT  = 0
	MATF_VOLUME_SHIFT = 2
	MATF_CLIP_SHIFT   = 5
	MATF_FLAG_SHIFT   = 8

	MATF_INDEX  = 3 << MATF_INDEX_SHIFT
	MATF_VOLUME = 7 << MATF_VOLUME_SHIFT
	MATF_CLIP   = 7 << MATF_CLIP_SHIFT
	MATF_FLAGS  = 0xFF << MATF_FLAG_SHIFT
	MAT_AIR     = 0                      // the default, fill the empty space with air
	MAT_WATER   = 1 << MATF_VOLUME_SHIFT // fill with water, showing waves at the surface
	MAT_LAVA    = 2 << MATF_VOLUME_SHIFT // fill with lava
	MAT_GLASS   = 3 << MATF_VOLUME_SHIFT // behaves like clip but is blended blueish

	MAT_NOCLIP   = 1 << MATF_CLIP_SHIFT // collisions always treat cube as empty
	MAT_CLIP     = 2 << MATF_CLIP_SHIFT // collisions always treat cube as solid
	MAT_GAMECLIP = 3 << MATF_CLIP_SHIFT // game specific clip material

	MAT_DEATH = 1 << MATF_FLAG_SHIFT // force player suicide
	MAT_ALPHA = 4 << MATF_FLAG_SHIFT // alpha blended
)
View Source
const (
	F_EMPTY uint32 = 0
	F_SOLID        = 0x80808080
)
View Source
const (
	DEFAULT_SKY = iota
	DEFAULT_GEOM
)

hardcoded texture numbers

View Source
const CUBE_FACTOR = 8

Variables

View Source
var DEFAULT_MAP_SLOTS []byte

This is generated using: sourdump -type cfg -index default.textures data/default_map_settings.cfg (that is not the full command, you should be able to infer it though)

Functions

func InsideWorld

func InsideWorld(size int32, vector Vector) bool

func LoadDefaultSlots

func LoadDefaultSlots(map_ *GameMap) error

func LoadPartial

func LoadPartial(p *gIO.Buffer, header Header) (worldio.MapState, error)

func MapToCXX

func MapToCXX(cube *Cube) worldio.Cube

func SaveChildren

func SaveChildren(p *io.Buffer, cube *Cube, size int32) error

func SavePartial

func SavePartial(p *io.Buffer, header Header, state worldio.MapState) error

Types

type BVec

type BVec struct {
	X byte
	Y byte
	Z byte
}

type CCube

type CCube worldio.Cube

type Cube

type Cube struct {
	Children    []*Cube
	SurfaceInfo [6]SurfaceInfo
	Edges       [12]byte
	Texture     [6]uint16
	Material    uint16
	Merged      byte
	Escaped     byte
}

func EmptyMap

func EmptyMap(scale int) *Cube

func MapToGo

func MapToGo(parent worldio.Cube) *Cube

func NewCubes

func NewCubes(face uint32, mat uint16) *Cube

func (*Cube) Count

func (c *Cube) Count() uint

func (*Cube) EmptyFaces

func (c *Cube) EmptyFaces()

func (*Cube) GetFace

func (c *Cube) GetFace(n int) uint32

func (*Cube) IsEmpty

func (c *Cube) IsEmpty() bool

func (*Cube) IsEntirelySolid

func (c *Cube) IsEntirelySolid() bool

func (*Cube) Print

func (c *Cube) Print()

func (*Cube) SetFace

func (c *Cube) SetFace(n int, val uint32)

func (*Cube) SetFaces

func (c *Cube) SetFaces(val uint32)

func (*Cube) SolidFaces

func (c *Cube) SolidFaces()

type Entity

type Entity struct {
	Position Vector
	Attr1    int16
	Attr2    int16
	Attr3    int16
	Attr4    int16
	Attr5    int16
	Type     C.EntityType
	Reserved byte
}

type FileHeader

type FileHeader struct {
	Magic      [4]byte
	Version    int32
	HeaderSize int32
	WorldSize  int32
	NumEnts    int32
	NumPVs     int32
	LightMaps  int32
}

type GameMap

type GameMap struct {
	Header    Header
	Entities  []Entity
	Vars      V.Variables
	WorldRoot *Cube
	VSlots    []*VSlot
	C         worldio.MapState
}

func BasicsFromGZ

func BasicsFromGZ(data []byte) (*GameMap, error)

func Decode

func Decode(data []byte) (*GameMap, error)

func DecodeBasics

func DecodeBasics(data []byte) (*GameMap, error)

func FromFile

func FromFile(filename string) (*GameMap, error)

func FromGZ

func FromGZ(data []byte) (*GameMap, error)

func NewMap

func NewMap() (*GameMap, error)

func (*GameMap) Destroy

func (m *GameMap) Destroy()

func (*GameMap) Encode

func (m *GameMap) Encode() ([]byte, error)

func (*GameMap) EncodeOGZ

func (m *GameMap) EncodeOGZ() ([]byte, error)

func (*GameMap) ToAPI

func (m *GameMap) ToAPI() (*api.Map, error)

func (*GameMap) ToFile

func (m *GameMap) ToFile(path string) error
type Header struct {
	Version    int32
	HeaderSize int32
	WorldSize  int32
	LightMaps  int32
	BlendMap   int32
	NumVars    int32
	NumPVs     int32
	NumVSlots  int32
	GameType   string
}

func NewHeader

func NewHeader() *Header

type IVec2

type IVec2 struct {
	X int32
	Y int32
}

type MergeCompat

type MergeCompat struct {
	U1 uint16
	U2 uint16
	V1 uint16
	V2 uint16
}

type NewFooter

type NewFooter struct {
	BlendMap  int32
	NumVars   int32
	NumVSlots int32
}

type NormalsCompat

type NormalsCompat struct {
	Normals [4]BVec
}

type OldFooter

type OldFooter struct {
	LightPrecision int32
	LightError     int32
	LightLOD       int32
	Ambient        byte
	WaterColor     [3]byte
	BlendMap       byte
	LerpAngle      byte
	LerpSubDiv     byte
	LerpSubDivSize byte
	BumpError      byte
	SkyLight       [3]byte
	LavaColor      [3]byte
	WaterfallColor [3]byte
	Reserved       [10]byte
	MapTitle       [128]byte
}

For versions <=28

type Slot

type Slot struct {
	Index    int32
	Sts      []TexSlot
	Variants *VSlot
	Loaded   bool
}

func NewSlot

func NewSlot() *Slot

func (*Slot) AddSts

func (slot *Slot) AddSts(name string) *TexSlot

type SlotShaderParam

type SlotShaderParam struct {
	Name string
	Loc  int32
	Val  [4]float32
}

type SurfaceCompat

type SurfaceCompat struct {
	TexCoords [8]byte
	Width     byte
	Height    byte
	X         uint16
	Y         uint16
	Lmid      byte
	Layer     byte
}

type SurfaceInfo

type SurfaceInfo struct {
	Lmid     [2]byte
	Verts    byte
	NumVerts byte
}

func (*SurfaceInfo) TotalVerts

func (surface *SurfaceInfo) TotalVerts() byte

type TexSlot

type TexSlot struct {
	Name string
}

type VSlot

type VSlot struct {
	Index      int32
	Changed    int32
	Layer      int32
	Next       *VSlot
	Slot       *Slot
	Params     []SlotShaderParam
	Linked     bool
	Scale      float32
	Rotation   int32
	Offset     IVec2
	Scroll     Vec2
	AlphaFront float32
	AlphaBack  float32
	ColorScale Vector
	GlowColor  Vector
}

func NewVSlot

func NewVSlot(owner *Slot, index int32) *VSlot

func VSlotsToGo

func VSlotsToGo(state worldio.MapState) []*VSlot

func (*VSlot) AddVariant

func (vslot *VSlot) AddVariant(slot *Slot)

type Vec2

type Vec2 struct {
	X float32
	Y float32
}

type Vector

type Vector struct {
	X float32
	Y float32
	Z float32
}

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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