expression

[Last updated: 2020/01/30]

 

Overview

Expression is the current Parameter(s) Against the value of Parameter(s) Can be set by adding or multiplying the values of Cubism This function handles facial expression motion.
Unity Standard motion playback function Animator In, there is no multiply in the blend mode that can be set for the layer, so it cannot be expressed.

The expression function setting file is exported in .exp3.json format.
About the expression mechanism Here   Please see each.

To use Expression, prefab   UpdateController settings   When   ParameterStore settings   Need to do.

The corresponding tutorial article Here Please refer to the.

Follow the steps below to play facial expression motion.

  1. Create [.exp3.asset]
  2. Create [.expressionList.asset] and add [.exp3.asset]
  3. Play facial expression motion
  4. Calculation and application of facial expression motion

 

Create [.exp3.asset]

[.exp3.asset] is a ScriptableObject asset converted from [exp3.json].
If [.exp3.asset] is changed, normal operation cannot be guaranteed.

To convert [exp.json] to [.exp3.asset], do the following:

  1. Parse [exp.json]
  2. Create CubismExpressionData
  3. [.exp3.asset] Create

 

Parse [exp.json]

The parsing of [exp3.json] uses CubismExp3Json.LoadFrom (string exp3Json) or CubismExp3Json.LoadFrom (TextAsset exp3JsonAsset).

 

 

Create CubismExpressionData

CubismExpressionData is a class that records information of parsed .exp3.json and holds the following data.

field Type Description
type string json file type. In case of .exp3.json, "Live2D Expression" is set.
fadeintime float Time until facial expression fades in. The unit of the value is seconds.
fadeouttime float Time until facial expression fades out. The unit of the value is seconds.
parameters SerializableExpressionParameter [] Apply facial expressions Parameter(s) ID, value to apply, calculation method.

 

To create a new [.exp3.asset], use CubismExpressionData.CreateInstance (CubismExp3Json json).
To override [.exp3.asset], use CubismExpressionData.CreateInstance (CubismExpressionData expressionData, CubismExp3Json json).

  • CubismExp3Json json: CubismExp3Json is a data parsed from [exp3.json].
  • CubismExpressionData expressionData: CubismExpressionData to be overwritten.

 

[.exp3.asset] Create

Create [.exp3.asset] as follows using AssetDatabase.CreateAsset.

 

This processing is done with CubismExpression3JsonImporter.Import ().

* For runtime, it is not necessary to convert CubismExpressionData to .asset.

 

Create [.expressionList.asset] and add [.exp3.asset]

[.expressionList.asset] is an asset that lists [.exp3.asset] references for each model.
This is used in CubismExpressionController to get the facial expression motion to play from CurrentExpressionIndex.
The order of the [.exp3.asset] list is added in the import order of [exp3.json].

* This item is processed by CubismExpression3JsonImporter.Import ().

 

Create [.expressionList.asset]

[.expressionList.asset] is created at the same level as the model prefab.

 

* For runtime, it is not necessary to make CubismExpressionList as .asset.

 

 

Added [.exp3.asset]

To add [.exp3.asset] to [.expressionList.asset], do as follows.

 

 

 

 

Play facial expression motion

By setting the index of facial expression motion to be played in CubismExpressionController.CurrentExpressionIndex, facial expression motion can be played and changed.

Facial expression motion is replayed as follows.

  1. Set end time of facial expression motion during playback
  2. Initialize a new facial expression motion and add it to the facial expression motion playlist

 

Set end time of facial expression motion during playback

If there is a facial expression motion being played, set the end time so that the facial expression motion being played ends.

This processing is done with CubismExpressionController.StartExpression ().

 

Initialize a new facial expression motion and add it to the facial motion list

Create CubismPlayingExpression with playback information of facial expression motion.

CubismPlayingExpression has the following information.

field

Type Description
type string json file type. In case of .exp3.json, "Live2D Expression" is set.
fadeintime float Time until facial expression fades in. The unit of the value is seconds.
fadeouttime float Time until facial expression fades out. The unit of the value is seconds.
weight float Expression weight. Values range from 0 to 1.
expressionusertime float Elapsed time since the start of facial expression playback. The unit of the value is seconds.
expressionendtime float Time when facial expression playback ends. The unit of the value is seconds.
destinations CubismParameter [] 表情が適用するパラメータ��配列。
value float [] Facial expression Parameter(s) The value to apply to. The number of elements and the order are the same as those in Destinations.
blend CubismParameterBlendMode [] Facial expression Parameter(s) The calculation method applied to. The number of elements and the order are the same as those in Destinations. The calculation method to be set is Override, Additive, Multiply.

CubismPlayingExpression can be created using CubismPlayingExpression.Create (CubismModel model, CubismExpressionData expressionData)

  • CubismModel model: A model that plays facial expression motion.
  • CubismExpressionData expressionData: [exp3.asset] data of facial expression motion to play.

The created facial motion is added to the playlist as shown below.

This processing is done with CubismExpressionController.StartExpression ().

 

Calculation and application of facial expression motion

Expression calculation and application is called from CubismExpressionController.OnLateUpdate ().

* Facial expressions must be applied after ParameterStore.SaveParameters ().
Expression is a function that applies a new expression value every frame to the current value.
If applied before ParameterStore.SaveParameters (), the result applied with the expression will be saved. Parameter(s) Is added or multiplied indefinitely.

© 2010 --2021 Live2D Inc.

English中文한국어日本語