common

package
v1.4.117 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCompareTest

func ByteCompareTest(src []byte, dst []byte) error

ByteCompareTest compares two byte arrays, and returns an error if they are not equal. This was made for testing

func DirTest

func DirTest() string

TestDir returns a testing directory

func IsTest

func IsTest() bool

func IsTestExtensive

func IsTestExtensive() bool

func NameBuild

func NameBuild(srcNames []string) (map[string]int32, []byte, error)

NameBuild prepares an EQG-styled name buffer list

Types

type Animation

type Animation struct {
	Header   *Header          `yaml:"header,omitempty"`
	Bones    []*BoneAnimation `yaml:"bones,omitempty"`
	IsStrict bool             `yaml:"is_strict,omitempty"`
}

Animation is an animation

func NewAnimation

func NewAnimation(name string) *Animation

func (*Animation) BoneBuild

func (anim *Animation) BoneBuild(version uint32, isMod bool, names map[string]int32) ([]byte, error)

BoneBuild prepares an EQG-styled bone buffer list

func (*Animation) NameBuild

func (anim *Animation) NameBuild(miscNames []string) (map[string]int32, []byte, error)

NameBuild prepares an EQG-styled name buffer list

type Bone

type Bone struct {
	Name          string  `yaml:"name"`
	Next          int32   `yaml:"next"`
	ChildrenCount uint32  `yaml:"children_count"`
	ChildIndex    int32   `yaml:"child_index"`
	Pivot         Vector3 `yaml:"pivot"`
	Rotation      Quad4   `yaml:"rotation"`
	Scale         Vector3 `yaml:"scale"`
	Flags         uint32  `yaml:"flags"`
	Children      []int   `yaml:"children,omitempty"` // used by wld
}

Bone is a bone

type BoneAnimation

type BoneAnimation struct {
	Name       string                `yaml:"name"`
	FrameCount uint32                `yaml:"frame_count"`
	Frames     []*BoneAnimationFrame `yaml:"frames,omitempty"`
}

type BoneAnimationFrame

type BoneAnimationFrame struct {
	Milliseconds uint32  `yaml:"milliseconds"`
	Translation  Vector3 `yaml:"translation"`
	Rotation     Quad4   `yaml:"rotation"`
	Scale        Vector3 `yaml:"scale"`
}

BoneAnimationFrame is a bone animation frame

type ByteSeekerTest

type ByteSeekerTest struct {
	io.Seeker
	*bytes.Buffer
	// contains filtered or unexported fields
}

ByteSeekerTest is used primarily for tag systems in tests, it isn't efficient otherwise

func NewByteSeekerTest

func NewByteSeekerTest() *ByteSeekerTest

func (*ByteSeekerTest) Bytes

func (b *ByteSeekerTest) Bytes() []byte

func (*ByteSeekerTest) Cap

func (b *ByteSeekerTest) Cap() int

func (*ByteSeekerTest) Len

func (b *ByteSeekerTest) Len() int

func (*ByteSeekerTest) Read

func (b *ByteSeekerTest) Read(p []byte) (n int, err error)

func (*ByteSeekerTest) ReadByte

func (b *ByteSeekerTest) ReadByte() (c byte, err error)

func (*ByteSeekerTest) ReadFrom

func (b *ByteSeekerTest) ReadFrom(r io.Reader) (n int64, err error)

func (*ByteSeekerTest) ReadRune

func (b *ByteSeekerTest) ReadRune() (r rune, size int, err error)

func (*ByteSeekerTest) ReadString

func (b *ByteSeekerTest) ReadString(delim byte) (line string, err error)

func (*ByteSeekerTest) Reset

func (b *ByteSeekerTest) Reset()

func (*ByteSeekerTest) Seek

func (b *ByteSeekerTest) Seek(offset int64, whence int) (int64, error)

func (*ByteSeekerTest) Write

func (b *ByteSeekerTest) Write(p []byte) (n int, err error)

func (*ByteSeekerTest) WriteByte

func (b *ByteSeekerTest) WriteByte(c byte) error

func (*ByteSeekerTest) WriteString

func (b *ByteSeekerTest) WriteString(s string) (n int, err error)
type Header struct {
	Name    string `yaml:"name"`
	Version int    `yaml:"version"`
}

type Layer

type Layer struct {
	Material string `yaml:"material"`
	Diffuse  string `yaml:"diffuse"`
	Normal   string `yaml:"normal"`
}

Layer is a layer of materials to swap

func (Layer) String

func (v Layer) String() string

type Light

type Light struct {
	Name     string
	Position Vector3
	Color    Vector3
	Radius   float32
}

Light is a light

type Material

type Material struct {
	ID         int32               `yaml:"id,omitempty"`
	Name       string              `yaml:"name"`
	ShaderName string              `yaml:"shader_name"`
	Flag       uint32              `yaml:"flag"`
	Properties []*MaterialProperty `yaml:"properties,omitempty"`
	Animation  MaterialAnimation   `yaml:"animation,omitempty"`
}

Material is a material

type MaterialAnimation

type MaterialAnimation struct {
	Sleep    uint32   `yaml:"sleep"`
	Textures []string `yaml:"textures,omitempty"`
}

type MaterialProperty

type MaterialProperty struct {
	Name     string `yaml:"name"`
	Category uint32 `yaml:"category"`
	Value    string `yaml:"value"`
	Data     []byte `yaml:"data,omitempty"`
}

MaterialProperty is a material property

func (*MaterialProperty) String

func (m *MaterialProperty) String() string

type Model

type Model struct {
	Header          *Header           `yaml:"header,omitempty"`
	FileType        string            `yaml:"file_type,omitempty"`
	Materials       []*Material       `yaml:"materials,omitempty"`
	ParticlePoints  []*ParticlePoint  `yaml:"particle_points,omitempty"`
	ParticleRenders []*ParticleRender `yaml:"particle_renders,omitempty"`
	Layers          []*Layer          `yaml:"layers,omitempty"`
	Bones           []Bone            `yaml:"bones,omitempty"`
	Vertices        []Vertex          `yaml:"vertices,omitempty"`
	Triangles       []Triangle        `yaml:"triangles,omitempty"`
}

Model is a model

func NewModel

func NewModel(name string) *Model

NewModel returns a new model

func (*Model) BoneBuild

func (model *Model) BoneBuild(version uint32, fileType string, names map[string]int32) ([]byte, error)

BoneBuild prepares an EQG-styled bone buffer list

func (*Model) MaterialBuild

func (model *Model) MaterialBuild(names map[string]int32) ([]byte, error)

MaterialBuild prepares an EQG-styled material buffer list

func (*Model) NameBuild

func (model *Model) NameBuild(miscNames []string) (map[string]int32, []byte, error)

NameBuild prepares an EQG-styled name buffer list

func (*Model) TriangleBuild

func (model *Model) TriangleBuild(version uint32, names map[string]int32) ([]byte, error)

TriangleBuild prepares an EQG-styled triangle buffer list

func (*Model) VertexBuild

func (model *Model) VertexBuild(version uint32, names map[string]int32) ([]byte, error)

VertexBuild prepares an EQG-styled vertex buffer list

type Object

type Object struct {
	Name      string
	ModelName string
	Position  Vector3
	Rotation  Vector3
	Scale     float32
}

Object is an object

type ParticlePoint

type ParticlePoint struct {
	Header  *Header               `yaml:"header,omitempty"`
	Entries []*ParticlePointEntry `yaml:"entries,omitempty"`
}

ParticlePoint is a particle point

func NewParticlePoint

func NewParticlePoint(name string) *ParticlePoint

type ParticlePointEntry

type ParticlePointEntry struct {
	Name        string  `yaml:"name"`
	BoneName    string  `yaml:"bone_name"`
	Translation Vector3 `yaml:"translation"`
	Rotation    Vector3 `yaml:"rotation"`
	Scale       Vector3 `yaml:"scale"`
	NameSuffix  []byte  `yaml:"name_suffix,omitempty"`
	BoneSuffix  []byte  `yaml:"bone_suffix,omitempty"`
}

ParticlePointEntry is a single entry in a particle point

type ParticleRender

type ParticleRender struct {
	Header  *Header                `yaml:"header,omitempty"`
	Entries []*ParticleRenderEntry `yaml:"entries,omitempty"`
}

func NewParticleRender

func NewParticleRender(name string) *ParticleRender

type ParticleRenderEntry

type ParticleRenderEntry struct {
	ID                  uint32 `yaml:"id"` //id is actorsemittersnew.edd
	ID2                 uint32 `yaml:"id2"`
	ParticlePoint       string `yaml:"particle_point"`
	ParticlePointSuffix []byte `yaml:"particle_point_suffix,omitempty"`
	UnknownA1           uint32 `yaml:"unknowna1"`
	UnknownA2           uint32 `yaml:"unknowna2"`
	UnknownA3           uint32 `yaml:"unknowna3"`
	UnknownA4           uint32 `yaml:"unknowna4"`
	UnknownA5           uint32 `yaml:"unknowna5"`
	Duration            uint32 `yaml:"duration"`
	UnknownB            uint32 `yaml:"unknownb"`
	UnknownFFFFFFFF     int32  `yaml:"unknownffffffff"`
	UnknownC            uint32 `yaml:"unknownc"`
}

ParticleRender defines what particle to emit on a particle point

type Quad4

type Quad4 struct {
	X float32 `yaml:"fx"`
	Y float32 `yaml:"fy"`
	Z float32 `yaml:"fz"`
	W float32 `yaml:"fw"`
}

Quad4 has X,Y,Z,W defined as float32

func Normalize

func Normalize(q Quad4) Quad4

Normalize a quaternion

type RGBA

type RGBA struct {
	R uint8 `yaml:"r"`
	G uint8 `yaml:"g"`
	B uint8 `yaml:"b"`
	A uint8 `yaml:"a"`
}

RGBA represents R,G,B,A as uint8

type Region

type Region struct {
	Name    string
	Center  Vector3
	Unknown Vector3
	Extent  Vector3
}

Region is a region

type Triangle

type Triangle struct {
	Index        UIndex3 `yaml:"index"`
	MaterialName string  `yaml:"material_name"`
	Flag         uint32  `yaml:"flag"`
}

Triangle is a triangle

type UIndex3

type UIndex3 struct {
	X uint32 `yaml:"ux"`
	Y uint32 `yaml:"uy"`
	Z uint32 `yaml:"uz"`
}

UIndex3 has X,Y,Z defined as uint32

type Vector2

type Vector2 struct {
	X float32 `yaml:"fx"`
	Y float32 `yaml:"fy"`
}

Vector2 has X,Y defined as float32

type Vector3

type Vector3 struct {
	X float32 `yaml:"fx"`
	Y float32 `yaml:"fy"`
	Z float32 `yaml:"fz"`
}

Vector3 has X,Y,Z defined as float32

func ApplyQuaternion

func ApplyQuaternion(v Vector3, q Quad4) Vector3

ApplyQuaternion transforms this vector by multiplying it by the specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector.

func (Vector3) String

func (v Vector3) String() string

String returns a string representation of the vector

type Vertex

type Vertex struct {
	Position Vector3 `yaml:"position"`
	Normal   Vector3 `yaml:"normal"`
	Tint     RGBA    `yaml:"tint"`
	Uv       Vector2 `yaml:"uv"`
	Uv2      Vector2 `yaml:"uv2"`
}

Vertex is a vertex

type Zone

type Zone struct {
	Header  *Header  `yaml:"header,omitempty"`
	Models  []string `yaml:"models,omitempty"`
	Objects []Object `yaml:"objects,omitempty"`
	Regions []Region `yaml:"regions,omitempty"`
	Lights  []Light  `yaml:"lights,omitempty"`
	Lits    []*RGBA  `yaml:"lits,omitempty"`
	// contains filtered or unexported fields
}

Zone is a zone

func NewZone

func NewZone(name string) *Zone

func (*Zone) Name

func (e *Zone) Name(id int32) string

Name returns the name of an id

func (*Zone) NameAdd

func (e *Zone) NameAdd(name string) int32

NameAdd is used when building a world file, appending new names

func (*Zone) NameClear

func (e *Zone) NameClear()

NameClear purges names and namebuf, called when encode starts

func (*Zone) NameData

func (e *Zone) NameData() []byte

NameData dumps the name cache

func (*Zone) NameIndex

func (e *Zone) NameIndex(name string) int32

NameIndex returns the index of a name, or -1 if not found

func (*Zone) SetNames

func (e *Zone) SetNames(names map[int32]string)

SetNames sets the names within a buffer

Jump to

Keyboard shortcuts

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