Skip to content

package asset_info

import "kaiju/engine/assets/asset_info"

Constants

InfoExtension

".adi"

ProjectCache

".cache"

Variables

ImageMetaOptions

map[string]any{

ErrNoInfo

errors.New("asset database does not have info for this file")

Functions

Exists

func Exists(path string) bool

Exists checks to see if a given path has a generated ADI file. The file it searches for will be path/to/file.ext.adi

ID

func ID(path string) (string, error)

ID returns the ID of the asset within it's ADI file, if the ADI file is not found, the read error is returned

InitForCurrentProject

func InitForCurrentProject() error

Move

func Move(info AssetDatabaseInfo, newPath string) error

RegisterMetadataStructure

func RegisterMetadataStructure(typeExtension string, metadata any) bool

Write

func Write(adi AssetDatabaseInfo) error

Types

AssetDatabaseInfo

struct

type AssetDatabaseInfo struct {
    ID       string
    Path     string
    Type     string
    ParentID string
    Tags     []string
    Children []AssetDatabaseInfo
    Metadata AssetMetadata
}

Lookup

func Lookup(id string) (AssetDatabaseInfo, error)

Lookup will find any asset given it's id (path). This has no information for importers, so it will populate the metadata with a non-castable interface

New

func New(path string, id string) AssetDatabaseInfo

Read

func Read(path string) (AssetDatabaseInfo, error)

Read will read the ADI file for the given path and return the AssetDatabaseInfo struct. Possible errors are:

  • ErrNoInfo: if the file does not exist
  • json.Unmarshal error: if the file is corrupted
  • filesystem.ReadTextFile error: if the file cannot be read

AssetDatabaseInfo.MetadataStructure

func (a *AssetDatabaseInfo) MetadataStructure() any

AssetDatabaseInfo.SpawnChild

func (a *AssetDatabaseInfo) SpawnChild(id string) AssetDatabaseInfo

AssetMetadata

struct

type AssetMetadata struct {
    HTML           HtmlMetadata
    Image          ImageMetadata
    Material       MaterialMetadata
    Mesh           MeshMetadata
    RenderPass     RenderPassMetadata
    Shader         ShaderMetadata
    ShaderPipeline ShaderPipelineMetadata
    Stage          StageMetadata
}

Rather than using interfaces, doing casting, and all that nonsense, we're just going to have a flat structure for asset metadata that is easy to access, easy to fill out, and easy to write. Since this is offline from the game, there is no need to try and abstract this out.

HtmlMetadata

struct

type HtmlMetadata struct{}

ImageMetadata

struct

type ImageMetadata struct {
    Filter        string `options:"imageFilterOptions"`
    Pivot         string `options:"imagePivot"`
    PixelsPerUnit int32
    Mipmaps       int32

    // TODO:  This needs to be used for packaging the content
    MaxSize string `options:"imageMaxSize"`
}

NewDefaultImageMetadata

func NewDefaultImageMetadata() ImageMetadata

ImageMetadata.ImageFilterMeta

func (m *ImageMetadata) ImageFilterMeta() rendering.TextureFilter

ImageMetadata.ImagePivotMeta

func (m *ImageMetadata) ImagePivotMeta() rendering.QuadPivot

ImageMetadata.MaxSizeMeta

func (m *ImageMetadata) MaxSizeMeta() int32

MaterialMetadata

struct

type MaterialMetadata struct{}

MeshMetadata

struct

type MeshMetadata struct {
    Name     string
    Material string
}

RenderPassMetadata

struct

type RenderPassMetadata struct{}

ShaderMetadata

struct

type ShaderMetadata struct{}

ShaderPipelineMetadata

struct

type ShaderPipelineMetadata struct{}

StageMetadata

struct

type StageMetadata struct{}