Cloth setup

We will cover the basic usage of Obi's cloth component: ObiCloth.

The Obi Cloth Component

To turn an object into a cloth:

  • Check it has either a MeshRenderer or a SkinnedMeshRenderer component.
  • Add a Obi Cloth component to it:
    • Select the object. Go to Component menu -> Physics -> Obi -> Obi Cloth
    • Or click "Add Component" button in the inspector and select "Obi Cloth".

This is how Obi Cloth's component in the inspector window looks like:

Obi Cloth Constraints

After adding a new Obi Cloth component to an object, Obi will also create several constraint components. Most of these components are optional and can be disabled to increase performance.

The constraint groups used for an ObiCloth are (in no particular order):

  • Aerodynamic Constraints
  • Distance Constraints
  • Bend Constraints
  • Pin Constraints
  • Skin Constraints
  • Volume Constraints

Each constraint component holds all properties and parameteres specific to that constraint type.

In the following sections we will take a look at the parameters of each constraint group, and how they can be used to achieve specific effects.

To get the simulation to work we need:

  • A mesh topology
  • A solver

The obi mesh topology asset

It generates and stores information about the topology of the mesh. This is needed in order to generate a particle-based representation of a it.

To create an obi mesh topology asset:

  • Go to Project panel (where all your project folders are displayed)
  • Right click on one of your project folders
  • Create -> Obi -> Obi Mesh Topology

To generate the topological information:

  • Select the ObiMeshTopology asset.
  • On the inspector panel select an Input Mesh your cloth is going to use.
  • Click on generate.

Here you can see the generated topology of a sphere in the inspector panel.

To assign this topology to your Obi Cloth:

  • Select your object where the Obi Cloth component is assigned
  • Go to Obi Cloth component in the inspector
  • Assign your topology on the "Shared Topology" property

Now click on "Initialize", and ObiCloth will figure out how to use particles and constraints to represent your topology.

Initializing should be done after changing the topology or if we want to reset all the parameters

The Obi Solver component

With just the topology, if we hit play nothing will happen. This is because ObiCloth only creates particles and sets up constraints between them, but does not perform any simulation by itself. That is the job of the ObiSolver component.

To create an Obi Solver component:

  • Select an existing Game Object or a new empty one just for this purpose.
  • Add a new Obi Solver component to it:
    • Select the object. Go to Component menu -> Physics -> Obi -> Obi Solver
    • Or click "Add Component" button in the inspector and select "Obi Solver".
  • Go to the Obi Solver component on the inspector
  • Make sure "Max Particles" is at least the same as your mesh.

To use the solver in your cloth:

  • Select your object where the Obi Cloth component is assigned
  • Go to Obi Cloth component in the inspector
  • Assign your Obi Solver on the "Solver" property

Last checks

To check if the cloth setup is properly done:

  • Enter play mode on the top bar and watch the simulation take place.

  • Click the big "Edit particles" button to enter particle editing mode.
  • Find the particle edit GUI on the viewport
  • Click the play button to see a preview of your particle simulation.
  • The cloth should fall (if you followed this guide and the Obi Solver is assigned)
  • Stop the simulation any time using the stop button

Summary

For now, keep in mind the steps to set up cloth:

  • Add the ObiCloth component to your cloth.
  • Add a ObiSolver component to any GameObject in your scene.
  • Generate the topology asset for the mesh your cloth is going to use.
  • Feed both the topology and the solver to your cloth, and click "Initialize".