Frayed Wallpaper Peeling Using nCloth, help


#1

Hi guys, im trying to recreate an effect using ncloth, but im kinda stuggling with it.
Heres the link: http://www.youtube.com/watch?v=_ELnEjFR81M
I’ve tried it two ways so far; using cut face tool to pre shatter the plane and have tried with animated maps to hold verts in place before the field arrives, but have had more success using Soup attribute transfer for glue strength per vertex. However i dont get the frayed edges this way.

The second way is using tearable surface constraint, however im applying it to the whole plane and it seems like there is a lot less control than pre shattering. And im struggling to immitate the fraying in the video, not sure what kind topology i should be using on the plane.
I can post results of either of these methods if it helps to see.
Thanks

Does anyone have any thoughts on how to achieve this effect?


#2

I suppose it depends on exactly what you are after, but a simple technique would be to have no forces or gravity acting on a pre-shattered cloth then animate the position of a volume axis field so it encompasses the object. So for example it might be an upward force inside the volume axis field and you just move it so it intersects the parts you want to peel off.

The shattering could be done by selecting all the edges you wish to tear along then doing doing detach component before making the mesh cloth.

If you wanted to make it like something sticking to a surface that is peeling off then you could perhaps additionally collide with the original non-shattered mesh, making it a passive collider and on the nRigid node set the forceField to create a slight clinging force near the surface (keep fieldDistance small).

Another approach is to lock the cloth using inputAttract and then animate the inputAttract per vertex. This is a little tricky to do, but the following works:

  1. Create a volumeAxis field affecting the cloth

  2. Set inputAttract to 1.5 and set inputAttractMapType to Per-Vertex

  3. Create a custom array attribute on the cloth (lets call it inputA):

addAttr -ln “inputA” -dt doubleArray nClothShape1;
setAttr -e-keyable true nClothShape1.inputA;

  1. Set up a particle creation and runtime expression for the nCloth

dynExpression -s “inputA = 1;” -c nClothShape1;
dynExpression -s “if( inputForce[0] != 0 ){
inputA = 0;
}” -rbd nClothShape1;

One can use particle expressions in a limited fashion with nCloth, because it is derived from the particle class. These expressions set inputA to 1 at the start frame and zero when the field strength is not zero.

  1. With a regular non-particle expression copy the array inputA to the inputAttractPerVertex array. We do this by connecting and disconnecting the attributes. We can’t simply leave it connected or directly set the per vertex array inside the particle expression, as this leads to a dependency graph loop that blocks evaluation of the cloth.

expression -s “connectAttr nClothShape1.inputA nClothShape1.inputAttractPerVertex;
disconnectAttr nClothShape1.inputA nClothShape1.inputAttractPerVertex;” -o pSphere1 -ae 1 -uc all ;

Once this is done the cloth will be locked to the input mesh position(even if it animates) until the volume axis field overlaps it, after which it is free to move with forces.
I’ve attached a simple scene showing this technique.

If you want to have smooth normals you could do a merge vertex followed by smooth normals on the output cloth mesh. (that’s basically what the tearable constraint does)


#3

Hi Duncan thanks for the response, Iv’e attempted to re-create your setup, but im having some trouble, i ran the lines you sent and everything connects giving me the two expressions
After running 4:

if( nClothShape1.inputForce[0] != 0 ){ 	nClothShape1.inputA = 0;

 }

And after running 5(I Changed the pSphere1 to to pPlane1):

connectAttr nClothShape1.inputA nClothShape1.inputAttractPerVertex;

 disconnectAtt r nClothShape1.inputA nClothShape1.inputAttractPerVertex;


However when simulating i get an execution error: ‘nClothShape1.inputA’ is already connected to ‘nClothShape1.inputAttractPerVertex’.

I tried deleting the expressions on the scene you sent and re-running the code but i still get the execution error. I understand what the expressions are doing, but not why im getting this error, am i missing something?


#4

Ha! there was an r offest from the ‘disconnectAtt r’ - syntax always the case!
So whats the best way of giving the ncloth that very ragged frayed look? I cant use terable surface constraint can i? - because all the pieces are shattered to begin with?


#5

To make it more frayed: instead of detaching all vertices like my example you should select just the edges where you want it to tear and detach them. If necessary create more edges (subdivide faces along tear boundary ) if you need a finer tear.


#6

I think thats what im currently doing, im using cut face to define where i want shatters to occur then selecting all edges and detaching, then smoothing to allow the mesh to curl and bend. But the edges that i have cut and detatched are just straight edges, how do i specify those edges for tearing when they are already detatched?


#7

nCloth uses the mesh topology for building its links and connections. Anywhere the mesh is detached along an edge is automatically split if you then make it nCloth… you must either do the detach before making it nCloth, or you must do it on the nCloth input( not output ) mesh.


#8

Dagnabit! Why didnt you post this years ago?! :stuck_out_tongue:

Cheers for it now :smiley:


#9

Hell Yeah… :slight_smile: so right…its a bit like SouP.ing with bounding
object and getting initial Spin and dynamics on the shards…

How would that work when not using input attract but glue strength on
an nComponent Tearable Constraint ? or both of them input attract to bound
to the moving object and tearable glue strength to get nice fractured shards ?

the same procedure but connected to the nComponent gluestrength VertaxMap
Input ?


#10

In that case i would have to create the tearable surface constraint on the input mesh after it has been made in to nCloth? and just forget about using the detatch tool before its nCloth because as you say those edges where it has been detatched are treated as a pre-split surface? is this right?
Would it be a better idea to create tearable surface around the cut edges, and then increase divisions, otherwise specifiying where tearing should occur would be kind of tricky due to all the divisions


#11

Ungh, Duncan, please removed Terrible Constraint from the arsenal, as we all know its pointless… :wink:

Never use it guys, its crap. Better workflow is to manually cut up your mesh or shatter it. Then make it cloth and use Weld Adjacent Borders… read up here, there are plenty of posts on the forum about it and how to do this.

Example - http://vimeo.com/16375110

As for specifying tearing, you can use ramps or textures on Input Mesh or Constraints, along with the method Duncan has shown you here to control what rips and where…


#12

Having a try with weld adjacent instead. Currently im diving an edge just down the middle, where i want to tear, then im using the brush tool to highlight verts down the subdivided section, and detatching component(not sure if this is a good way of doing this or not). Then turning in to cloth and using weld constraint, and as soon as the simulation starts i get this:Untitled-1.jpg which only seems to happen when i increase the number of divisions.
Not sure why im finding this so tough :hmm:
Awesome example btw Howard :slight_smile:


#13

If you created the constraint based on selected components then changing the resolution of the underlying mesh will result in different components being connected together. With a weld constraint this will snap those components together, which would explain the problem you are seeing. Just display the input nCloth mesh and reselect the elements you want to be constrained after changing the resolution then do nConstraint: replace members to fix the problem. Or perhaps you could instead constrain based on max distance and set the nComponent to be all border vertices( or edges, if the verts do not align)… in this way you could change the mesh resolution and the constraint would still work OK.


#14

One can manually cut up the mesh using the tearable constraint by first selecting all edges you wish it to tear on( instead of the full mesh ). It will only shatter the cloth mesh along those edges.

Duncan


#15

I just realized that your problem must the be max distance on the constraint… just lower the value. When you increase the resolution the length of edges may go below the max distance value, which causes neighbor edges to get attached (which causes it to clump when it is a weld constraint).

The max distance is set on the high side by default so that border don’t need to exactly touch to be welded.


#16

Is there a difference in the end result if you use a tearable constraint vs. the weld adjacent borders? I’ve definitely ran into problems with the tearable constraint ( my most recent troubles http://forums.cgsociety.org/showthread.php?f=86&t=1098885 ) and am wondering if I should just try switching my methodology. Great thread btw, thanks for all the info.


#17

Im still having no luck with weld, reducing max distance reduces the constraint to not enough points to tear anything, and when there is enough it just distorts, its probably because im still painting verts which can’t be a good method. Still trying to figure out this workflow.
pfunk, that test looked amazing, the colorAtPoint script sounds very interesting. I read you used a fractal to define where the tears occured, to do this would you have to make the entire mesh part of the constraint and use the fractal as a glue strength map. Is this the correct workflow?
Because i want my mesh to tear in so many places to select each vert on something so high res would take ages.


#18

Originally I used a fractal in the nComponent for the tearable constraint, but since that requires the whole mesh to be a part of the constraint, I changed to my approach of creating a quick select set of the verts above a defined white value in a texture and adjusting the glue strength on the constraint. Here’s what I was doing >>

string $obj = “pSphere1”; // obj to be ripped
string $tex = “file1”; // file texture where you want rips
string $cpm = “CPM_tear”; // need to create a closestPointOnMesh or
// nearestPointOnMesh and connect mesh to it

int $numVerts[] = polyEvaluate -v $obj;

float $threshold = .7; // define white value threshold
string $tearVtx[];
clear $tearVtx;

for ($v = 0; $v < $numVerts[0]; $v++) {
string $vtx = ($obj + “.vtx[” + $v + “]”);
float $pos[] = pointPosition -w $vtx;
setAttr ($cpm + “.inPositionX”) $pos[0];
setAttr ($cpm + “.inPositionY”) $pos[1];
setAttr ($cpm + “.inPositionZ”) $pos[2];

    float $u = `getAttr ($cpm + ".parameterU")`;
    float $v = `getAttr ($cpm + ".parameterV")`;    

    float $color[] = `colorAtPoint -o RGB -u $u -v $v $tex`;
    if ($color[0] &lt; $threshold) {
        $tearVtx[(`size $tearVtx`)] = $vtx;
    }    

}

print ("NUM VTX = " + $numVerts[0] + "
");
print ("TEARABLE VTX = " + (size $tearVtx) + "
");

sets -name “tearableVtx” -text “tearableVtx” $tearVtx;

Hope it helps!


#19

Wow pfunk, what a handy piece of code. Been trying to get it to work, having some problems though. Just to check i’ve got this right; im running: createNode closestPointOnMesh -n CPM_tear;
Then in the connection editor im hooking up nCloth outMesh to closestPointOnMesh input mesh. I then get this error(and whenever selecting plane): menuItem: Object ‘goToConnectedMenuItem’ not found.
Not sure if this is the reason?
Then upon running the code everything executes fine but the vert selection is kind of messed up like the closestPointOnMesh node isn’t running correctly, sometimes it selects all or none of the verts despite there being a ramp etc then sometimes i get things similar to this: Untitled-1.jpg
Any ideas, am i missing something? Nearly got it all working, getting this working would be a massive help though, especially to sim times. Thanks


#20

Close, just connect the nCloth outMesh.worldMesh to closestPointOnMesh.inMesh. If there are still problems you can always just try switching to the nearestPointOnMesh node instead and see if that makes a difference. Hope it works!