Breath

Updated: 10/06/2022

To make the model breathe in OW, use CubismBreath.
Since the parameters can be made to operate cyclically, they can be applied to a variety of things, not just breathing.

The parameters to be applied can be specified as desired.
It is also possible to specify for each parameter the period, the range of values for the parameter, and the Weight value at which the value is applied.

Use CubismBreath

Creation of CubismBreath instance

To create a CubismBreath instance, use the CubismBreath::Create function in Native (C++) or the CubismBreath.create function in Web (TypeScript) and Java.

// C++
CubismBreath* breath = CubismBreath::Create();
// TypeScript
let breath: CubismBreath = CubismBreath.create();
// Java
CubismBreath breath = CubismBreath.create();

Parameter specification

To specify parameters to set the breath, use the Native (C++) CubismBreath::BreathParameterData structure or the Web (TypeScript) and Java BreathParameterData class.
Pass the parameter ID to be set as the first argument as CubismId* type (CubismId type for SDK for Web and SDK for Java).
The second argument is the offset value of the periodic operation. The value of the cyclic motion of respiration is set from a sine wave and specifies its starting position.
The third argument sets the maximum value of the sine wave.
The fourth argument sets the period of the sine wave.
The fifth argument sets the weight to which the value is applied to the parameter.

// C++
csmVector<CubismBreath::BreathParameterData> breathParameters;

breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId("ParamAngleX"), 0.0f, 15.0f, 6.5345f, 0.5f));
breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId("ParamAngleY"), 0.0f, 8.0f, 3.5345f, 0.5f));
breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId("ParamAngleZ"), 0.0f, 10.0f, 5.5345f, 0.5f));
breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId("ParamBodyAngleX"), 0.0f, 4.0f, 15.5345f, 0.5f));
breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId("ParamBreath"), 0.5f, 0.5f, 3.2345f, 0.5f));

breath->SetParameters(breathParameters);
// TypeScript
const breathParameters: csmVector<BreathParameterData> = new csmVector();

breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleX"), 0.0, 15.0, 6.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleY"), 0.0, 8.0, 3.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleZ"), 0.0, 10.0, 5.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId("ParamBodyAngleX"), 0.0, 4.0, 15.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId("ParamBreath"), 0.5, 0.5, 3.2345, 1));

breath.setParameters(breathParameters);
// Java
List<CubismBreath.BreathParameterData> breathParameters = new ArrayList<>();

breathParameters.add(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleX"), 0.0f, 15.0f, 6.5345f, 0
breathParameters.add(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleY"), 0.0f, 8.0f, 3.5345f, 0.
breathParameters.add(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId("ParamAngleZ"), 0.0f, 10.0f, 5.5345f, 0
breathParameters.add(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId("ParamBodyAngleX"), 0.0f, 4.0f, 15.5345
breathParameters.add(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId("ParamBreath"), 0.5f, 0.5f, 3.2345f, 0.

_breath.setParameters(breathParameters);

Apply Values to the Model

To apply the breath, use the CubismBreath::UpdateParameters function in Native (C++) or
the CubismBreath.updateParameters function in Web (TypeScript) and Java.
The first argument is the target model and the second argument is the difference time since the last update.

// C++
if (breath ! = NULL)
{
    breath->UpdateParameters(cubismModel, deltaTimeSeconds);
}
// TypeScript
if (this._breath ! = null) {
  this._breath.updateParameters(this._model, deltaTimeSeconds);
}
// Java
if (breath ! = null) {
    breath.updateParameters(cubismModel, deltaTimeSeconds);
}

Destroy CubismBreath

The CubismBreath instance must also be destroyed at the time the model is released.

// C++
CubismBreath::Delete(breath);
// TypeScript
CubismBreath.delete(breath);

Java has a policy of letting garbage collection do the deallocation, so there is no need for a disposal procedure.

Was this article helpful?
YesNo
Please let us know what you think about this article.