01. Settings for Physics


The built-in physics tool can add physical features to your model, such as a hair swaying motion according to how the head moves. 


    To Add Physics

On the top menu, click [Project]  →   [Add]  →  [Physics] .

A new item "physics.json" is added to the project.


At the settings, check off the box for "Easy Mode", as we will be configuring it in details.



To learn about Easy Mode, please see here.


 
  Settings Configuration for Physics


We now make the front bang sway like it has a realistic physical property. 
Let's begin with labeling the set if physics we create.

On the drop-down menu where it shows the item "p00", right-click it and click "Rename". 

Enter "hair_front" in the text field and press "OK". 


This is how you label your settings.

Moving on, we go through each section of configuration - "Basic", "Input", "Output".

To see the description of each value, hover your mouse on the value label. 



Basic

On the "Basic" tab, you should see the following.  

This is where you configure the performance of the swaying motion for an object. 

Mass
The mass of the object. 
(This applies weight to the object)
The bigger the value, the wider the swing.

Length
The length between the base of the object and the tip of object where the swaying happens.
(E.g. the length of the string that does a pendulum movement)
The bigger the value, the slower the swing.

Air Resistance
The diminishing rate of the swing motion.
The bigger the value, the sooner the swing stops.


Input

On the "Input" tab, you'd see the following. This is where you define the source of the force.
Click the [+] button to add an item. A settings window will appear.

In the settings window, enter the values as shown below.


ID
The parameter to be defined as a factor of the physical movement
We want the face's movement affect the front bangs. In this case, select "PARAM_ANGLE_X" (Angle_X parameter) in this field. Angle_X is the parameter which controls the face movement.

type
Type of parameter value
The movement we are making responds the face's X axis. Select "X" for this field.

Moving distance per unit
The amount of transformation of the object per 1 unit on the parameter (when the value of the parameter
is changed by "1") 
The configuration in the sample above defines that when parameter "Angle_X" is increased by "1" unit on the scale, the face object is virtually moved by 5mm, or in meters, 0.005m. 
If the parameter is one that has a value range from -30 to 30 which controls the Angle_X rotation of the face, enter "1" in this field. It means that "1 unit in the parameter is equivalent to virtually rotating 1 degree". 
The unit here will be changed from
(m) "meter" to (°) "degree" when the "type" field is changed to "Angle".

Weight
The weight of this factor on the movement
We can go with default value "1" for now. We may need to adjust it later.

Press [OK], and you will see a new item added to the list.


To have the hair also capturing the Z axis rotational movement of the face, add the following physics factor.


Angle_Z is a rotational parameter, so set the type to "Angle".

With this set of inputs, the hair object now responds to the face X and Z-axis movement.



Output

Finally, go to the "Output" tab to configure the output settings.
Same as "Input", press [+] to add a component to apply physics on.

Follow the image below to configure.


ID
The parameter to respond to the input factors
We want to define here the parameter that is responsible for the front bang's swaying movement.
Select "PARAM_HAIR_FRONT" (Hair move - front) parameter.

type
Type of parameter value
Here we define the front bang's movement whether it is directional (X or Y-axis) or rotational (angle).

Moving distance per unit
The amount of transformation of the object per 1 unit on the parameter (when the value of the parameter 
is changed by "1") 
The parameter "Hair move - front" has a range of -1 to 1. Virtually, the model's hair should have a swaying range approximately 30° to 45° (40° for this instance). The ratio is then 1 : 40, which 1/40 = 0.025, hence that is value for this configuration. 

Weight
The weight of this factor on the movement
We can go with default value "1" for now. We may need to adjust it later.



The "Output" settings is completed.

The model should have physics applied to the front bang.

Click-drag on the model to observe the result. See if the front bang appears swaying after moving as the face moves.



Adding Physics Components

Let's add physics to the hair at the back.
Press the [+] button to add a new component to apply physics on.

In the field "label", enter a name for labeling this set of physics.
Check the box for copy to enable copying the configuration of an existing set. Select the set from the drop-down menu to copy.

Configure the settings for "hair back" as shown below.


Since the hair at the back is longer, "Mass" and "Length" in the "Basic" tab need to be doubled. In the "Output" tab, change the item ID to "PARAM_HAIR_BACK", but leave the property values the same as for "hair front". 

As such, whenever adding a new element, you will be mainly configuring the values in the "Basic" tab.
Only when necessary would you adjust property values in the "Input" / "Output" tab. 


    Exporting Physics Settings as a JSON file

To export your physics settings, go to [Project]  →  [Write]  →  [Physics] . A JSON file is created in the destination folder.
When exporting physics settings for clothes or accessories, it is recommended to name the file with indication of the source moc file. 

As simple as such, the physics settings has been exported. 


    Physics Settings Samples

Here are some recommended set of physics for your model.

Front Bang Movement (responding to the face in X and Z-axis)

If you want to customize the sample, make adjustments to the properties in "Basic" tab mainly. 

The sample is based on the following set of parameter presets. If your model has different properties, you would need to make adjustment to the "Moving distance per unit" value. 

Face Angle X :  -30 ~ 30
Face Angle Z :  -30 ~ 30
Hair move - front :  -1 1




Front bang Movement (responding to the face X and Z-axis + body X and Z rotation)

This physics settings makes the front bang correspond to the movements of both the face and the body. 
The following is the preset parameter value:

Face Angle X :  -30 ~ 30
Face Angle Z :  -30 ~ 30
Body Angle X :  -10 ~ 10
Body Angle Z :  -10 ~ 10
Hair move - front :  -1 ~ 1




Note that for "Input", the weight property has different values among the elements.
If you only have one element, set its weight as "1".


※ About the Weight property

When there are multiple elements, it may require some adjustments to the "weight", which determines the influence proportion of each element. 
The following describes the algorithm of the "weight" property, based on the presets that are shown in the sample images above.

( i ) In the case where PARAM_ANGLE_X has the weight of 1 、PARAM_BODY_ANGLE_X has 1 


This formula shows how the Angle X of the face (PARAM_ANGLE_X) is applied to the hair movement by the proportion of the weight. Let A represent that influence of the face, A has 100% influence. 

1 * A = A

This is how PARAM_ANGLE_X affects the physics calculation.

Next, we add in the factor of Angle X of the body (PARAM_BODY_ANGLE_X). Let B represent the influence of the body. 
B has a weight of "1", which gives it 100% of influence, too. The outcome of the formula is calculated as such:

1 * B + ( 1 - 1 ) * A = B

Hence, the final result makes B as the sole influence on the physics.

When both A and B have a weight of 1, because of the how the calculation works, the result is that B overrides A completely. 

This is a wrong way to use the mechanic.

The settings gives a pointless outcome. The following example would make more sense. 

( ii ) PARAM_ANGLE_X has a weight of 1 、PARAM_BODY_ANGLE_X has  0.5 

This formula gives Angle X of the face (PARAM_ANGLE_X) a weight of 1. Let A represent that influence of the face, A has 100% influence. 

1 * A = A

This is how PARAM_ANGLE_X affects the physics calculation.


Next, we add in the factor of Angle X of the body (PARAM_BODY_ANGLE_X). Let B represent the influence of the body. 
B has a weight of "0.5", which gives it 50% of influence. The outcome of the formula is calculated as such:

0.5 * B + ( 1 - 0.5 ) * A = 0.5 A + 0.5 B

Hence, the final result is 0.5 A + 0.5 B influencing the physics.

In other words, A and B each share half the influence on the physics.

At a glance, this seems a reasonable result. However, when tested in Viewer, the swaying motion of the hair is rather subtle. This is a problem caused by the formula. When B, the body angle X, is contributing 50% of the front bang's movement, that leaves a 50% cap on A, the face angle X. However, the face does most of the movement when the character is tracking the mouse cursor, when the body only moves a little. Thus, the calculation is correct, its the formula that limited the performance.

Hence, to give the best performance, we should change the weight proportion to make sure the face gives more contribution than the body to the hair's movement.

( iii ) PARAM_ANGLE_X has a weight of 2、PARAM_BODY_ANGLE_X has 0.5 

This time, let A be the face angle X (PARAM_ANGLE_X). 
Let's give it a weight of 2, thus A have 200% influence.

2 * A = A

As such, PARAM_ANGLE_X results as in the physics calculation.

Next, we add in the body angle X factor. Let B be the body angle X (PARAM_BODY_ANGLE_X). Give 
B a weight of 0.5. It now has only 50% influence. 
0.5 * B + ( 1 - 0.5 ) * 2 A = A + 0.5 B

Combining the factors, the calculation results as 
 A + 0.5 B.

Therefore, A will have full influence on the hair's physics, and B has half. 

When tested in Viewer, the hair movement looks convincing and natural. 

However, with this calculation, the hair movement can go up to 150% when the two factors both reach their maximum movement.
This would cause the hair to excessively swing to the maximum range. This is one problem to lookout when handling 2 parameters.


In this particular case, we use formula ( iii ) for the best result. Although, depending on the situation, sometimes ( ii ) may be a better option.
It is also helpful to adjust the property values to optimize the calculation.

Comments