HarmonicMotion (UE)

Updated: 09/05/2024

This page contains statements regarding the alpha version.

Summary

HarmonicMotion is a function that periodically iterates the values of specified parameters.
It is used primarily for things that are in constant motion, such as breathing.

How to handle the component

HarmonicMotion in the Cubism SDK for Unreal Engine can be used by adding a CubismHarmonicMotionComponent to child components of a CubismModel actor.

Components for specifying parameters to operate

HarmonicMotion can be used by adding a CubismHarmonicMotionComponent to child components of a CubismModel actor.

CubismHarmonicMotionComponent provides a separate iterative motion for each element of Parameters. On the basis of the blend method specified in each BlendMode, the value in Value is applied to the parameter corresponding to the ID set in Id.

for (FCubismHarmonicMotionParameter& Parameter : Parameters)
{
	if (!Parameter.bEnabled)
	{
		continue;
	}

	UCubismParameterComponent* Destination = Model->GetParameter(Parameter.Id);

	if (!Destination)
	{
		continue;
	}

	Parameter.Value = Parameter.CalcValue(Time, Destination->MinimumValue, Destination->MaximumValue);

	switch (Parameter.BlendMode)
	{
		case ECubismParameterBlendMode::Overwrite:
		{
			Destination->SetParameterValue(Parameter.Value);
			break;
		}
		case ECubismParameterBlendMode::Additive:
		{
			Destination->AddParameterValue(Parameter.Value);
			break;
		}
		case ECubismParameterBlendMode::Multiplicative:
		{
			Destination->MultiplyParameterValue(Parameter.Value);
			break;
		}
	}
}

To add or remove a target parameter, add or remove the Parameters element of the component.

If Enabled is set to true, the periodic oscillation value is applied.
This behavior can be controlled by the parameters provided in CubismHarmonicMotionParameter.

  • Channel

    Specifies the multiplier for the sine wave period set by the CubismHarmonicMotionController.

    HarmonicMotion allows multiple periods for a single model, which can be set with the CustomHarmonicMotionController.

    Here, set the index of the CustomHarmonicMotionController.ChannelTimescales.
  • Direction

    Sets the range of periodic operation with respect to the center of the parameter.

    There are three setting items.
    • Left: It works only in the left half of the range from the center of the parameter.
    • Right: It works only in the right half of the range from the center of the parameter.
    • Centric: It works across the entire range of parameters.
  • NormalizedOrigin

    Sets the center of the parameter to be referenced by Direction.

    The center will be set to the value when the minimum value of that parameter is set to 0 and the maximum value of that parameter is set to 1.
  • NormalizedRange

    Sets the amplitude at which to operate the value from the center of the value set in NormalizedOrigin.

    Set the distance traveled from the center when the minimum value of that parameter is 0 and the maximum value is 1.

    This value can only range from the center position set by NormalizedOrigin to the minimum or maximum value of the parameter.
  • Duration

    Adjusts the duration of the parameter.
Was this article helpful?
YesNo
Please let us know what you think about this article.