asset

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

View Source
const UnspecifiedNodeIndex = int32(-1)
View Source
const UnspecifiedOffset = int32(-1)

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound indicates that the specified content is not available.

Functions

func Encode added in v0.8.0

func Encode(value interface{}) error

Types

type Binary added in v0.8.0

type Binary struct {
	Data []byte
}

Binary represents a blob of bytes

func (*Binary) DecodeFrom added in v0.8.0

func (b *Binary) DecodeFrom(in io.Reader) error

func (*Binary) EncodeTo added in v0.8.0

func (b *Binary) EncodeTo(out io.Writer) error

type BodyDefinition added in v0.8.0

type BodyDefinition struct {
	Name                   string
	IsStatic               bool
	Mass                   float32
	MomentOfInertia        [3][3]float32
	RestitutionCoefficient float32
	DragFactor             float32
	AngularDragFactor      float32
	CollisionBoxes         []CollisionBox
	CollisionSpheres       []CollisionSphere
	CollisionMeshes        []CollisionMesh
}

type BodyInstance added in v0.8.0

type BodyInstance struct {
	Name      string
	NodeIndex int32
	BodyIndex int32
}

type CollisionBox added in v0.8.0

type CollisionBox struct {
	Translation [3]float32
	Rotation    [4]float32
	Width       float32
	Height      float32
	Lenght      float32
}

type CollisionMesh added in v0.8.0

type CollisionMesh struct {
	Translation [3]float32
	Rotation    [4]float32
	Triangles   []CollisionTriangle
}

type CollisionSphere added in v0.8.0

type CollisionSphere struct {
	Translation [3]float32
	Rotation    [4]float32
	Radius      float32
}

type CollisionTriangle added in v0.8.0

type CollisionTriangle struct {
	A [3]float32
	B [3]float32
	C [3]float32
}

type CubeTexture

type CubeTexture struct {
	Dimension  uint16
	Filtering  FilterMode
	Format     TexelFormat
	Flags      TextureFlag
	FrontSide  CubeTextureSide
	BackSide   CubeTextureSide
	LeftSide   CubeTextureSide
	RightSide  CubeTextureSide
	TopSide    CubeTextureSide
	BottomSide CubeTextureSide
}

func (*CubeTexture) DecodeFrom

func (t *CubeTexture) DecodeFrom(in io.Reader) error

func (*CubeTexture) EncodeTo

func (t *CubeTexture) EncodeTo(out io.Writer) error

type CubeTextureSide

type CubeTextureSide struct {
	Data []byte
}

type Decodable

type Decodable interface {
	DecodeFrom(in io.Reader) error
}

Decodable represents an asset that can be deserialized.

type Encodable

type Encodable interface {
	EncodeTo(out io.Writer) error
}

Encodable represents an asset that can be serialized.

type FilterMode

type FilterMode uint8
const (
	FilterModeNearest FilterMode = iota
	FilterModeLinear
	FilterModeAnisotropic
)

type IndexLayout added in v0.8.0

type IndexLayout uint8
const (
	IndexLayoutUint16 IndexLayout = iota
	IndexLayoutUint32
)

type Material added in v0.8.0

type Material struct {
	Name            string
	Type            MaterialType
	BackfaceCulling bool
	AlphaTesting    bool
	AlphaThreshold  bool
	Translucent     bool
	Scalars         [16]*float32
	Textures        [16]string
}

type MaterialType added in v0.8.0

type MaterialType uint8
const (
	MaterialTypePBR MaterialType = iota
	MaterialTypeAlbedo
)

type MeshDefinition added in v0.8.0

type MeshDefinition struct {
	Name         string
	VertexData   []byte
	VertexLayout VertexLayout
	IndexData    []byte
	IndexLayout  IndexLayout
	Fragments    []MeshFragment
}

type MeshFragment added in v0.8.0

type MeshFragment struct {
	Topology      MeshTopology
	IndexOffset   int32
	IndexCount    uint32
	MaterialIndex int32
}

type MeshInstance added in v0.8.0

type MeshInstance struct {
	Name            string
	NodeIndex       int32
	DefinitionIndex int32
}

type MeshTopology added in v0.8.0

type MeshTopology uint8
const (
	MeshTopologyPoints MeshTopology = iota
	MeshTopologyLineStrip
	MeshTopologyLineLoop
	MeshTopologyLines
	MeshTopologyTriangleStrip
	MeshTopologyTriangleFan
	MeshTopologyTriangles
)

type Model added in v0.8.0

type Model struct {
	Nodes           []Node
	Materials       []Material
	MeshDefinitions []MeshDefinition
	MeshInstances   []MeshInstance
	BodyDefinitions []BodyDefinition
	BodyInstances   []BodyInstance
}

func (*Model) DecodeFrom added in v0.8.0

func (m *Model) DecodeFrom(in io.Reader) error

func (*Model) EncodeTo added in v0.8.0

func (m *Model) EncodeTo(out io.Writer) error

type Node added in v0.8.0

type Node struct {
	Name        string
	ParentIndex int32
	Translation [3]float32
	Rotation    [4]float32
	Scale       [3]float32
}

type ReflectDecoder added in v0.8.0

type ReflectDecoder struct {
	// contains filtered or unexported fields
}

func NewReflectDecoder added in v0.8.0

func NewReflectDecoder(in io.Reader) *ReflectDecoder

func (*ReflectDecoder) Decode added in v0.8.0

func (d *ReflectDecoder) Decode(target interface{}) error

type ReflectEncoder added in v0.8.0

type ReflectEncoder struct {
	// contains filtered or unexported fields
}

func NewReflectEncoder added in v0.8.0

func NewReflectEncoder(out io.Writer) *ReflectEncoder

type Registry

type Registry interface {
	Resources() []Resource
	ResourceByID(id string) Resource
	ResourceByName(name string) Resource
	ResourcesByName(name string) []Resource
	CreateResource(kind, name string) Resource
	// CreateIDResource is deprecated and available only due to the old
	// pack mechanism.
	CreateIDResource(id, kind, name string) Resource
	Save() error
}

Registry represents a managment interface for assets.

func NewDirRegistry

func NewDirRegistry(dir string) (Registry, error)

NewDirRegistry creates a Registry implementation that stores content on the filesystem. The provided dir parameter needs to point to the project root. A special assets directory will be created inside if one is not available already.

func NewWebRegistry

func NewWebRegistry(assetsURL string) (Registry, error)

NewWebRegistry creates a Registry implementation that reads content from the web. The provided assetsURL parameter needs to point to the web location of the assets.

This registry does not support write or delete operations.

type RegistryLocator added in v0.8.0

type RegistryLocator struct {
	// contains filtered or unexported fields
}

RegistryLocator is an implementation of ReadLocator that uses a Registry to access resources.

func NewRegistryLocator added in v0.8.0

func NewRegistryLocator(registry Registry) *RegistryLocator

NewRegistryLocator returns a new *FileLocator that is configured to access resources located on the local filesystem.

func (*RegistryLocator) ReadResource added in v0.8.0

func (l *RegistryLocator) ReadResource(path string) (io.ReadCloser, error)

type Resource

type Resource interface {
	ID() string
	Kind() string
	Name() string
	SetName(name string)
	Dependants() []Resource
	Dependencies() []Resource
	AddDependency(resource Resource)
	RemoveDependency(resource Resource)
	ReadPreview() (image.Image, error)
	WritePreview(image.Image) error
	DeletePreview() error
	ReadContent(target Decodable) error
	WriteContent(source Encodable) error
	DeleteContent() error
	Delete()
}

Resource represents the generic aspects of an asset.

type Scene added in v0.8.0

type Scene struct {
	Model
}

type TexelFormat

type TexelFormat uint8
const (
	TexelFormatR8 TexelFormat = iota
	TexelFormatR16
	TexelFormatR16F
	TexelFormatR32F
	TexelFormatRG8
	TexelFormatRG16
	TexelFormatRG16F
	TexelFormatRG32F
	TexelFormatRGB8
	TexelFormatRGB16
	TexelFormatRGB16F
	TexelFormatRGB32F
	TexelFormatRGBA8
	TexelFormatRGBA16
	TexelFormatRGBA16F
	TexelFormatRGBA32F
	TexelFormatDepth16F
	TexelFormatDepth32F
)

type TextureFlag added in v0.8.0

type TextureFlag uint8
const (
	TextureFlagMipmapping TextureFlag = 1 << iota
	TextureFlagLinear

	TextureFlagNone TextureFlag = 0
)

func (TextureFlag) Has added in v0.8.0

func (f TextureFlag) Has(flag TextureFlag) bool

type TwoDTexture

type TwoDTexture struct {
	Width     uint16
	Height    uint16
	Wrapping  WrapMode
	Filtering FilterMode
	Format    TexelFormat
	Flags     TextureFlag
	Data      []byte
}

func (*TwoDTexture) DecodeFrom

func (t *TwoDTexture) DecodeFrom(in io.Reader) error

func (*TwoDTexture) EncodeTo

func (t *TwoDTexture) EncodeTo(out io.Writer) error

type VertexLayout added in v0.8.0

type VertexLayout struct {
	CoordOffset    int32
	CoordStride    int32
	NormalOffset   int32
	NormalStride   int32
	TangentOffset  int32
	TangentStride  int32
	TexCoordOffset int32
	TexCoordStride int32
	ColorOffset    int32
	ColorStride    int32
}

type WrapMode

type WrapMode uint8
const (
	WrapModeRepeat WrapMode = iota
	WrapModeMirroredRepeat
	WrapModeClampToEdge
)

Jump to

Keyboard shortcuts

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