This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Rope Body

Rope body enables physical simulation of ropes, cables, wires, etc. Ropes can be pinned to the following types of bodies:

To pin a rope to a body so it would hang freely, or tie several bodies, use a particles joint. The rope body can be torn as a cloth body. Rope enhances the realism of simulated environment and saves the time of game artists as it replaces animation. However, simulation of this type of body is quite costly and it is strongly recommended to use distance optimization to avoid performance hits.
Notice
Rope body can be assigned only to dynamic mesh objects.

See also

Programming realization:

Mesh Requirements

The only acceptable mesh type for a rope body is a cylinder. You can use a standard primitive cylinder to create a rope. To do this via UnigineEditor perform the following steps:

  1. On the Menu bar, click Create -> Primitive -> Cylinder
  2. Specify desired rope parameters (length, radius) for a cylinder, e.g. the following.

    Create Cylinder

  3. Click Ok.
  4. Place the created dynamic mesh object in the world.
  5. Now a rope body can be assigned to the created object.

Mass-Spring Simulation Model

A rope body is modeled as set of point masses (particles) located in the mesh vertices. Each particle is represented with a sphere shape and is linked together with other particles by inner spring joints that are located along the mesh edges. Inner joints allow to recreate mesh topology, on the one hand, and constrain stretching and folding, on the other.

Mass-Spring Simulation Model

Each particle is characterized by a position, mass and velocity and has a constant spherical shape with a set radius. The total mass of the whole body is equally distributed among them. In accordance with Newton's second law particles can be acted upon by a force or an impulse applied by inner joints and external forces (collision, gravity, air resistance, wind, etc.).

Self-collision of the particles and collisions between different cloth bodies are not calculated. However, the cloth interacts with environment by colliding with other physical bodies if Collision box is checked. Its behavior in case of contact is controlled by such parameters as friction and restitution. Selective physical interaction is available via corresponding bitmasks

Thus, rope body can be regarded as constrained system of rigid particles and therefore shares some parameters with rigid bodies:

Particle Radius

As it was already mentioned, each particle is a sphere with a set radius. Thus, particles use continuous collision detection. The rope never lies flat on the ground or tightly adheres to the surfaces. There is always a gap equal to particle radius.

As collisions between the particles are not calculated, they should not be considered when setting a radius:

  • Higher values are preferable for more robust behavior. However, too big radius may result in incorrect interaction with the environment (twitching or blowing up of the rope).
  • Lower values decrease the gap between the rope body and the surface. However, too low radius results in poor collision handling.

Notice
An object can pass through the rope, when the particle radius is small and the rope is stretched. The reason is that continuous collision detection is performed only for particle spheres located in vertices of rope mesh.

Joints Solver Iterations

The number of iterations controls the accuracy of the solution of rope inner joints. This number indicates how many times the joints are solved per physics frame. Joints are solved in a random order to provide more predictable stretching results.

  • Low number of iterations results in faster simulation. However, in this case the rope is more prone to stretching and looks more elastic. The minimum value is 1.
  • High number of iterations provides more accurate solution of constraints. In this case the rope lookes stiffer. The maximum value is 16.
    Notice
    Increased number of iterations is considerably expensive and at some point ceases to bring a noticeable benefit, so it should be kept within a reasonable cost-effectiveness limit.
Increasing the number of iterations may help to avoid twitching of a rope.

Stretching and Folding

A rope may be deformed by stretching and folding. These deformations are controlled with joint constraints of two types:

With these types of constraints, it is possible to obtain the desired look and feel of the rope and simulate a variety of different deformable materials ranging from a stiff metal wire to an elastic rubber cord.

Linear Restitution

Linear restitution determines how far the rope particles can be stretched apart from each other. It enforces rope joints to restore the distance that was between the vertices of the original mesh:

  • By the maximum value of 1, the particles spring back with great force and the rope is hard to stretch. It gives the effect of stiff non-stretch rope, e.g. a metal wire.
  • The lower the value, the easier the particles are moved away from each other and the more stretchable and elastic the rope is, e.g. a rubber cord.
    Notice
    0 and near zero values are not allowed because they cause unstable simulation and blowing up of the rope.

Angular Restitution

Angular restitution determines the possible angle between rope triangles that are formed by particles. It constrains the folding of the rope by enforcing joints to keep the angle between the triangles of the original mesh:

  • By the maximum value of 1, the angles tend to be retained and the rope resists folding. The rope appears to be stiff.
    Notice
    The maximum value may provide unsteady behavior.
  • By the minimum value of 0, the rope can be easily folded and bent in any direction, regardless of the original topology of the mesh.

Notice
If the rope is too stretchy and rubbery, try one of the following:
  • Set linear restitution to 1.
  • Increase the number of joints solver iterations.
  • Use the mesh with fewer vertices.

Rigidity of Motion

Rigidity parameter is an additional constraint of the rope motion to make it stiffer and more inflexible. For that purpose, linear and angular velocities of each rope particle are corrected according to the total velocities interpolated for all the particles.

  • The minimum value of 0, makes the rope elastic, flexible and easily deformable.
  • The maximum value of 1, makes the rope stiffer and less prone to deformation.

Tearing

When the rope is stretched or folded beyond its elastic limit, it tears and shreds into pieces. Tearing is caused by applying the force or collision with a physical body, and depends on the rope stiffness (controlled by linear and angular restitution parameters). The rope is torn only along the edges of rope triangles, splitting mesh vertices and duplicating particles.

Notice
If torn pieces of rope fall onto one plane, they cause z-fighting.

Linear Threshold Distance

Linear threshold sets the distance limit for stretching the rope. When two particles move away from each other further than this limit, joints that connect them break and a the tear appears.

  • If set to infinity (inf), the rope is stretched without tearing. This value is set by default.

Angular Threshold Angle

Same as linear threshold, angular threshold represents a maximum angle to fold the rope relative to its initial state.

  • If set to infinity (inf), the rope is folded without tearing. This value is set by default.
    Notice
    It is recommended to keep the angular threshold lower or equal to 180 degrees.

Simulation Distance

To improve performance and avoid excessive load, simulation of the rope can be limited to the specified distance. When the player is out of this area, the rope stops to be updated and freezes statically. Particles joints also become inactive and cease to attach pinned bodies.

  • If set to infinity (inf), there is no distant-dependent optimization for rope. This value is set by default.

Notice
If distant-dependent optimization is used, rope body should be attached only to static bodies. Otherwise, it may cause visually incorrect behavior, such as rope hanging in the air or attached bodies fall loose due to gravity. In case of attaching a rope to dynamic objects, use Physics distance.

Assigning a Rope Body

To assign a rope body to an object via UnigineEditor perform the following steps:

  1. Open the World Hierarchy window
  2. Select a dynamic mesh object to assign a rope body to.
    Notice
    Make sure that object's mesh meets requirements!
  3. Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> Rope.

    Adding a body

  4. Set body's name and change other parameters if necessary.

Attaching a Rope

Rope attached to a skinned mesh

Rope attached to animated character

Ropes can be attached to the following types of bodies:

To attach a rope to a body use a particles joint. In case of rigid bodies (either static or dynamic) and dummy bodies, pinned particles stay fixed in their position and follow transformations of attached objects pulling the rope with it.
  1. Select a rigid body, a ragdoll body or a dummy body.
  2. Add a particles joint.
  3. Specify a rope body.
  4. Adjust the pinning area using threshold and size parameters of the particles joint.

Notice
To ensure stable simulation it is important to set appropriate masses of the rope and the attached body. Unbalanced masses may cause twitching of rope joints.

Attachment to Skinned Mesh

Convincing simulation of the rope on a skinned character requires a different approach. To follow bones transformations, each vertex of the rope that is found in the particles joint area is mapped to the nearest skinned mesh vertex (up to the distance specified by the Threshold parameter of the particles joint).

Notice
It is not recommended to attach the rope directly to the skinned character, because difference in topologies may result in visual artifacts. Instead of it, it is better to create an identical rope surface on the skinned mesh character, make it invisible and attach a physical rope to it.

For example, we need to create a rope that is glued to the hand of a skinned character while the rest of the rope hangs and moves loosely. It is done in the following steps:

  1. When creating a skinned mesh, add a rope segment surface identical to the clipped part that needs to be pinned. In our case, it's rope part in a hand.
  2. Add skinned mesh that has a ragdoll body assigned. Make sure that the rope segment surface is enabled.
  3. Add a separate dynamic rope mesh and synchronize its position with skinned character. Turn off physical simulation (CTRL + SPACE) and assign a rope body.
  4. Attach rope body to ragdoll body. If the Threshold distance of the particles joint is set low enough, the physical rope will be automatically attached only to the rope segment surface (i.e. hand). After that, the rope segment surface is simply disabled and does not provide any load at all.
Last update: 2018-04-26
Build: ()