mod

package
v0.0.0-...-86c6665 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CubeDefs []*t.Cube

CubeDefs is the CubeRef to Cube lookup table.

Faces is the global face atlas.

View Source
var Mods = map[string]*Mod{}

Mods is the global map of all mods by ID

UITiles is the face atlas for all UI tiles in all mods.

View Source
var VoxDefs = []*Vox{}

VoxDefs is the list of voxel definitions by internal ID.

Functions

func GetCubeDef

func GetCubeDef(id string) *t.Cube

GetCubeDef returns the cube definition.

func GetCubeDefFromRef

func GetCubeDefFromRef(r t.CubeRef) *t.Cube

GetCubeDefFromRef returns the cube definition referenced by the cube reference.

func GetCubeRef

func GetCubeRef(id string) t.CubeRef

GetCubeRef returns the CubeRef assigned to the given id.

func GetPartMesh

func GetPartMesh(path string) *c3d.VoxelMesh

GetPartMesh returns the part mesh by resource path.

func GetUITile

func GetUITile(p string) t.FaceIndex

GetUITile returns the index of the UI tile at the given path.

func LoadMods

func LoadMods(mods ...string) error

LoadMods loads the named mods in order.

func ReloadModInfo

func ReloadModInfo() error

ReloadModInfo reloads all top-level info for all mods present.

Types

type AFQuat

type AFQuat [3]float32

AFQuat is the JSON structure used to hold X, Y, Z rotations to turn into quaternions.

func (*AFQuat) UnmarshalJSON

func (q *AFQuat) UnmarshalJSON(d []byte) error

type Animation

type Animation []*AnimationFrame

Animation contains the information and functionality to play an animation loop on a model. Animations consist of rotations to joints only.

type AnimationFrame

type AnimationFrame struct {
	Time      float32           `json:"time"`      // Time T for interpolation to Q
	Rotations map[string]AFQuat `json:"rotations"` // Map of part ID's to quaternions that describe that part's final rotation
}

AnimationFrame describes a single frame of the animation.

type Mod

type Mod struct {
	ID          string `json:"-"`           // Unique ID of the mod
	Name        string `json:"name"`        // Descriptive name of the mod
	Description string `json:"description"` // Description of the mod
	// contains filtered or unexported fields
}

Mod manages a bundle of cubit engine content in separate external files.

type Model

type Model struct {
	DrawDescriptor *c3d.ModelDrawDescriptor // The draw descriptor this model manages
	Bounds         t.AABB                   // Model bounds in world coordinates
	// contains filtered or unexported fields
}

Model describes a hierarchy of parts with defined animations.

func NewModel

func NewModel(p string) *Model

NewModel constructs a new model from the model descriptor at the resource path given.

func (*Model) StartAnimation

func (m *Model) StartAnimation(p, l string)

StartAnimation starts the animation identified by the resource path on the model on the given animation layer.

func (*Model) Update

func (m *Model) Update(dt float32)

Update should be called once per frame to update internal model state, such as animations.

type ModelDescriptor

type ModelDescriptor struct {
	Bounds t.AABB               `json:"bounds"` // Bounding box of the model
	Root   *ModelPartDescriptor `json:"root"`   // Root part
}

ModelDescriptor describes how to initialize a model.

type ModelPartDescriptor

type ModelPartDescriptor struct {
	ID          string                `json:"id"`          // ID of the part for animations
	Mesh        string                `json:"mesh"`        // Absolute path to the part mesh
	Origin      mgl32.Vec3            `json:"origin"`      // Center point / rotation point of the part
	Orientation t.Orientation         `json:"orientation"` // T-pose orientation
	Children    []ModelPartDescriptor `json:"children"`    // Child parts
}

ModelPartDescriptor describes how to initialize a part attached to a model.

type Vox

type Vox struct {
	Ref  t.VoxRef       // Voxel reference
	Mesh *c3d.VoxelMesh // Voxel mesh
	// contains filtered or unexported fields
}

Vox manages an RGBA voxel image.

func GetVoxByPath

func GetVoxByPath(p string) *Vox

GetVoxByPath returns the vox model by mod path.

func NewVox

func NewVox(v *util.Vox) *Vox

NewVox creates a new Vox object ready to use.

Jump to

Keyboard shortcuts

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