Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
akasaki1211 committed Oct 8, 2024
2 parents cff30ca + 1136c64 commit f7fcea6
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 60 deletions.
Binary file added .images/aetemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .images/turbulence_wind.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .images/turbulence_wind_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ A custom node that applies dynamics to one section of a joint chain. It can be i
1. Put [boneDynamicsNode.mll](#Pre-built-plug-ins) in `C:\Users\<USERNAME>\Documents\maya\<MAYAVERSION>\plug-ins`.
2. Load "boneDynamicsNode.mll" from Plug-in Manager.

> **Note**
> If [AEboneDynamicsNodeTemplate.mel](scripts/AEboneDynamicsNodeTemplate.mel) is placed in `C:\Users\<USERNAME>\Documents\maya\<MAYAVERSION>\scripts`, the layout of the Attribute Editor will change.
>
> ![aetemplate](.images/aetemplate.png)
## Basic Usage
Create any joint chain and connect the `boneDynamicsNode` per section. The minimum required connections are as follows:

Expand Down Expand Up @@ -44,10 +49,21 @@ Let's move the current frame to 1 or later and move the root. The joint-chain sh
### Dynamics Attributes
- `Damping` : Attenuates speed. The larger the value, the harder it is to accelerate.
- `Elasticity` : Force to return to the original posture.
- `Elastic Force Function` __(*Experimental)__ : The type of elastic force.
- `Linear`: Normal.
- `Quadratic`: The elastic force increases when it is moved away from the original posture.
- `Cubic`: The elastic force increases **even more** when it is moved away from the original posture.
- `Stiffness` : Suppresses changes between frames (steps). Setting to 1 will result in loss of motion.
- `Mass` : Affects the force to return to the original posture.
- `Gravity` : If Y-up and the unit is in centimeters, set [0,-980,0].
- `Gravity Multiply` : Will be multiplied by Gravity.
- `Additional Force` : Any additional force.
- `Additional Force Scale` : Scale value of additional force.
- `Enable Turbulence`: Enable turbulence force.
- `Turbulence Seed`: Seed value for randomly changing the vector direction.
- `Turbulence Strength`: Scale value of turbulence force.
- `Turbulence Vector Change Scale`: Change in turbulence force vector.
- `Turbulence Vector Change Max`: Maximum change in turbulence force vector.

### Bake to Keyframes
Select the joint and execute "Bake Simulation" from the "Key" menu. Then delete the boneDynamicsNode.
Expand Down Expand Up @@ -147,7 +163,8 @@ The converging pose can be manipulated by duplicating the joint-chain and connec

### Offset Transform

You can cancel the transform by connecting the worldMatrix of the node you do not want affected (such as the root controller of character) to the `Offset Matrix`.
You can cancel the transform by connecting the worldMatrix of the node you do not want affected (such as the root controller of character) to the `Offset Matrix`.
The `Offset Matrix Weight` attribute adjusts the amount of influence. Please note that he `Offset Matrix Weight` must be **the same values** for all joints in the chain, otherwise unnatural behavior will occur.

![offset_matrix](.images/offset_matrix.gif)

Expand All @@ -169,12 +186,26 @@ Branching is possible, but good results are obtained with joints like the one on

![branching_skeleton](.images/branching_skeleton.png)

### Additional Force / Turbulence Force

The vector entered in `Additional Force` is multiplied by the `Additional Force Scale` and added to the external force. Unlike `Gravity`, it takes mass into account.

Enabling `Enable Turbulence` adds a vector that changes direction randomly to the external force. The change accumulates starting from the `Reset Time`. Nodes with the same `Turbulence Seed` and `Reset Time` will generate the same turbulence vector.

**Turbulence wind** can be represented by a combination of these features.

![turbulence_wind](.images/turbulence_wind.gif)
![turbulence_wind_settings](.images/turbulence_wind_settings.png)

---

> 💡**Sample Script**
> [advanced_usage.py](sample_scripts/advanced_usage.py) is a script to connect bonedynamicsNode to any joint chain. Please select and execute them in order from the root of the joint to the tip of the joint.
> - Enable per-section scaling.
> - If place the collider created by expcol as a child of 'collider_grp', to be connected.
> - If duplicate the joint-chain to be simulated and add '_target' to the end of the name, to allow manipulation of the target posture.
> - If a node named "offset" exists, will be connected to cancel the transform.
> - If a node named "wind" exists, it will be connected to the Additional Force.
## Pre-built plug-ins
Pre-built `boneDynamicsNode.mll` in the [plug-ins](./plug-ins) folder. Install to the appropriate Maya version and ready to use.
Expand All @@ -183,7 +214,7 @@ Pre-built `boneDynamicsNode.mll` in the [plug-ins](./plug-ins) folder. Install t
|Maya 2022 Update 5 win64|[Download](./plug-ins/2022/boneDynamicsNode.mll)|
|Maya 2023 Update 3 win64|[Download](./plug-ins/2023/boneDynamicsNode.mll)|
|Maya 2024 Update 2 win64|[Download](./plug-ins/2024/boneDynamicsNode.mll)|
|Maya 2025 Update 1 win64|[Download](./plug-ins/2025/boneDynamicsNode.mll)|
|Maya 2025 Update 2 win64|[Download](./plug-ins/2025/boneDynamicsNode.mll)|

## How to Build
For example, Maya 2024 in Windows:
Expand Down
Binary file modified plug-ins/2022/boneDynamicsNode.mll
Binary file not shown.
Binary file modified plug-ins/2023/boneDynamicsNode.mll
Binary file not shown.
Binary file modified plug-ins/2024/boneDynamicsNode.mll
Binary file not shown.
Binary file modified plug-ins/2025/boneDynamicsNode.mll
Binary file not shown.
24 changes: 22 additions & 2 deletions sample_scripts/advanced_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def create_dynamics_node(
target_bone=None,
offset_node=None,
colliders=[],
visualize=True
visualize=True,
additional_force_node=None,
additional_force_init_vec=[0,0,-1]
):

if not bone in cmds.listRelatives(end, p=True):
Expand Down Expand Up @@ -40,6 +42,19 @@ def create_dynamics_node(
if cmds.objExists(offset_node):
cmds.connectAttr(offset_node + '.worldMatrix[0]', boneDynamicsNode + '.offsetMatrix', f=True)

if additional_force_node:
if cmds.objExists(additional_force_node):
vp = cmds.listConnections(additional_force_node + '.worldMatrix[0]', s=False, d=True, type='vectorProduct')
if vp:
vp = vp[0]
else:
vp = cmds.createNode('vectorProduct')
cmds.setAttr(vp + '.operation', 3)
cmds.setAttr(vp + '.input1', additional_force_init_vec[0], additional_force_init_vec[1], additional_force_init_vec[2], type='double3')
cmds.setAttr(vp + '.normalizeOutput', 1)
cmds.connectAttr(additional_force_node + '.worldMatrix[0]', vp + '.matrix', f=True)
cmds.connectAttr(vp + '.output', boneDynamicsNode + '.additionalForce', f=True)

if visualize:
# angle limit
angle_cone = cmds.createNode("implicitCone")
Expand Down Expand Up @@ -133,6 +148,9 @@ def create_dynamics_node(

# Name of the node to offset the transform.
offset_node_name = "offset"

# Node name that controls the direction of additional force
additional_force_node_name = "wind"

# ---------------------------------------------------

Expand All @@ -149,7 +167,9 @@ def create_dynamics_node(
target_bone=bone+target_bone_postfix,
offset_node=offset_node_name,
colliders=colliders,
visualize=True
visualize=True,
additional_force_node=additional_force_node_name,
additional_force_init_vec=[0, 0, -1]
)

if boneDynamicsNode:
Expand Down
83 changes: 83 additions & 0 deletions scripts/AEboneDynamicsNodeTemplate.mel
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
global proc AEboneDynamicsNodeTemplate(string $nodeName)
{
editorTemplate -beginScrollLayout;

editorTemplate -beginLayout "Bone Dynamics Node Attributes" -collapse false;

editorTemplate -addControl "enable";
editorTemplate -addControl "time";
editorTemplate -addControl "resetTime";
editorTemplate -label "FPS" -addControl "fps";

editorTemplate -beginLayout "Input Attributes" -collapse false;
editorTemplate -addControl "boneTranslate";
editorTemplate -addControl "boneJointOrient";
editorTemplate -addControl "boneScale";
editorTemplate -addControl "boneInverseScale";
editorTemplate -addControl "boneParentMatrix";
editorTemplate -addControl "boneParentInverseMatrix";

editorTemplate -addSeparator;

editorTemplate -addControl "endTranslate";
editorTemplate -addControl "endScale";
editorTemplate -endLayout;

editorTemplate -beginLayout "Control Attributes" -collapse true;
editorTemplate -addControl "rotationOffset";
editorTemplate -addControl "offsetMatrix";
editorTemplate -addControl "offsetMatrixWeight";
editorTemplate -endLayout;

editorTemplate -beginLayout "Dynamics Attributes" -collapse false;
editorTemplate -addControl "damping";
editorTemplate -addControl "elasticity";
editorTemplate -addControl "elasticForceFunction";
editorTemplate -addControl "stiffness";
editorTemplate -addControl "mass";
editorTemplate -addControl "gravity";
editorTemplate -addControl "gravityMultiply";

editorTemplate -addSeparator;

editorTemplate -addControl "additionalForce";
editorTemplate -addControl "additionalForceScale";

editorTemplate -addSeparator;

editorTemplate -addControl "enableTurbulence";
editorTemplate -addControl "turbulenceSeed";
editorTemplate -addControl "turbulenceStrength";
editorTemplate -addControl "turbulenceVectorChangeScale";
editorTemplate -addControl "turbulenceVectorChangeMax";
editorTemplate -endLayout;

editorTemplate -beginLayout "Limits" -collapse true;
editorTemplate -addControl "enableAngleLimit";
editorTemplate -addControl "angleLimit";
editorTemplate -endLayout;

editorTemplate -beginLayout "Collisions" -collapse true;
editorTemplate -addControl "radius";
editorTemplate -addControl "iterations";
editorTemplate -addControl "enableGroundCol";
editorTemplate -addControl "groundHeight";
editorTemplate -addControl "sphereCollider";
editorTemplate -addControl "capsuleCollider";
editorTemplate -addControl "infinitePlaneCollider";
editorTemplate -label "Mesh Collider (*Experimental)" -addControl "meshCollider";
editorTemplate -addControl "meshColCutoff";
editorTemplate -endLayout;

//suppressed attributes
editorTemplate -suppress "outputRotate";

// include/call base class/node attributes
AEdependNodeTemplate $nodeName;

editorTemplate -addExtraControls;

editorTemplate -endLayout;

editorTemplate -endScrollLayout;
}
Loading

0 comments on commit f7fcea6

Please sign in to comment.