min

package
v0.2.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TEXTURE_CHANGE_ADD = iota
	TEXTURE_CHANGE_RESET
)

Variables

View Source
var (
	SKEL_MODEL_TYPES = []string{"md5", "iqm", "smd"}
	VERT_MODEL_TYPES = []string{"md3", "md2", "obj"}
)
View Source
var (
	// All of the valid material slots
	MATERIALS = []string{
		"air",
		"water",
		"water1",
		"water2",
		"water3",
		"water4",
		"glass",
		"glass1",
		"glass2",
		"glass3",
		"glass4",
		"lava",
		"lava1",
		"lava2",
		"lava3",
		"lava4",
		"clip",
		"noclip",
		"gameclip",
		"death",
		"alpha",

		"sky",
	}

	CUBEMAPSIDES = []string{
		"lf",
		"rt",
		"ft",
		"bk",
		"dn",
		"up",
	}

	MODELTYPES = []string{
		"md2",
		"md3",
		"md5",
		"obj",
		"smd",
		"iqm",
	}

	// The valid parameters to texture slots
	PARAMS = []string{
		"c",
		"u",
		"d",
		"n",
		"g",
		"s",
		"z",
		"a",
		"e",

		"1",
	}
)
View Source
var (
	// Textures can have some additional stuff to modify them but they
	// should refer to the same file
	// ex: <mix:1,1,1><mad:2/2/2>
	TEXTURE_REGEX = regexp.MustCompile(`((<[^>]*>)*)([^<]+)`)

	TEXTURE_COMMAND_REGEX = regexp.MustCompile(`<([^>]*)>`)
)
View Source
var (
	COMMAND_REGEX = regexp.MustCompile(`(("[^"]*")|([^\s]+))`)
)
View Source
var EMPTY_COMMANDS = []string{
	"adaptivesample",
	"ambient",
	"blurlms",
	"blurskylight",
	"causticmillis",
	"causticscale",
	"cloudalpha",
	"cloudboxalpha",
	"cloudboxcolour",
	"cloudcolour",
	"cloudfade",
	"cloudheight",
	"cloudscale",
	"cloudscrollx",
	"cloudscrolly",
	"edgetolerance",
	"elevcontag",
	"fog",
	"fogcolour",
	"fogdomecap",
	"fogdomeclip",
	"fogdomeclouds",
	"fogdomecolour",
	"fogdomeheight",
	"fogdomemax",
	"fogdomemin",
	"grassalpha",
	"grasscolour",
	"lightlod",
	"lightprecision",
	"lmshadows",
	"mapmsg",
	"maptitle",
	"maxmerge",
	"mdlalphablend",
	"mdlalphadepth",
	"mdlalphatest",
	"mdlambient",
	"mdlbb",
	"mdlcollide",
	"mdlcullface",
	"mdldepthoffset",
	"mdlellipsecollide",
	"mdlextendbb",
	"mdlfullbright",
	"mdlglare",
	"mdlglow",
	"mdlpitch",
	"mdlscale",
	"mdlshader",
	"mdlshadow",
	"mdlspec",
	"mdlspin",
	"mdltrans",
	"mdlyaw",
	"minimapclip",
	"minimapcolour",
	"minimapheight",
	"noclip",
	"panelset",
	"rdeye",
	"rdjoint",
	"rdlimitdist",
	"rdlimitrot",
	"rdtri",
	"rdvert",
	"setshader",
	"setshaderparam",
	"shadowmapambient",
	"shadowmapangle",
	"skill",
	"skyboxcolour",
	"skylight",
	"skytexture",
	"skytexturelight",
	"smoothangle",
	"spinclouds",
	"spinsky",
	"sunlight",
	"sunlightpitch",
	"sunlightscale",
	"sunlightyaw",
	"texalpha",
	"texcolor",
	"texlayer",
	"texoffset",
	"texrotate",
	"texscale",
	"texscroll",
	"texsmooth",
	"water2colour",
	"water2fog",
	"watercolour",
	"waterfallcolour",
	"waterfog",
	"waterspec",
	"yawsky",
}
View Source
var EMPTY_MODEL_COMMANDS = []string{
	"adjust",
	"alphablend",
	"alphatest",
	"ambient",
	"animpart",
	"cullface",
	"envmap",
	"fullbright",
	"glare",
	"glow",
	"link",
	"noclip",
	"pitch",
	"pitchcorrect",
	"pitchtarget",
	"scroll",
	"shader",
	"spec",
	"tag",
}

Functions

func CountChildTextures

func CountChildTextures(cubes []*maps.Cube, target map[int32]int)

func CountTextures

func CountTextures(cube *maps.Cube, target map[int32]int)

func FileExists

func FileExists(path string) bool

func Find

func Find[T any](handler func(x T) bool) func(list []T) opt.Option[T]

func GetChildTextures

func GetChildTextures(state worldio.MapState, vslots []*maps.VSlot) map[int32]int

func NormalizeTexture

func NormalizeTexture(texture string) string

Types

type Index

type Index struct {
	Assets []string
	Refs   []IndexAsset
}

type IndexAsset

type IndexAsset struct {
	Id   int
	Path string
}

type Mapping

type Mapping struct {
	// The absolute path of the asset on the filesystem
	// Example: /home/blah/sauerbraten/packages/base/blah.cfg
	From *Reference

	// The path of the asset relative to the game's "root"
	// Example: packages/base/blah.cfg
	To string
}

func CrunchReferences

func CrunchReferences(references []Mapping) []Mapping

Ensure each source file only appears in the destination once.

type Model

type Model struct {
	Name string
}

type Processor

type Processor struct {
	Roots        []assets.Root
	LastMaterial *maps.Slot
	VSlots       []*maps.VSlot
	Slots        []*maps.Slot

	Textures  TextureIndex
	Models    []Model
	Sounds    []*Reference
	Materials map[string]*maps.Slot
	// File references are guaranteed to be included and do not have a slot
	Files []*Reference

	ModelFiles []*Reference
	// contains filtered or unexported fields
}

func NewProcessor

func NewProcessor(roots []assets.Root, slots []*maps.VSlot) *Processor

func (*Processor) AddFile

func (processor *Processor) AddFile(ref *Reference)

func (*Processor) AddModel

func (processor *Processor) AddModel(name string)

func (*Processor) AddModelFile

func (p *Processor) AddModelFile(name string)

func (*Processor) AddSlot

func (processor *Processor) AddSlot() *maps.Slot

func (*Processor) AddSound

func (processor *Processor) AddSound(ref *Reference)

func (*Processor) AutoGrass

func (p *Processor) AutoGrass(name string)

func (*Processor) DoNothing

func (p *Processor) DoNothing()

func (*Processor) EmptyVSlot

func (processor *Processor) EmptyVSlot(owner *maps.Slot) *maps.VSlot

func (*Processor) Exec

func (p *Processor) Exec(name string)

func (*Processor) FindCubemap

func (processor *Processor) FindCubemap(ctx context.Context, cubemap string) []*Reference

func (*Processor) FindTexture

func (processor *Processor) FindTexture(ctx context.Context, texture string) *Reference

func (*Processor) ListVSlots

func (processor *Processor) ListVSlots()

func (*Processor) LoadSky

func (p *Processor) LoadSky(name string)

func (*Processor) LoadSkyOverlay

func (p *Processor) LoadSkyOverlay(name string)

func (*Processor) MModel

func (p *Processor) MModel(name string)

func (*Processor) MapModelCompat

func (p *Processor) MapModelCompat(rad int, h int, tex int, name string, shadow string)

func (*Processor) MapSound

func (p *Processor) MapSound(name string, vol int, maxUses int)

func (*Processor) MdlEnvMap

func (p *Processor) MdlEnvMap(envMapMax float32, envMapMin float32, envMap string)

func (*Processor) MdlName

func (p *Processor) MdlName() string

func (*Processor) NormalizeModelPath

func (p *Processor) NormalizeModelPath(modelDir string, path string) string

This is slightly different from the other Normalize because models specifically use relative paths for some stuff

func (*Processor) ProcessFile

func (processor *Processor) ProcessFile(ctx context.Context, ref *Reference) error

func (*Processor) ProcessModel

func (p *Processor) ProcessModel(ctx context.Context, path string) error

func (*Processor) ProcessModelFile

func (p *Processor) ProcessModelFile(ctx context.Context, modelDir string, modelType string, ref *Reference) ([]*Reference, error)

func (*Processor) ReassignVSlot

func (processor *Processor) ReassignVSlot(owner *maps.Slot, vslot *maps.VSlot) *maps.VSlot

func (*Processor) RegisterSound

func (p *Processor) RegisterSound(name string, vol int)

func (*Processor) ResetMaterials

func (processor *Processor) ResetMaterials()

func (*Processor) ResetModels

func (processor *Processor) ResetModels(limit int)

func (*Processor) ResetSounds

func (processor *Processor) ResetSounds()

func (*Processor) ResetTextures

func (processor *Processor) ResetTextures(n int32)

func (*Processor) ResolveRelative

func (p *Processor) ResolveRelative(ctx context.Context, modelDir string, file string) *Reference

func (*Processor) SaveTextureIndex

func (processor *Processor) SaveTextureIndex(path string) error

func (*Processor) SearchFile

func (processor *Processor) SearchFile(ctx context.Context, path string) *Reference

Search for a file in the roots, one at a time

func (*Processor) SetBumpMap

func (p *Processor) SetBumpMap(meshname string, normalMapFile string)

func (*Processor) SetMaterial

func (processor *Processor) SetMaterial(material string)

func (*Processor) SetModelDir

func (p *Processor) SetModelDir(name string)

func (*Processor) SetSkin

func (p *Processor) SetSkin(meshname string, tex string, masks string, envMapMax float32, envMapMin float32)

func (*Processor) SkelLoadPart

func (p *Processor) SkelLoadPart(model string, other string)

func (*Processor) SkelSetAnim

func (p *Processor) SkelSetAnim(anim string, animFile string)

func (*Processor) Texture

func (p *Processor) Texture(type_ string, name string, rot int, xOffset int, yOffset int, scale float32)

func (*Processor) TextureReset

func (p *Processor) TextureReset(limit int)

func (*Processor) VertLoadPart

func (p *Processor) VertLoadPart(model string)

func (*Processor) VertSetAnim

func (p *Processor) VertSetAnim(anim string)

type Reference

type Reference struct {
	Path string
	Root assets.Root
}

A reference to a file on the FS or in a root.

func NewReference

func NewReference(root assets.Root, path string) *Reference

func ReplaceExtension

func ReplaceExtension(ref *Reference, newExtension string) *Reference

func (*Reference) Exists

func (r *Reference) Exists(ctx context.Context) bool

func (*Reference) ReadFile

func (r *Reference) ReadFile(ctx context.Context) ([]byte, error)

func (*Reference) Resolve

func (r *Reference) Resolve(ctx context.Context) (string, error)

func (*Reference) String

func (r *Reference) String() string

type RootFlags

type RootFlags []string

func (*RootFlags) Set

func (flags *RootFlags) Set(value string) error

func (*RootFlags) String

func (flags *RootFlags) String() string

type Texture

type Texture struct {
	Ref      *Reference
	Line     int
	Type     string
	Name     string
	Rotation int
	Xoffset  int
	Yoffset  int
	Scale    float32
}

func (Texture) Op

func (t Texture) Op() TextureChangeType

type TextureChange

type TextureChange interface {
	Op() TextureChangeType
}

type TextureChangeType

type TextureChangeType byte

type TextureIndex

type TextureIndex []TextureChange

func (TextureIndex) Marshal

func (t TextureIndex) Marshal(p *io.Packet) error

func (*TextureIndex) Unmarshal

func (t *TextureIndex) Unmarshal(p *io.Packet) error

type TextureReset

type TextureReset struct {
	Limit int
}

func (TextureReset) Op

Jump to

Keyboard shortcuts

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