In this example, the usage of constraint mechanics in DeepAR Studio will be showcased through the usage of rope constraints. The example includes two balloons connected to the user's ear with an imaginary rope and them moving respective to the user's head movement.

The steps to recreate this concrete example are given in the rest of the article. The given property values are all exemplary and can be adjusted if some value change doesn't result in the expected behaviour.

Step 0.a

Open the balloons.fbx file given in the zip that is located at the bottom of the article by selecting FileImport FBX or by pressing Cmd+I keyboard shortcut. The imported objects are located on the left in the hierarchy as nodes, under the root node RootNode.

Step 0.b

To enable visualisation of colliders go to PhysicsDebugShow Colliders. The visible colliders allow for more precise proper alignment of the added colliders with the objects present in the respective physics world.

Step 0.c

All descendants of the RootNode that contain one of the collider components can be made static for the effect creation process so that the made changes can be visible the process of making. The non-static objects in this example are the two balloon models and after setting up the transformation and other parameters, their static property should be disabled. By making a certain node static, all of its descendants become static as well, locking their positions in the previously defined physics world.

Step 1

In order to enable physics mechanics in the effect, a Physics World component needs to be added to RootNode by selecting the aforementioned node and then choosing PhysicsPhysics World. It is added in order to set core physics characteristics that will apply to the children nodes of the selected node recursively - in this case, all the descendants of RootNode in the hierarchy.

The changed properties in the added component, for this example, are:

  • Gravity: 0 -100 0

    • stronger gravity in the negative y direction results in the replication of the balloons being filled with helium and "defying gravity"

  • Kinematic Knockback Factor: 0

    • setting the property's value to 0 disables it - the collision of static and non-static objects will not produce any knockback on the non-static objects, in this case the two balloons.

Step 2

A new node that is a child of the RootNode is created, which will contain all the physics objects - in this example, the node is called Balloons. The two balloon nodes containing the balloon models should become the children of the newly made node by selecting RootNode and choosing NodeAdd Empty.

Also to be added is the Disable Child Nodes component that is accessible by selecting Add ComponentDisable Child Nodes. The component is added to a node that contains at least one physics object as its descendant in order to retain stability of such objects in the physics world.

The component's property Disable If Face Not Visible should be enabled so that the balloons that rely on the face and its state of being detected don't showcase unexpected behaviour when the user's face is detected again after not being detected for a certain period of time.

Step 3

Each of the two balloon objects needs to be added as a child to its specific new node and then additional new nodes should be added as the children of those objects that will represent the respective colliders.

The nodes are created by selecting the node that is to be the parent of the node that is to be created and then choosing NodeAdd Empty.

I.e, for each node repeat:

  • Create a new node and name it adequately - in this example, B1Node/B2Node

  • Move each balloon as the the child of the newly created node and optionally rename it - in this example, B1Model/B2Model

  • Select the object node (BxModel) and create a new node that will represent the balloons' colliders and rename them - in this example, B1Collider/B2Collider

The hierarchy should look like this:

Step 4

Step 4.a

The B1Node's Transformations component was changed in this example to the given values:

  • Position: -9 -4 0

Step 4.b

The B2Node's Transformations component was changed in this example to the given values:

  • Position: 9 -4 0

Step 4.c

Add the Physics Box Body component using PhysicsPhysics BodyPhysics Box Body to each of the two BxNode nodes and change the property settings for the both of them to the same values:

  • Static Object: enabled

  • Extent: 0.1 0.1 0.1

These colliders will act as attachments on the user's ears to which the invisible balloon strings will be attached.

Step 5

Step 5.a.i

The B1Model's Transformations component was changed in this example to the given values:

  • Position: -5 -10 0

  • Scale: 3 3.25 3.75

Step 5.a.ii

The B2Model's Transformations component was changed in this example to the given values:

  • Position: 5 6.5 0

  • Scale: 2.4 2.6 3

Step 5.b.i

The B1Model's colour can be changed in its Material properties component. One of the available shaders should be chosen, and for this example the changed properties were:

  • Select Shader: Standard shader

  • Diffuse color set to magenta.

  • Ambient color set to black.

  • Shininess: 16

  • Directional light color/Point light 1 color/Point light 2 color all set to white.

  • Lights intensity: 0 0 1

  • Directional light: 0 0 1

  • Point light 2 position: -1 0 1

Step 5.b.ii

The B2Model's colour can be changed in its Material properties component. One of the available shaders should be chosen, and for this example the changed properties were:

  • Select Shader: Standard shader

  • Diffuse color set to cyan.

  • Ambient color set to black.

  • Shininess: 100

  • Directional light color/Point light 1 color/Point light 2 color all set to white.

  • Lights intensity: 1 1 1

  • Directional light: 0 0 1

  • Point light 1 position: 1 0 1

  • Point light 2 position: -1 0 1

Step 5.c

Both nodes should have the Physics Rope Constraint component added to them, accessible through PhysicsConstraintsPhysics Rope Constraint. To reduce possible dislocation errors to a certain degree, the nodes' ERP value should be changed (done for both B1Model and B2Model) by:

  • Override ERP: enabled

  • ERP: 0.2

The Rope Length property of the B1Model should be set to 3, while for the B2Model it should be changed to 2.5.

Step 5.d

In order for the rope constraint to work, a Physics Box Body collider is added to the BxModel nodes using PhysicsPhysics BodyPhysics Box Body, since it needs parent and the child that are connected using this constraint to be in an immediate relationship (the child is the direct child of the node, not a descendant). The values to be changed are:

  • Mass: 0.1

    • give the balloons a lighter mass to resemble their real-life counterparts

  • Fixed Rotation should have the x and z axes as the fixed values.

    • in order to keep the balloons in a somewhat steady state, so that they don't roll around when animated

  • Extent: 0.1 0.1 0.1

These colliders will act as attachments on the user's ears to which the invisible balloon strings will be attached.

Step 6

Since the default colliders in the Studio have fixed rotation values (if added to the object itself, they inherit the position, but not the other properties), new empty nodes were added as children of the BxModel nodes respectively - BxCollider nodes. The Transformation and the Physics Capsule Body components should be added to these new nodes and changed to these values (for both the colliders):

Transformations component:

  • Rotation: 90 0 0

Physics Capsule Body component:

  • Static Object: enabled

  • Radius: 1.2

Step 7

An optional step is the addition of a collider for the user's head. The collider is added in the form of a simple capsule collider that mimics the head shape.

  • Select RootNode (making it the parent of the new node) and create a new node using NodeAdd Empty

  • Give the node an arbitrary name, in this example HeadCollider was chosen

  • Add the capsule collider component using PhysicsPhysics BodyPhysics Capsule Body

  • Set these values within the newly added Physics Capsule Body component:

    • Radius: 8

    • Height: 8

  • Change the Transformations component so that it properly aligns with the user's head

    • Position: 0 2 -5

The hierarchy should look like this:

Since the balloons are the only non-static object in the world, their positions will be reset every time the effect is reopened, by pressing the Reload button located on the upper right of the window or every time some value of any object in the effect is changed. Other (static) objects stay in the same position relative to the root node's origin point.

The final effect can also be obtained by opening the physics_balloons_finished file as an already existing effect using FileOpen effect or Cmd+O keyboard shortcut in the Studio.

After trying out the example, freely play around with the recommended settings to explore the possibilities of the represented physics mechanics.

Download the required .fbx file and the final effect

Did this answer your question?