:

Cloth in UT3

 

 

Introduction

 

In UE3 cloth is defined within a skeletal mesh. This is done by weighting vertices to a ‘cloth bone’. When the skeletal mesh is loaded into UE3 the vertices associated with this bone are physically simulated. Any vertices which are not weighted to this bone are skinned in the traditional way.

 

 

As an additional option vertices can be attached to the skinned skeletal mesh in other ways. One way is to attach the vertex so that it is tearable, this means that if the cloth is stretched beyond a factor of it original length then the attachment will snap and the vertices will become free.

 

 

One issue has to be taken into account however, to have vertices which can break; they need to be attached to collision geometry, even if the geometry does not collide with anything else. For this reason we have two ways to do cloth attachment: 1.Create a physics asset (with the tool PhAT) associated with skeletal mesh. 2. Attach cloth to colliding shape by selecting a flag.

 

 

 

 

 

Examples:

 

TBCompleted

 

 

3DS Max Creation

 

The first step is to create the asset in maya/max and setup the skinning.

 

 

What I have done is create a triangle sheet in maya. Plus 3 bone joints:

 

·        ClothJoint – This is the bone we use to specify vertices which are normal free cloth.

·        RigidJoint – This is the bone we use to attach cloth breakable attachments to.

·        RootJoint – Just to keep things organized really.

 

The next step is to create a smooth skin between the mesh and the skeleton. Following that I paint the skin weights so that most of the mesh is fully influenced by the cloth joint, but with the two corners (in black) influenced to the “RigidJoint”.

 

This skinning process can be accessed in the video!

 

I then export this mesh using ActorX as a skeletal mesh.

 

 

Import the mesh into UE3 and set the cloth properties

 

 

Next we import the skeletal mesh into UE3 Editor as normal. This gives a skeletal mesh asset. Open this in the AnimSetViewer.

 

On the mesh tab we can setup the properties for the cloth. One thing which helps is to turn on display of bone names.

 

 

Now we specify the part of the mesh which is cloth, by adding the “ClothBone” to the list of cloth bones.

 

Then add the breakable part to the ClothSpecialBones… BoneName is the name of the bone (the one we skinned the corners to) and for BoneType we select CLOTHBONE_BreakableAttachment.

 

Finally the other cloth parameters can be tweaked. In this case we probably want to make sure ClothAttachmentTearFactor is set appropriately. A cloth attachment tear factor of 1.5 will cause the attachment to break when it is extended 150% of its original length.

 

Link here for some cloth parameters and what they mean!

 

We must select bForceCPUSkinning as UE3 does not currently support GPU skinned cloth. Also select bEnableClothLineChecks, or the cloth can not be shot.

 

 

Create Physics Asset

 

 

We need to make a very simple physics asset to associate with the skeletal mesh, to which the attachments are welded. (It can also be useful for blocking movement through the gap in the level where the cloth is by adjusting the collision filtering settings).

 

 

 

To create the collision asset, right click the skeletal mesh and select “Create New Physics Asset”. Choose a sensible name.

 

Now PhAT asks us how to auto create the asset. The default options are normally OK, since we will be editing it anyway. However at present there is a bug in PhAT related to cases where no asset is initially auto created. So to work around this it is best to set “Minimum Bone Size” to -1.

 

Now PhAT displays our mesh with some collision boxes created for each bone. We only really want one for this model for the RigidJoint (which our cloth is attached to) so delete the others.

 

Next scale the box so it fits around the cloth (size/position isn’t really important as we are just using it to attach to).

 

We can set the collision flags here, for example if we don’t want players/weapons to collide, uncheck bBlockZeroExtent and bBlockNonZeroExtent. Also bFixed can be checked so the box doesn’t start falling when we run the level.

 

 

Create AtClothActorPlaceable

 

 

The attached cloth can now be put in the level, please do the following steps:

1. Find and select the AtClothActorPlaceable class in the Generic Browser -> Actor Classes.

2. Right click on the map and click “Add AtClothActorPlaceable Here”.

 

3. Press F4 to open the AtClothActorPlaceable Properties page. Find the model we want to use in the Generic Browser, set the skeletal mesh as the SkeletalMesh property, and set related physics asset as the PhyscisAsset property of the AtClothActorPlaceable actor.

 

 

4. Save and run map, now the AtClothActorPlaceable actor should work as a piece of cloth with two corners attached. Here the cloth corners are attached to the box we created in physics asset. And this attachment is breakable because we set the bone RigidJoint’s BoneType as CLOTHBONE_BreakableAttachment in Step 2.

5. If we want the cloth to attach to other colliding actors in the map, we can select the “bAttachToCollidingShapes” flag of AtClothActorPlaceable actor. Also, we can make a breakable attachment by selecting “bAttachmentTearable”, and we can make a two way interaction attachment by selecting “bAttachmentTwoWay”.

6. If we select “bWakeUpWhenLevelStart”, the cloth will be woken up automatically after level starts. Or it will keep asleep until it is touched by other actors or shot.

7. By default, the cloth can collide with the level geometry and most actors, but the player can walk through the cloth with out any collision. If we want the cloth to block player, we can refer to Collision -> CollisionType and change it to COLLIDE_BlockAll.

 

If we do not want to use AtClothActorPlaceable class, we can just select the skeletal mesh in the generic browser and right click in the map to create a skeletal mesh actor. Then we should enable cloth simulation by setting bEnableClothSimulation on the mesh. Plus associate the physics asset we created by setting bHasPhysicsAssetInstance and the PhysicsAsset properties. Also we have to set all other useful parameters manually. For which parameters are useful for metal cloth, please refer to the script and help document of the AtClothActorPlaceable class.

 

Tips:

 

There are a number of console commands which can be used in the game or “play in editor” window to see what PhysX is using.

 

nxvis cloth_mesh – This displays the mesh which PhysX is simulating in wireframe.

 

nxvis cloth_attachment – This displays the points which are attached to collision geometry (in Physics Asset) or the world. (ie the points we skinned to the RigidJoint above).

 

nxvis collision – Shows collision geometry. Including the box we attach the cloth to in the skeletal mesh. (note: there is a bug in UE3/nvidia video drivers which means this may not work for large levels)

 

 

 

 

Create Metal Fence by AtClothActorPlaceable

 

Introduction

 

In this document, we will show how to create metal fence by AtClothActorPlaceable. Here we will focus on how to create the cloth model from the original static mesh. We will take a UT3’s metal fence for example to show the detail steps. For the cloth creation, please refer to Creation_AtClothActorPlaceable.doc for more details.

 

                 

 

Create metal fence by Cloth

 

1. Find the metal fence model in UT3’s asset package. Here we take HU_Deco. Mesh. S_HU_SM_Chainlink02_B for example. This model is a static mesh.

 

 

2. Import this model to a map. Here we can use any map we like.

3. Press F4 to edit the static mesh actor, set its location to (0, 0, 0).

 

4. Select the static mesh actor and export the model to a file: MetalFence.obj.

5. Open the MetalFence.obj file with 3D-Max.

 

6. Replace the middle plane with more detailed model. A 10×10 polygon mesh, e.g.

7. Add three bones: Root, Cloth and Rigid. Root should be the parent bone, Cloth and Rigid bone are child bones. Rigid bone stays at the same position with Root bone.

 

8. Move Root bone to the (0, 0, 0) of the world axis. Then make skin and assign vertex.

9. There are four iron pipes on the edge of the metal fence, assign all vertices on these pipes to the Root bone.

10. Then we assign vertices on the middle 10×10 polygon mesh. Vertices on the yellow area should be assigned to Root bone; vertices on the red area should be assigned to Rigid bone; all other vertices on the blue area should be assigned to Cloth bone.

11. Export the model to a file MetalFence.psk with ActorX.

12. Import MetalFence.psk to UE3 editor as a skeletal mesh. Double click the skeletal mesh actor to edit its properties. We also need to select bForceCPUSkinning which is not shown on the picture.

13. Right click the skeletal mesh actor and choose to Create New Physics Asset. Please set the “Minimum Bone Size” to -1 to init it successfully.

14. Delete the collision shape which is associated to Cloth bone.

15. Enlarge the collision shapes which are associated with Root and Rigid bone. Make sure they can cover the whole cloth model.

16. Find and select the AtClothActorPlaceable class in the Generic Browser -> Actor Classes. Right click on the map and click “Add AtClothActorPlaceable Here”.

17. Press F4 to open the AtClothActorPlaceable Properties page. Set the skeletal mesh we just created as the SkeletalMesh property, and set related physics asset as the PhyscisAsset property of the AtClothActorPlaceable actor.

18. Save and run map, now the AtClothActorPlaceable actor should work as a piece of cloth. Shoot the metal fence with a weapon which has force field. The metal fence can be blown dynamically, and the top part of metal fence can be detached from the iron pipes.

 

 

Metal Cloth

 

AtMetalClothActorPlaceable Creation

 

Introduction

 

Metal cloth is a cloth mode which allows cloth to be used to simulate plastic deformation. For example dents in barrels, car bodywork or metal doors can be displayed when there is a large impact on the surface.

 

In UE3 metal cloth is created in a very similar way to normal cloth, first a cloth mesh is created and imported to UE3 as a skeletal mesh with the bClothMetal flag set. Then to enable the feature a rigid body should be attached to the cloth in Physics Asset.

 

The cloth acts as a deformable surface for the rigid body. The cloth automatically becomes rigid when the body is attached. The rigid body is used for simulation until an object hits it with enough impulse to cause deformation, at this point the cloth deforms.

 

                 

 

Tutorial – Step 1 – Create the mesh in a 3D tool

 

Create 2 bones. Align both bones such that their local transforms are aligned with the world axis. Make the rigid_bone the parent of the cloth_bone.

 

 

 

Note: we’d better place the rigid_bone at (0, 0, 0) of the world axis. Or there may be displacement problem when we use the metal cloth in map.

 

Select the object to be made into cloth. It should be a single object, not a composite of multiple Max objects and not a group. We should be able to select all parts of it with a single mouse-click.

 

Apply a Skin modifier to it and add both the rigid_bone and cloth_bone. Assign all vertices in the object to the cloth_bone, with weighting of 1.0. Make sure no vertices are assigned to the rigid_bone.

 

Then we can use ActorX (from Epic) to export the mesh as a skeletalmesh.

 

 

 

Tutorial – Step 2 – Import the mesh into UE3 and set the metal cloth properties

 

Next we import the skeletal mesh into UE3 Editor as normal. This gives a skeletal mesh asset in the Generic Browser. Open this in the AnimSetViewer. On the mesh tab we can setup the properties for the metal cloth.

 

 

Now we specify the part of the mesh which is cloth, by adding the “Cloth” bone to the list of cloth bones. There is no need to add ClothSpecialBones as no vertex is assigned to the “Rigid” bone.

 

Set ClothIterations to 1, or to some other small integer value as the cloth simulation won’t need that much precision. Collision handling is not done by the cloth but by the assigned rigid body.

 

Enable bMetalCloth as this will be the crucial part for metal cloth simulation. ClothMetal-ImpulseThreshold will specify how strong an impact needs to be to start metal deformation. ClothMetalPenetrationDepth gets added to the colliding actor, even pushing metal cloth further in. ClothMetalMaxDeformationDistance is used to make limits to the deformation. Otherwise meshes can get too much distorted.

 

We must select bForceCPUSkinning as UE3 does not currently support GPU skinned cloth. Also select bEnableClothLineChecks, or the cloth can not be shot. We can adjust other properties of the cloth, but for metal simulation, they have no effect. The only property that might be useful during metal cloth simulation is ClothThickness.

 

 

 

Tutorial – Step 3 – Create Physics Asset

 

 

Right-click on the SkeletalMesh and select Create PhysicsAsset. The default options are normally OK, since we will be editing it anyway. However at present there is a bug in PhAT related to cases where no asset is initially auto created. So to work around this it is best to set “Minimum Bone Size” to -1. Make sure to select the “Create Joints” option.

 

When PhAT opens, the model will likely have one collision shape associated with each bone.  Please delete the shape associated with the Rigid bone and make sure no shape is assigned to it. Or the metal cloth can not be created because of two bodies.

 

Add more collision shapes depending on how big the cloth is. Make sure to only add boxes and spheres as metal cloth can’t handle anything else. If we use box, we can add only one for the cloth bone. But for sphere, we can use more than one.

 

In the end we should have something like this:

 

 

Note that we don’t have to align the spheres very well, this will all be done by the metal cloth upon initialization, undoing any fine tuning we’ve already done.

 

Then we need to set the properties of the collision shape. Set the following properties for the Cloth bone:

 

          bFixed:                         false

          bNoCollision:                           false

          bBlockZeroExtent:                    true

          bBlockNonZeroExtent: true

 

When running the simulation and entering “nxvis collision” to the command line, we can see how many spheres the cloth actually uses. We should add more spheres until the metal cloth actually can’t use all of them anymore (it will put all the remaining shapes to the same position as the first shape). Then take away all unused ones to optimize metal cloth.

 

 

 

Tutorial – Step 4 – Create AtMetalClothActorPlaceable

 

 

The attached cloth can now be put in the level, please do the following steps:

1. Find and select the AtMetalClothActorPlaceable class in the Generic Browser -> Actor Classes.

2. Right click on the map and click “Add AtMetalClothActorPlaceable Here”.

 

 

 

 

3. Press F4 to open the AtMetalClothActorPlaceable Properties page. Find the model we want to use in the Generic Browser, set the skeletal mesh as the SkeletalMesh property, and set related physics asset as the PhyscisAsset property of the AtMetalClothActorPlaceable actor.

4. Save and run map, now the AtMetalClothActorPlaceable actor should work as a metal cloth actor. The following picture shows some deformed metal cloth mines after falling from sky and colliding with each other.

 

 

5. By default, the metal cloth can collide with the level geometry and most actors, but the player can walk through it with out any collision. If we want the metal cloth to block player, we can refer to Collision -> CollisionType and change it to COLLIDE_BlockAll.

 

If we do not want to use AtMetalClothActorPlaceable class, we can just select the skeletal mesh in the generic browser and right click in the map to create a skeletal mesh actor. Then we should enable cloth simulation by setting bEnableClothSimulation on the mesh. Plus associate the physics asset we created by setting bHasPhysicsAssetInstance and the PhysicsAsset properties. Also we have to set all other useful parameters manually. For which parameters are useful for metal cloth, please refer to the script and help document of the AtMetalClothActorPlaceable class.

 

 

  Pressure Cloth Creation

 

 

First, to dispel a slight misnomer, the implementation you see in UT3 is not the same as our SDK soft bodies; these are simply pieces of cloth that hold an internal pressure. So as you can imagine, the process for creating a piece of pressure cloth isn’t to complex (for you, let me tell you, the calculations are fun!)

First you’ll need to create an object that would hold a pressure (this is NOT a requirement, but simply will make your simulation make sense; you can add pressure to a flat piece of cloth if you desired!)

 

Wire frame view in the animset viewer of TheBlob in the package At_AdvCloth

From here you will setup your cloth as always, however with one slight difference, the pressure check boxes!

 

You must first check the “bEnableClothPressure” followed by setting your cloth pressure value! The higher the value the more the pressure.

 

Pressures: 0.5, 1, and 5 respectively

Take note that performance is particularly taxing with a large amount of vertices (such as you see here, there are 9000 triangles going through this simulation!)