Tutorials

This page includes tutorials for getting acquainted the most important features of the plugin. The results of the tutorials are available under Deform Dynamics/Scenes/Tutorials.

At the end of each tutorial, we will refer to one of the demo scenes that utilize this functionality. Although the tutorials presented here can be used on their own, we recommend you to also study the demos provided.

Always create a new scene for each tutorial.

Getting started

This tutorial describes how to generate a cloth using the built-in Deform Patch Creator, and how to create an interesting simulation by hanging it from two corners.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the Deform Manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (4, 4) and the Resolution (81) of the patch, and click the Create patch button.
  4. Choose a material that the patch should use. In the Mesh Renderer component, expand the Materials and click on the dot next to the material parameter, locate the material Cloth blue in the assets and apply it.

Fixing two vertices

  1. In the Deform Body component of the GameObject, press Fixed vertices.
  2. In the scene view, you will notice a set of white particles corresponding with the vertices of the patch. Paint the corners of the cloth by moving the mouse cursor on top of the particles and left-click.

Enabling interaction with the cloth

  1. In the object containing the Deform Body component, press Add Component, and search for Deform Picking. Add the Deform Picking component to the body.
  2. This means that you can use the mouse to pick and drag the cloth in play mode.

Running the simulation

  1. Press play in Unity.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Demos > HangingCloth.

Using implicit colliders

This tutorial describes how to generate a cloth using the built-in Deform Patch Creator, and drop it on a rotating Deform Collider Sphere. We will also add a Deform Collider Plane with friction.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (3, 3) and the Resolution (111) of the patch, and click the Create patch button.
  4. Move the patch by setting the Y-position of the Transform component to 0.5.
  5. Choose a material that the patch should use. In the Mesh Renderer component, expand the Materials and click on the dot next to the material parameter, locate the material Cloth blue in the assets and apply it.

Adding a Deform Collider Sphere

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Collider > Sphere to create a Deform Collider Sphere.
  3. Set the Radius of the sphere to 0.4.
  4. Set the Kinetic Friction to 0.75 and the Static Friction to 2.25.
  5. Enable Show Collider In Game. Now a material parameter can be set. Press the dot next to the parameter, locate the material ColliderMaterial and apply it.
  6. Set the Bias of the sphere collider to 0.05. This is to prevent z-fighting.

Adding a Deform Collider Plane

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Collider > Plane to create a Deform Collider Plane.
  3. Move the plane by setting the Y-value of the Transform component to -0.75.
  4. Set the Kinetic Friction to 0.4 and the Static Friction to 1
  5. Enable Show Collider In Game. Now a material parameter can be set. Press the dot next to the parameter, locate the material ColliderMaterialGray and apply it.
  6. Set the Bias of the plane collider to 0.001. This is to prevent z-fighting.

Rotating the Deform Collider Sphere

  1. Select the Deform Collider Sphere in the Hierarchy window.
  2. Press Add Component, and search for Rotator. Add the Rotator component. The code of the Rotator script can be seen at the end of this tutorial.
  3. Leave the Axis at (0, 1, 0) and set the Velocity to 0.02.

Running the simulation

  1. Press play in Unity.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > RotatingSphereCollider.

The rotator script:

public class Rotator : MonoBehaviour {

  public Vector3 axis = Vector3.up;
  public float velocity = 0.01f;

  void Update () {
    transform.RotateAround(transform.position, Vector3.up, velocity);
  }
}

Sewing two patches together

This tutorial describes how to use the Sewing editor, to sew two patches together. The patches will then fall upon a sphere.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (2, 2) and the Resolution (51) of the patch, and click the Create patch button.
  4. Move the patch by setting the X-position of the Transform component to 1.25.
  5. Choose a material that the patch should use. In the Mesh Renderer component, expand the Materials and click on the dot next to the material parameter, locate the material Cloth pink in the assets and apply it.
  6. Create a second cloth patch by repeating the proces in step 1-5. This time, set the X-position to -1.25 and the material to Cloth purple.

Sewing the patches together

  1. In the main menu bar, press Deform Dynamics > Sew to open up the Sewing editor. This will expose the Sewing editor, and the contour points of the Deform Bodies.
  2. We will use the Vertex mode for this tutorial. In Vertex mode we need to select the start and end points of two seam lines, by hovering over a contour point and pressing the left mouse button.
  3. Select the start point of seam line A:

  4. Select the end point of seam line A:

  5. Select the start point of seam line B:

  6. Select the end point of seam line B:

  7. Press Create seam to create the seam:

Adding a Deform Collider Sphere

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Collider > Sphere to create a Deform Collider Sphere.
  3. Set the Kinetic Friction to 0.3 and the Static Friction to 2.25.
  4. Enable Show Collider In Game. Now a material parameter can be set. Press the dot next to the parameter, locate the material ColliderMaterial and apply it.
  5. Set the Bias of the sphere collider to 0.05. This is to prevent z-fighting.
  6. Move the collider by setting the Y-position of the Transform component to -0.6.

Enabling interaction with the cloth

  1. In the objects containing Deform Body components, press Add Component, and search for Deform Picking. Add the Deform Picking component to the bodies.
  2. This means that you can use the mouse to pick and drag the cloth in play mode.

Running the simulation

  1. Press play in Unity.
  2. Pick the cloth by right-clicking and dragging.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > SewingPatches.

Creating a simulation from a mesh

This tutorial describes how to simulate a triangular mesh. This is good for creating garments from pre-defined meshes. It is important that the mesh you want to simulate has triangles of approximately the same size. You can examine the meshes used in the demo scenes to see examples of meshes that are well suited for simulation.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the Deform Manager.
  3. The manager is initialized with a set of default parameters which you can use. In this tutorial, we will change these default parameters.

Changing the Deform Manager parameters

  1. Select the Deform Manager game object in the Hierarchy window.
  2. Set the Gravity to (0, 0, 0).
  3. Enable Ignore Intersecting Particles. When you want to simulate triangular meshes, multiple self collider particles might spawn inside each other. With this option enabled, we can mitigate this problem.

Adding a simulated mesh

  1. Locate the prefab partyfrock by navigating to Assets > Deform Dynamics > Resources > Meshes in the Project window.
  2. Drag the entire prefab to the Hierarchy window.
  3. Set the rotation of the object in the Transform component to (0, 180, 0).
  4. The parent object only has a transform. The Deform Body component only works on objects which contain a Mesh filter. Expand the partyfrock object in the Hierarchy window and select the child object default.
  5. Choose a material that the dress should use. In the Mesh Renderer component of the partyfrock child object, expand the materials list and click on the dot next to the material parameter, locate the material Cloth red in the assets and apply it.
  6. With the partyfrock child object selected, press Add Component, and search for Deform Body. Add the Deform Body component to the object.

Enabling interaction with the cloth

  1. In the object containing the Deform Body component, press Add Component, and search for Deform Picking. Add the Deform Picking component to the body.
  2. This means that you can use the mouse to pick and drag the cloth in play mode.

Running the simulation

  1. Press play in Unity.
  2. Pick the cloth by right-clicking and dragging.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > ClothFromMesh.

Exporting a simulation

This tutorial shows how to set up recording and exporting an animation to an .fbx file, using the Deform Exporter. The resulting .fbx file and point cache files can then be loaded into the 3d modeling tool of your choosing, for example 3ds Max. We will be using the same hanging cloth setup as in the first tutorial.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (4, 4) and the Resolution (81) of the patch, and click the Create patch button.
  4. Move the patch by setting the Y-value of the Transform component to 5.
  5. Choose a material that the patch should use. In the Mesh Renderer component, expand the Materials and click on the dot next to the material parameter, locate the material Cloth blue in the assets and apply it.

Fixing two vertices

  1. In the Deform Body component of the GameObject, press Fixed vertices.
  2. In the scene view, you will notice a set of white particles corresponding with the vertices of the patch. Paint the corners of the cloth by moving the mouse cursor on top of the particles and left-clicking.

Adding a Deform Exporter

  1. Select the Deform Body in the Hierarchy window.
  2. Press Add Component, and search for Deform FBX Exporter. Add the Deform FBX Exporter component to the cloth object.
  3. In the Deform FBX Exporter component, press the [...]-button to specify a file path, where the animation will be saved.
  4. Enable the recording by pressing Record animation to .fbx. Note that the recording will not start until the simulation starts. You can also press this button to start the recording during the simulation.

Running the simulation

  1. Press play in Unity.
  2. When you want to end your recording, simply press the Record animation to .fbx button again, or end the simulation by pressing the Play button again.

Example of the recording in 3ds Max

The fbx file can then be imported into 3ds Max, and a Point Cache modifier can be added to the object. The result can be seen in the gif above.

Using the Mesh Collider

The mesh collider can be applied to any GameObject that has a Mesh Filter or a Skinned Mesh Renderer. When an object has a mesh collider component, all DeformBody objects will collide with the triangles of the mesh.




To achieve the best possible results, the mesh should adhere to the following criteria:

If the mesh you want to collide against doesn't fulfill these criteria, the simulation may still work but it will not be optimized. To solve this problem, the Use Proxy toggle of the Deform Collider Mesh component can be enabled, which allows you to provide a separate mesh that will only be used for collision handling. Additionally, it is possible to generate such a mesh by pressing the Generate proxy button. This opens up a customized view of the Remesher, where a mesh that adheres to the above criteria can be created using the mesh provided via the Mesh Filter/Skinned Mesh Renderer. By pressing Save mesh asset and use as proxy, the generated mesh will both be saved to disk and used as a proxy in the Deform Collider Mesh component.

An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > MeshColliderRemeshed.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (1.5, 1.5) and the Resolution (71) of the patch, and click the Create patch button.
  4. Move the patch by setting the position of the Transform component to (0, 1.1, 0) and the rotation to (0, 30, 0).
  5. Choose a material that the patch should use. In the Mesh Renderer, expand the Materials and click on the dot next to the material parameter. Locate the material Cloth blue in the assets and apply it.

Adding the monkey mesh collider

  1. Locate the prefab monkey_highres by navigating to Assets > Deform Dynamics > Resources > Meshes in the Project window.
  2. Drag the entire prefab to the Hierarchy window.
  3. The parent object only has a transform. The Deform Collider Mesh component only works on objects which contain either a Mesh Filter or a Skinned Mesh Renderer. Expand the monkey_highres object in the Hierarchy window and select the child object default.
  4. Press Add Component, and search for Deform Collider Mesh. Add the Deform Collider Mesh component to the object.
  5. Set the Kinetic Friction to 0.65 and the Static Friction to 0.85.
  6. Set the Bias to 0.012.
  7. Enable Use proxy and generate a proxy mesh with 6000 vertices by pressing Generate proxy.
  8. Apply the proxy by pressing Save mesh asset and use as proxy.

Running the simulation

  1. Press play.

Creating a clothed character

In this tutorial, we will show how to create an animated character with clothes. To do this, we use two external tools: MakeHuman and Mixamo. We will briefly explain how we acquired the character animation. For further information, we refer to MakeHuman and Mixamo documentation. We will also use the same approach as in the tutorials Creating a simulation from a mesh and Using the mesh collider.

If you use your own character creation pipeline, or if you want to use the characters provided with the plugin project, you can skip the first three sections of this tutorial. Remember that the character needs a Skinned Mesh Renderer in Unity.

Creating a character using MakeHuman

  1. Download MakeHuman from http://www.makehumancommunity.org/content/downloads.html
  2. Open MakeHuman, and create your character using their GUI.
  3. Go to the Pose/Animate tab and choose the default skeleton in the skeleton tab, and the T-pose in the pose tab.
  4. Export the character as an FBX file.

Assigning an animation to the character using Mixamo

  1. Go to www.mixamo.com and log in (or create an account if you don't have any)
  2. Press Upload character and choose the character you want to use.
  3. Choose the animation you want to use
  4. Press download and choose the following options
    • Format: FBX for Unity(.fbx)
    • Skin: With skin
    • Frames per Second: 60
    • Keyframe Reduction: none

Importing your character in Unity

  1. Drag and drop the .fbx file which you downloaded from Mixamo into your Project window.
  2. Create a new Animator Controller by right-clicking in the Project window.
  3. Double click the Animator Controller to open it.
  4. Right-click in the Animator window, and create a new state.
  5. Press the new state and assign the motion which is located inside the prefab which was created when you imported the fbx file.

From this point in the tutorial, we will assume that you use the characters and clothes which are already present in the project. Of course, you can use the character which you obtained by following the previous two sections, but for the sake of the tutorial, we will refer to the meshes in the project.


Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.

Adding the character to the scene and assign a mesh collider to it

  1. Locate the prefab makehuman_rigged_w_hair@Walk by navigating to Assets > Deform Dynamics > Resources > Meshes > Animated > WomanWalking in the Project window.
  2. Drag the prefab makehuman_rigged_w_hair into the Hierarchy window.
  3. Set the Scale (2, 2, 2) of the Transform component.
  4. Assign the animation controller highres_walking, located at Assets > Deform Dynamics > Resources > Meshes > Animated > WomanWalking to the controller in the Animator component.
  5. Press Add Component, and search for AnimationSynchronizer. Add the AnimationSynchronizer component. The script synchronizes the animation of the visual character with the time inside the physics engine.
  6. Expand the selected object in the Hierarchy window, and go to the child object makehuman_rigged_w_hairMesh which contains the Skinned Mesh Renderer.
  7. Press Add Component, and search for Deform Collider Mesh. Add the Deform Collider Mesh component to the object.
  8. Set the Kinetic Friction (0.3) and the Static Friction (1.5).
  9. Set the Bias (0.0015).

Adding a dress to the character

  1. Locate the prefab berkeley_dress_b by navigating to Assets > Deform Dynamics > Resources > Meshes in the Project window.
  2. Drag the entire prefab to the Hierarchy window.
  3. The parent object only has a Transform component. The DeformBody component only works on objects which contain a Mesh filter. Expand the berkeley_dress_b object in the Hierarchy window and select the child object default.
  4. Set the Position (-0.42, 2.225, 0.742) the Scale (2, 2, 2) in the Transform component. We want the garment to fit the character as well as possible in the initial configuration. Note that you have to do this on the child object which contains the Mesh filter.
  5. Choose a material that the patch should use. In the Mesh Renderer component, expand the materials list and click on the dot next to the material parameter, locate the material Bottom material in the assets and apply it.
  6. Press Add Component, and search for Deform Body. Add the Deform Body component to the object.

Painting friction

  1. In the Deform Body component, press the button Kinetic friction. In the Scene view, at the bottom right, you will see a Vertex paint editor.
  2. In the Deform Body component, under the Kinetic friction button, set the Amount to 0.9 and paint the entire upper part of the dress by left-clicking in the scene view.
  3. Now, we will paint the static friction. Press the Static friction button. Set the Amount to 3.5 and paint the entire upper part of the dress.

Running the simulation

  1. Press play.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > ClothedCharacter.

Creating garments from DXF-files

In this tutorial, we will explain how to import cloth patterns from DXF-files and sew them together. DXF-files are usually created using CAD software, and is the industry standard for garment patterns. In the plugin project, we will provide a basic pattern created using FreeCAD, that can be used to create a t-shirt. In this tutorial, we will sew this t-shirt around a character mesh.

Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. Enable Sample Surface. This option makes it so that the patches get an even distribution of self-collision particles.

Adding a character mesh collider

  1. Locate the prefab male_fat@T-pose by navigating to Assets > Deform Dynamics > Meshes > Animated > new_characters in the Project window.
  2. Drag the prefab male_fat@T-pose into the Hierarchy window.
  3. Expand the selected object in the Hierarchy window, and go to the child object male_fatMesh which contains the Skinned Mesh Renderer.
  4. Press Add Component, and search for Deform Collider Mesh. Add the Deform Collider Mesh component to the object.
  5. Set the Kinetic Friction (0.1) and the Static Friction (1.0).
  6. Set the Bias (0.0025).
  7. Enable Use proxy and generate a proxy mesh with 5000 vertices by pressing Generate proxy.
  8. Apply the proxy by pressing Save mesh asset and use as proxy.

Importing a DXF-pattern

  1. When you drag a DXF-file (Note! Its file ending has to be .dxf2, due to Unity already using the .dxf file ending) into the Project window, a prefab will be created. The parent prefab is containing the import settings, while the child prefab contains a Mesh Renderer, Mesh filter and the correct Transform.
  2. In this tutorial, we will use the shirt3 pattern, located at Assets > Deform Dynamics > Resources > Patterns.
  3. Expand the shirt3 object and drag four shirt3 [0] 0 prefabs into the Hierarchy window.
  4. Set the transform component of these four patterns as follows:
    • [1] Position: (0, 1.15, -0.15), Scale: (0.04, 0.04, 0.04)
    • [2] Position: (0, 1.15, 0.25), Scale: (0.04, 0.04, 0.04)
    • [3] Position: (0, 1.10, -0.2), Scale: (0.055, 0.055, 0.055)
    • [4] Position: (0, 1.10, 0.3), Scale: (0.055, 0.055, 0.055)
  5. Select all four patterns in the Hierarchy window. Set the triangle size of the Deform Pattern component to 0.0001 and press Triangulate.
  6. Select all four patterns in the Hierarchy window. Press Add Component, and search for Deform Body. Add the Deform Body component to all the objects.
  7. Set the material of patch 1 and 2 to BottomCloth.
  8. Set the material of patch 3 and 4 to TopCloth.

Sew the patches together

  1. Select patch 3 and 4 and disable the GameObjects.
  2. In the main menu bar, press Deform Dynamics > Sewing to open up the Sewing editor. This will expose the Sewing editor, and the contour points of the Deform Bodies. In this tutorial, we will be utilizing both the Vertex mode and the Contour mode of the Sewing editor.
  3. Reduce the Sphere size until you get a satisfactory size.
  4. Select Contour mode in the Sewing editor. When in Contour mode the seam lines will be defined depending on which part of the contour you press. If you press between two distinct parts of a contour, you will select both parts. Select the seam lines as shown below:
  5. Select Vertex mode in the Sewing editor. When in Vertex mode the seam lines will be defined by four points: the start and end points of seam line A, and the start and end points of seam line B. Create a seam for the upper part of the sleeve like this:
  6. Repeat step 4 and 5 for the other side of the mesh.
  7. Enable patch 3 and 4 again, and repeat steps 4, 5 and 6.
  8. In the end, you will end up with the following seam lines:

Set the sewing priority

  1. Select the last four Deform Seams in the hierarchy window.
  2. Set the Priority to 100. This will make it so that they stitch together 100 frames after the first four Deform Seams are done.

Running the simulation

  1. Press play.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > ClothedCharacterDXF.

Saving and loading a garment configuration

This tutorial will show how to save a cloth configuration, and start the simulation from that configuration at another time. For example, this can be useful for setting up a garment of a character in T-pose, animate the character to an arbitrary pose, save the configuration, and then start the animation and cloth configuration from that pose. In this tutorial, we will only show a basic example.

We will be using the same setup as in the previous tutorial Creating garments from DXF-files. If you have already done the previous tutorial, you can skip to Saving the current configuration.



On the left: Original configuration. On the right: Using deformed meshes with a base mesh

Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. Enable Sample Surface. This option makes it so that the patches get an even distribution of self-collision particles.

Adding a character mesh collider

  1. Locate the prefab male_fat@T-pose by navigating to Assets > Deform Dynamics > Resources > Meshes > Animated > new_characters in the Project window.
  2. Drag the prefab male_fat@T-pose into the Hierarchy window.
  3. Expand the selected object in the Hierarchy window, and go to the child object male_fatMesh which contains the Skinned Mesh Renderer.
  4. Press Add Component, and search for Deform Collider Mesh. Add the Deform Collider Mesh component to the object.
  5. Set the Kinetic Friction (0.1) and the Static Friction (1.0).
  6. Set the Bias (0.0025).
  7. Enable the Remesh option, and set the Num Remeshed Vertices (4000).

Importing a DXF-pattern

  1. When you drag a DXF-file (Note! Its file ending has to be .dxf2, due to Unity already using the .dxf file ending) into the Project window, a prefab will be created. The parent prefab is containing the import settings, while the child prefab contains a Mesh Renderer, Mesh filter and the correct Transform.
  2. In this tutorial, we will use the shirt3 pattern, located at Assets > Deform Dynamics > Resources > Patterns.
  3. Expand the shirt3 object and drag four shirt3 [0] 0 prefabs into the Hierarchy window.
  4. Set the transform component of these four patterns as follows:
    • [1] Position: (0, 1.15, -0.15), Scale: (0.04, 0.04, 0.04)
    • [2] Position: (0, 1.15, 0.25), Scale: (0.04, 0.04, 0.04)
    • [3] Position: (0, 1.10, -0.2), Scale: (0.055, 0.055, 0.055)
    • [4] Position: (0, 1.10, 0.3), Scale: (0.055, 0.055, 0.055)
  5. Select all four patterns in the Hierarchy window. Set the triangle size of the Deform Pattern component to 0.0001 and press Triangulate.
  6. Select all four patterns in the Hierarchy window. Press Add Component, and search for Deform Body. Add the Deform Body component to all the objects.
  7. Set the material of patch 1 and 2 to BottomCloth.
  8. Set the material of patch 3 and 4 to TopCloth.

Set the sewing priority

  1. Select the last four Deform Seams in the Hierarchy window.
  2. Set the Priority to 100. This will make it so that they stitch together 100 frames after the first four Deform Seams are done.

Start from this point if you have already completed the tutorial Creating garments from DXF-files or are working directly with the scene Deform Dynamics > Scenes > Tutorials > ClothedCharacterDXF.


Adding Deform Mesh Asset Generators

  1. Add a Deform Mesh Asset Generator component to all Deform Bodies in the scene.
  2. Select a path within your Unity project and a name for all the meshes. Please note that the path must lie within your project. For example:
    Assets/shirt0_base.asset
    Assets/shirt1_base.asset
    Assets/shirt2_base.asset
    Assets/shirt3_base.asset
  3. Select all Deform Bodies that now contain Deform Mesh Asset Generators and press Generate mesh asset.
  4. Four mesh assets should now be present in your assets-folder.

Saving the base meshes

  1. Select all Deform Bodies.
  2. In the Deform Mesh Exporter, press Export mesh.
  3. Note: This should be done without running the simulation.

Saving the deformed meshes

  1. Change the postfix in the Deform Mesh Asset Generators to deformed. Now your Deform Mesh Asset Generators should have the following paths:
    Assets/shirt0_deformed.asset
    Assets/shirt1_deformed.asset
    Assets/shirt2_deformed.asset
    Assets/shirt3_deformed.asset
  2. Press play and let the simulation run for a few seconds.
  3. When the cloth is in the correct configuration, select all Deform Bodies, go to the Deform Mesh Asset Generator component and press Generate mesh asset.
  4. End the simulation by pressing the Play-button again.
  5. Four new mesh assets should now be present in your assets-folder, and they should be deformed in a way that corresponds with the character.

Using the deformed meshes

  1. For each Deform Body, change the mesh in the Mesh filter to the corresponding mesh that you saved with the _deformed postfix.
  2. For each Deform Body, add the corresponding mesh with the _base postfix in the Base Mesh parameter of the Deform Body.
  3. Now your clothes should be in a good starting position, but use the correct physical parameters of the base meshes.

Running the simulation

  1. Press play.

Creating one piece sleeves

This tutorial will show how to create sleeves for a t-shirt that is made from one mesh. If you only want to see how to create the sleeve, you can open the demo Deform Dynamics > Scenes > Tutorials > ClothedCharacterSleeves, and start the tutorial from Bending the sleeves.

Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the manager.
  3. Enable Sample Surface. This option makes it so that the patches get an even distribution of self-collision particles.

Adding a character mesh collider

  1. Locate the prefab male_fat@T-pose by navigating to Assets > Deform Dynamics > Resources > Meshes > Animated > new_characters in the Project window.
  2. Drag the prefab male_fat@T-pose into the Hierarchy window.
  3. Expand the selected object in the Hierarchy window, and go to the child object male_fatMesh which contains the Skinned Mesh Renderer.
  4. Press Add Component, and search for Deform Collider Mesh. Add the Deform Collider Mesh component to the object.
  5. Set the Kinetic Friction (0.1) and the Static Friction (1.0).
  6. Set the Bias (0.0025).

Importing t-shirt patches

  1. Navigate to Assets > Deform Dynamics > Resources > Meshes > berkeley_tshirt.
  2. Drag all the objects, called tshirt_patchX into the Hierarchy window.
  3. Set the transform component of these four patches as follows:
    • [1] Position: (-0.5, 1.5, 0), Rotation: (0, -90, 0)
    • [2] Position: ( 0.5, 1.5, 0), Rotation: (0, 90, 0)
    • [3] Position: ( 0.15, 1.25, 0.25), Rotation: (0, 0, 0)
    • [4] Position: (-0.15, 1.25, 0.25), Rotation: (0, 0, 0)
    • [5] Position: (0.15, 1.25, -0.15), Rotation: (0, 180, -90)
    • [5] Position: (-0.15, 1.25, -0.15), Rotation: (0, 180, -90)
  4. Set the material of all the patches to BottomCloth.

Sew the patches together

  1. Select all the child objects called default, and add a DeformBody component to them. Make sure you add the DeformBody to the objects with a MeshFilter.
  2. In the main menu, press Deform > Sew
  3. If the sphere is too large, reduce the Sphere size in the Sewing editor.
  4. To define a seam, four points have to be selected: the start-/end points of seam line A, the start-/end points of seam line B. Once you select the start point of A, the editor will automatically jump to the end point of A, and so forth.
  5. Define the following seams:











  6. Repeat the process for the other side.

  7. In the end, you will end up with something similar to the picture below:

Bending the sleeves

  1. In order to sew the sleeves to themselves, around the arm, we need to apply a Deform Modifier Bend. Select the child object of tshirt_patch1, where the DeformBody and MeshFilter are located. Press Add Component, and search for Deform Modifier Bend. Add the Deform Modifier Bend component to the object.
  2. Set the Bend Axis to Z, the Symmetry Axis to X and the Angle to 360.
  3. Press Apply bending.
  4. Repeat the process for tshirt_patch2.
  5. You will end up with something similar to the picture below:

Sew the sleeves

  1. In the main menu, press Deform Dynamics > Sewing
  2. If the sphere is too large, reduce the Sphere size in the Sewing editor.
  3. Define the following seams:
  4. Do the same for the other sleeve.

Running the simulation

  1. Press play.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > ClothedCharacterSleeves.

Using skinning

Skinning can be used to skin parts of a DeformBody to a DeformColliderMesh. This way, animation can be created partially by skinning and simulation. In the animation below, the pants start without any skinning, and the friction of the mesh collider is very low. The strength of the skinning is then gradually increased to make the pants assume their original position, while still keeping some of the dynamic behaviour from the simulation.

Enabling skinning

  1. Add a DeformSkinning component to a GameObject that already has a DeformBody.
  2. Set the Mesh Collider parameter of the DeformSkinning component to an existing DeformColliderMesh component in the scene.
  3. To skin all vertices of the DeformBody, enable Full Skinning. To select a subset of vertices to skin to the DeformColliderMesh, use the Skinned vertices vertex painting tool.

Using collision masks

Collision masks allows for fine-grained control over the collision behavior of the DeformBody and DeformColliderMesh components, by using vertex painting. For example, it allows for defining parts of a DeformBody that should ignore collisions with parts of a DeformColliderMesh, or which specific parts in a group of several DeformBody components that should be able to collide with each other. Two simple rules govern the behavior of collision masks:

  1. An unpainted vertex (white) will collide with every other vertex.
  2. A painted vertex (green, blue, red or yellow) will collide with every unpainted vertex and every painted vertex of the same color.




Editing the collision mask of a DeformColliderMesh

  1. Open the vertex painting interface by pressing the Collision mask button in the DeformColliderMesh inspector.
  2. Select the red color using the buttons that show up under the Collision mask button.
  3. Paint the parts of the DeformColliderMesh that should be ignored.



Editing the external collision mask of a DeformBody

  1. Open the vertex painting interface by pressing the External collision mask button in the DeformColliderMesh inspector. To instead govern how the DeformBody will collide against itself and other DeformBody components, use the Self collision mask button.
  2. Select the green color using the buttons that show up under the External collision mask button.
  3. Paint the parts of the DeformBody that should ignore the painted part of the DeformColliderMesh.



Running the simulation

  1. Press play.

An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Tutorials > CollisionMask.

Using proxy meshes

This tutorial describes how to use the Deform Body Proxy functionality, to create many objects mimicking a source object.




Adding a Deform Manager

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Manager and create the Deform Manager.
  3. The manager is initialized with a set of default parameters which you can use. If you want to change the parameters, you can do it in the Deform Manager game object.

Adding a cloth patch

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Patch Creator to create a new patch object.
  3. Create the mesh of the GameObject by specifying the Size (4, 4) and the Resolution (81) of the patch, and click the Create patch button.
  4. Choose a material that the patch should use. In the Mesh Renderer component, expand the Materials and click on the dot next to the material parameter, locate the material Cloth blue in the assets and apply it.

Fixing two vertices

  1. In the Deform Body component of the GameObject, press Fixed vertices.
  2. In the scene view, you will notice a set of white particles corresponding with the vertices of the patch. Paint the corners of the cloth by moving the mouse cursor on top of the particles and left-click.

Adding a proxy mesh

  1. Right-click in the Hierarchy window.
  2. Navigate to Deform Dynamics > Deform Body Proxy to create a new proxy object.
  3. You now need to manually add a Mesh Renderer component and a Mesh filter component to the new proxy object that you just created. If the Deform Body that you intend to use the proxy on, uses a Skinned Mesh Renderer instead of a Mesh Renderer, you need to add that to the proxy object instead.
  4. Specify the Deform Body created in the previous step as the Source object, by either drag and drop from the Hierarchy window, or by pressing the dot next to it.
  5. Place the proxy object at a position different than the source object.
  6. You can then duplicate as many proxy objects as you want, and place them around the scene, without any significant performance loss.

Enabling interaction with the cloth

  1. In the object containing the Deform Body component, press Add Component, and search for Deform Picking. Add the Deform Picking component to the body.
  2. This means that you can use the mouse to pick and drag the cloth in play mode. You can only interact with the object containing the Deform Body component, not the proxies.

Running the simulation

  1. Press play in Unity.


An example scene using this functionality can be found inside the Unity project under Deform Dynamics > Scenes > Demos > FlagProxies.

Using garments made in Marvelous Designer/CLO

This tutorial describes some best practices for preparing garments created in Marvelous Designer (MD) or CLO for simulation with the Deform Dynamics plugin for Unity. This includes details on how to create an optimal mesh topology, which file formats to use and how to export and import seams. Note that this is an experimental feature which may change significantly in the near future.




Mesh topology

In general, to achieve the best possible performance, triangles should be similar in size. To achieve this in MD/CLO, make sure that all patterns have the same Particle Distance value:

File formats and seams

MD/CLO supports exporting garments in a number of file formats. However, at the time of writing the only option that also makes it possible to export the seams is OBJ. If the garment that is being exported is already draped around a character in MD/CLO, the seams don't need to be exported. Instead, the "Weld" option can be used to connect vertices that are joined by a seam. In this case, the file format also doesn't matter as much, and any 3D format can be used as Unity supports it.

However, if the garment is to be exported as patches before draping on a character body (which is recommended in order to get the most accurate rest values for the simulation), the seams must also be exported and the "Unweld" option should be used. The "Single Object" preset should be used in order for the seams to refer to the correct vertex indices. Finally, the seams are exported by checking the "Save with Meta Data (XML)" option.

Importing seams into Unity

When exporting the seams from MD/CLO according to the instructions above, a separate meta data file in XML format will be created. This file can be imported by placing the Deform Seam Importer component on a game object with a Deform Body based on the corresponding mesh that was exported from MD/CLO.



The default OBJ importer in Unity sometimes changes the number of vertices when optimizing the mesh or computing normals. This will cause corrupt indices that break the seams. A future version of the Deform Seam Importer will let you import the OBJ in a way that solves this issue.