A 3D Physics engine is a piece of software that provides an approximate simulation of certain physical systems, such as rigid body dynamics, soft body dynamics, fluid dynamics.
In Modulo Kinetic, the 3D Physics engine is accessible via a dedicated node in the Graph Editor
that can be linked to a 3D Scene.
The node enables you to create Bodies that can be linked to objects in your 3D Scene or that can exist independently as invisible objects.
Bodies are designed to be subject to physical forces that can be set in the graph either with static or dynamic data.
Bodies are also designed to interact with each other and the 3D Physics node has dedicated pins that trigger when a collision is detected between two bodies.
Node Settings
Properties
There are two tabs of properties available in the Editor
panel for this node : General and Bodies
The General tab contains general properties related to the 3D scene, general debug as well as Floor and Water settings.
The Bodies tab is a dedicated interface to create and manage the bodies in the 3D scene.
Inputs
Name | Type | Description |
---|---|---|
Enabled | Boolean | Set to True to activate the physics or false to deactivate the physics engine |
Array | Array | Array containing the physics data to apply on bodies. (See below) |
Outputs
Name | Type | Description |
---|---|---|
Debug | Array | Output to connect to the mesh emitter to display bodies in the 3D scene |
Boolean | Boolean | Sends a Trigger Event when a collision is detected |
ContactRemoved | Boolean | Sends a Trigger Event when two bodies that had previously collided are completely free from one another |
Shape_1 | String | Name of one of the bodies in the collision |
Shape_2 | String | Name of the other body in the collision |
Setting up Physics
Create a Physics node in a dedicated compute graph and in the Editor
panel fill the Scene 3d name property with the name of the 3D scene in which you would like to apply physics.
In the 3D Scenes
Material tab, create a material that will be dedicated to displaying the bodies when debug mode is active.
We recommend using a PBR material with Alpha Mode set to Blend and a value for alpha set to 200 so that bodies are distinguishable from one another when they overlap. The PBR material will react to the lighting in your scene and render the morphology of bodies better. Set the color of the material to the color of your choice.
In the Hierarchy tab, create a Mesh Emitter and apply the newly created material to it.
In the Graph Editor
drag & drop the Mesh Emitter Instance and connect the Debug output pin of the Physics node to the Data input pin of the Mesh Emitter node.
You are now ready to start creating Bodies in the Physics node and using them in your 3D Scene.
Bodies
When the Physics node is selected in the Graph Editor
, the Editor
panel presents two tabs : General and Bodies. This second tab contains an interface dedicated to creating and managing the bodies on which the physics will apply.
Click on the button to create a new body.
The left part of the tab contains the list of bodies in the 3D scene. The right part of the tab will contain the parameters for each body.
You can rename a body either by using the dedicated field in the right part or by double-clicking on its name in the list on the left.
Property | Description |
---|---|
Name | Name of the body |
Link status | Informs if the body is linked to a node in the 3D scene |
Offset position | If body is linked, offsets its position relative to the 3D node |
Offset rotation | If body is linked, offsets its rotation relative to the 3D node |
Shape | Select between Sphere, Box, Capsule or Cylinder |
Parameters | Defines the size of the shape |
Weight | Weight of body to affect the computation of collision between bodies |
Motion type | Select between Static, Kinematic and Dynamic |
Layer | Select between Static, Moving and Sensor |
Position * | Home position of the body in space. If the body has moved, this position will be recalled when the body is disabled. |
Rotation * | Home rotation of the body in space. If the body has moved, this rotation will be recalled when the body is disabled. |
Restitution * | Defines how much the body reacts on collisions |
Friction | If movement is defined by a Force (F) this value sets a friction factor for the bodies interaction when sliding on other bodies or the floor |
Linear speed limit | Sets a maximum speed for linear movements |
Angular speed limit | Sets a maximum speed for angular movements (when the body turns) |
Buoyancy | (If using water floor) Defines how much the body floats |
Linear drag | Defines how much the water (floor) will slow the body’s linear movement |
Angular drag | Defines how much the water (floor) will slow the body’s angular movement |
Friction works for forces F and FA (Forces) but will not affect V and VA (Velocity) (See below)
When modifying the Position and Rotation parameters of a body, it will only be dynamically displayed if the body is disabled.
If the body is enabled and these parameters are modified, the modifications will only be applied after the body has been disabled/enabled again.
Body paramaters
Here is a sample of all four body type available in the Physics engine:
From left to right : Box, Sphere, Capsule, Cylinder.
Box parameters
Parameter | Description |
---|---|
X | Scale along the X axis |
Y | Scale along the Y axis |
Z | Scale along the Z axis |
Sphere parameters
Parameter | Description |
---|---|
R | Radius of the sphere |
Capsule parameters
Parameter | Description |
---|---|
H | Scale along the Y axis |
R | Radius of the cylinder center part |
Cylinder parameters
Parameter | Description |
---|---|
H | Scale along the Y axis |
R | Radius of the cylinder |
Run-lock parameters
When you modify any parameter in the Run-lock parameters section, the body’s name will be highlighted red both in the list on the left and in the section on the right and the Validate
button will also display red.
Whenever these parameters are modified, you must click on the red Validate
button before these changes are taken into account by the Physics engine.
Linking a body to an object
To link a body to a 3D Node simply name it exactly the same as the name of the Node in the corresponding 3D Scene. The body will attach to the first node that is found in the Hierarchy tab that matches the bodie’s name.
When a body is attached to a node, the Link status will automatically update and display Linked and the node’s position and rotation values will override the values set in the body’s parameters.
Applying forces
To apply forces to a body in your Physics engine, create an array and connect it to the Physics node Array input pin.
The Add Item node can be used to easily and individually control the forces applied to each body.
In the Add Item node, add any of the following properties:
Property | Type | Description |
---|---|---|
name | String | (mandatory) This field will indicate which body to target |
enable | number | This can be connected to any boolean or number input. 0 will disable the body. Anything else will enable it |
Px | number | Offset point of application of force along the local X axis |
Py | number | Offset point of application of force along the local Y axis |
Pz | number | Offset point of application of force along the local Z axis |
FAx | number | Apply a force along the local X axis |
FAy | number | Apply a force along the local Y axis |
FAz | number | Apply a force along the local Z axis |
Fx | number | Apply a force along the global X axis |
Fy | number | Apply a force along the global Y axis |
Fz | number | Apply a force along the global Z axis |
VAx | number | Apply a velocity along the local X axis |
VAy | number | Apply a velocity along the local Y axis |
VAz | number | Apply a velocity along the local Z axis |
Vx | number | Apply a velocity along the global X axis |
Vy | number | Apply a velocity along the global Y axis |
Vz | number | Apply a velocity along the global Z axis |
TAx | number | Apply a rotation force along the local X axis |
TAy | number | Apply a rotation force along the local Y axis |
TAz | number | Apply a rotation force along the local Z axis |
Tx | number | Apply a rotation force along the global X axis |
Ty | number | Apply a rotation force along the global Y axis |
Tz | number | Apply a rotation force along the global Z axis |
UseV | boolean | Set to 0 to use Forces (FA and F) or set to 1 to use Velocity (VA and V). By default forces will be applied over velocity. |
SetX | number | Force the position along the global X axis |
SetY | number | Force the position along the global Y axis |
SetZ | number | Force the position along the global Z axis |
SetOx | number | Force a rotation along the local X axis |
SetOy | number | Force a rotation along the local Y axis |
SetOz | number | Force a rotation along the local Z axis |
Forces & hierarchy
Forces (FA and F) can be combined and apply a continuous effort on the body at the point of application (P) until the body reaches it’s linear and angular speed limits depending on how the force sets the object in motion. If the body is immobile when the force is applied, it will gradually accelerate until it reaches those limits.
Velocities (VA and V) can be combined and apply a constant speed on the body at the point of application (P) until it reaches it’s linear and angular speed limits as well. If the body is immobile when velocity is applied, it will immediately reach the specified velocity.
Rotation forces (TA and T) can be combined and apply a continuous rotation effort on the body at the center of the object (object origin) until the body reaches it’s angular speed limits. If the body is immobile when the force is applied, it will gradually accelerate until it reaches those limits.
When applying forces and velocity, the UseV flag can be used to select whether the forces apply or whether velocity applies. The rotation forces (TA and T) can be applied simultaneously to the forces (FA and F) but not with velocities (VA and V)
Global vs Local
Point of application
By default, all forces apply at local point (0, 0, 0) of a given body, which represents the bodies origin.
To visualize where that point is, place your body at position (0, 0, 0) and the center of the grid in the 3D Viewer will align with the bodies origin. It is generally the center of mass of the body.
You can use the (Px, Py, Pz) input parameters of a body to offset this point along any of the three axes. This offset is done on the local axes of the body and not on the global axes of the world.
When you offset the point of application, an additional small sphere will appear in or around the body to help visualize where this point is in space.
It is good practice when defining the point of application of a body to reset it’s rotation to (0, 0, 0) as well so that the local and global axes align.
Need more help with this?
Don’t hesitate to contact us here.