Module Live2LOVE

Live2LOVE is a LÖVE module to load and render Live2D models which uses love.filesystem module to load files, so it works even in fused mode.

Live2LOVE uses love.graphics to do the whole rendering. This provides some advantages like you can apply transformation, using Shader, render to Canvas, and more. At least LOVE 11.0 is required to use this module!

Note that Live2D SDK is required to compile this module, as per README.md says.

Functions

loadMocFile (moc) Load cubism model file without additioal setup.
loadModel (model) Load model definition and fully initialize model.

Class Live2LOVEModel

Live2LOVEModel:setParamValue (name, value[, weight]) Set parameter value of model.
Live2LOVEModel:getMesh ([index]) Retrieve LÖVE Mesh object of specified index or all Mesh objects.
Live2LOVEModel:update (dT) Update model.
Live2LOVEModel:draw () Draw model.
Live2LOVEModel:setExpression (name) Set model expression.
Live2LOVEModel:setMotion (name[, mode]) Set model motion.


Functions

loadMocFile (moc)
Load cubism model file without additioal setup. Only use this if your model file does lack of model definition or your library (or your responsibility) to control the paths.

Parameters:

Returns:

    Live2LOVEModel Model object

Raises:

error when the model file is not recognized.
loadModel (model)
Load model definition and fully initialize model. Most user should use this function. This is recommended way and most of the model preparation is handled. by this function.

Parameters:

  • model string Model definition file path (JSON).

Returns:

    Live2LOVEModel Model object.

Raises:

error when it fails to load (due to many factor).

Class Live2LOVEModel

This is model object
Live2LOVEModel:setParamValue (name, value[, weight])
Set parameter value of model.

Parameters:

  • name string Parameter name.
  • value number Parameter value.
  • weight number Parameter weight (defaults to 1). (optional)
Live2LOVEModel:getMesh ([index])
Retrieve LÖVE Mesh object of specified index or all Mesh objects.

Parameters:

  • index number Index to get it's Mesh data (defaults to nil). (optional)

Returns:

    List of Mesh objects (in a table) or specified Mesh object for specified index.

Raises:

error when index is out of range.
Live2LOVEModel:update (dT)
Update model.

Parameters:

  • dT number Time elapsed since last frame in seconds.
Live2LOVEModel:draw ()
Draw model. Drawing Live2D model object is done using love.graphics.draw, which means that, for example, current transformation stack and Shader affects the model rendering.

Note that if you're rendering the model into Canvas, the Canvas must have stencil buffer to be set (or available), or you'll getting error that stencil buffer is not set!

Live2LOVEModel:setExpression (name)
Set model expression.

Parameters:

  • name string Expression name.

Raises:

error when there are no expressions loaded, initialization failure, or expression with specified name does not exist.
Live2LOVEModel:setMotion (name[, mode])
Set model motion.

Parameters:

  • name string Motion name.
  • mode How to handle the motion.
    1. "normal" (or 1) will play the motion for once then revert back to previous motion.
    2. "loop" (or 2) will play the motion in loop. That's it. It plays the motion again when it's finished.
    3. "preserve" (or 3) will play the motion for once and stays that way.
    If absent, "normal" mode is used. (optional)

Raises:

error when there are no motions loaded, initialization failure, or motion with specified name does not exist.
generated by LDoc 1.4.6 Last updated 2018-06-03 17:00:59