cubism

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 13 Imported by: 0

README

Cubism Go

Go Reference Go Report Card CI

cubism-go is an unofficial Golang implementation of the Live2D Cubism SDK. It leverages ebitengine/purego, making it easy to use.

Installation

go get -u github.com/aethiopicuschan/cubism-go

Requirements

  • Dynamic library for Cubism Core
  • Live2D model

Usage

Sample code is available in the example directory. It demonstrates the use of almost all functionalities, so please refer to it alongside the Go Reference.

Additionally, there is a renderer/ebitengine package for rendering implementations. This package enables seamless integration with projects using Ebiten. Of course, you can also use your custom renderer.

Moreover, there are several implementations available for audio playback:

  • sound/normal
    • A straightforward implementation
  • sound/delay
    • An implementation that defers loading and decoding of audio files until playback
  • sound/disabled
    • An implementation that disables audio playback

You can also implement your own version of these.

Development

For pre-commit hooks, we use lefthook. The configured tools include:

If you're using Homebrew, you can install all the necessary tools with the following command:

brew install lefthook staticcheck typos-cli

After that, run lefthook install to enable the hooks.

The same checks are also performed using GitHub Actions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cubism

type Cubism struct {

	// A function to load audio files
	LoadSound func(fp string) (s sound.Sound, err error)
	// contains filtered or unexported fields
}

The main body of cubism-go

func NewCubism

func NewCubism(lib string) (c Cubism, err error)

Constructor for the Cubism struct

func (*Cubism) LoadModel

func (c *Cubism) LoadModel(path string) (m *Model, err error)

Load a model from model3.json

type Drawable

type Drawable struct {
	Id              string
	Texture         string
	VertexPositions []drawable.Vector2
	VertexUvs       []drawable.Vector2
	VertexIndices   []uint16
	ConstantFlag    drawable.ConstantFlag
	DynamicFlag     drawable.DynamicFlag
	Opacity         float32
	Masks           []int32
}

type Model

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

A model struct

func (m *Model) DisableAutoBlink()

Disable Auto Blink

func (m *Model) EnableAutoBlink()

Enable Auto Blink

func (*Model) GetCore

func (m *Model) GetCore() core.Core

Get the core

func (*Model) GetDrawable

func (m *Model) GetDrawable(id string) (d Drawable, err error)

Get the Drawable with the specified ID

func (*Model) GetDrawables

func (m *Model) GetDrawables() []Drawable

Get the drawables

func (*Model) GetHitAreas

func (m *Model) GetHitAreas() []model.HitArea

Get the list of hit areas

func (*Model) GetMoc

func (m *Model) GetMoc() moc.Moc

Get the moc

func (*Model) GetMotionGroupNames

func (m *Model) GetMotionGroupNames() (names []string)

Get the list of motion group names

func (*Model) GetMotions

func (m *Model) GetMotions(groupName string) []motion.Motion

Get the list of motions in the group

func (*Model) GetOpacity

func (m *Model) GetOpacity() float32

Get the opacity of the model

func (*Model) GetParameterValue

func (m *Model) GetParameterValue(id string) float32

Get the value of the parameter

func (*Model) GetParameters

func (m *Model) GetParameters() []parameter.Parameter

Get the list of parameters

func (*Model) GetSortedIndices

func (m *Model) GetSortedIndices() []int

Get the sorted drawing order indices

func (*Model) GetTextures

func (m *Model) GetTextures() []string

Get the path of a texture image

func (*Model) GetVersion

func (m *Model) GetVersion() int

Get the version of the model

func (*Model) PlayMotion

func (m *Model) PlayMotion(groupName string, index int, loop bool) (id int)

Play a motion

func (*Model) SetParameterValue

func (m *Model) SetParameterValue(id string, value float32)

Set the value of the parameter

func (*Model) StopMotion

func (m *Model) StopMotion(id int)

Stop a motion

func (*Model) Update

func (m *Model) Update(delta float64)

Update the model

Jump to

Keyboard shortcuts

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