Introduction to ClothFX
From LightWiki
This is an introduction to using LW's ClothFX. First let's start off with building a basic test Mesh. I have a whole directory devoted to testing, including a ball which has an example of all the different Vertex Map types in it and some Skelegons, so I can try out a new effect really quickly. So open Modeler and draw out a Box (shift-x) on the first layer of a new object. Make it 1m x 1m x 1m centred around the origin. Open the Layers Panel (More Windows>Layers Panel) and double click the first Layer. Rename the layer to Box.
In the next Layer, draw out a Ball (shift-o) 1m x 1m x 1m around the origin. Rename that layer to Ball. Press 'q' and rename the Surface to ball. This just make it easier to colour it to see what's going on. In the next layer draw out a box again, but make it 4m x 0m x 4m, that is to say a plane, and ensure it has 20 segments in the x and z directions using the Numeric Panel (press n). This should give us enough resolution to get decent collision and shapes. Rename its layer to cloth, and give it a new surface cloth. Change it to a Subpatch object by pressing Tab.
Save your object (press 's') as Box_Ball_Cloth and send it to Layout using the little button at the top right of Modeler.
Once Layout is open, select your cloth object move it up above the other objects(press 't' for the Transform tool and drag on the green arrow), and your box object below your ball object. Press 'p' to open the Object Properties Panel. In geometry tab, set Subdivision Order to Last, otherwise ClothFX will use the subdivided geometry to do the simulation on, and that will be much slower than the pre-subdivided geometry. Go to the Dynamics tab and Click Add Dynamic>Cloth. Click ClothFX and you'll see the ClothFX panel.
Go to the Etc panel and change Gravity Y to -9. -9.8 m/s^2 is the value of earth's gravity, but -9 is quicker to type :) There is also a preset selector which gives you some rough settings, but we won't use that yet.
Click (Calculate in the top right of the properties panel) and you'll see the Cloth object fall down through the other objects. (if the layout view goes blank, just wait a little and it should reappear once the calculation is done. If that happens, use the Start button on the Dynamics>FX browser to start the calc, as this will give you a progress bar to show you it's still working)
This is because we haven't set collision yet. Click on the Collision tab and set Collision Detect to <all>. You'll notice that you can also select 'cloth/surface'. This is if you have more than one surface, or some VMaps applied, you can use this to limit collision to just this part of the object to make the simulation calculate more quickly.
Now we need an object to collide with. Select your Ball and in the Dynamics tab, select Add dynamic>Collision. If you click on the FX Collision, you'll see by adding it to a mesh, it will automatically set the Type to Object. Click Calculate again.
You'll see the cloth fall through the objects again, but this time it'll bulge as it hits the ball. First, reduce the Bounce/Bind power in the collision object to 120%. Then the cloth won't bounce so much. Set Friction Power to 10 as this will stop the cloth sliding too quickly once we've adjusted the clothFX settings. Set Fix power to 10, as this will stop the cloth sliding completely. In real life, things stick for a bit before moving when you push them. Lightwave Fx emulate that with Fix being the sticking, and Friction determining how quckly you can accelerate the object once it starts moving. High friction and no Fix means the cloth will slide off slowly, while no Friction and high Fix means the cloth will stay on the ball. A mixture of the two is more like real life.
Select your cloth object and open the clothFX panel. In the Basic tab, set Spring to 1000, and Sub structure to 1000. Spring controls how hard each point pulls on on the points connected to it by poly edges, while Sub Structure builds links with other points in the same polygon, meaning the poly is less likely to distort and more likely to try to remain it's original shape. Both will help stop the over stretching.
Go to the ClothFX>Collision tab again, and set the Collision offset to 10cm. This controls how close a cloth point can get to a collision polygon. It will vary dependent on your scene size, and density of your collision mesh. More dense meshes can use lower values successfully, but will be slower to calculate. Using this we can avoid interpenetration without having to use more complex collision meshes. Too high values will make your collision object look blobby when covered by the cloth object, so use the minimum value to stop interpenetration.
Press calculate again, and you'll see the cloth land on the ball and swing underneath it, still stretching somewhat. Open the clothfx panel and go to the Advance tab. Set Stretch Limit to 1%. This sets an absolute value to how far each point can stretch from its neighbours and gives better results than using Spring or Sub Structure alone.
Also, set Compress Stress to 1000%. this will make the cloth stiffer and less likely to bend. In the collision tab, set Self Collision to <all> as this will stop the cloth penetrating itself, and Friction and Fix to 100% to stop the cloth sliding. Hit calculate. You should see your cloth looking quite a lot like cloth, with nice pleating effects as it settles on your ball. If the preview runs out of time, set the preview range to 200 down at the bottom right corner of the Layout window.












