Obi Official Forum
Help Manually tear the cloth - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Manually tear the cloth (/thread-2278.html)



Manually tear the cloth - bluedrag0n - 31-05-2020

Hi, 

I need to manually tear the cloth based on the particle I selected. I have the particleindex of the selected particle and need to tear that particle from the particle above it, or remove the distance constraint. Is there a way to do it without using physics/force? I can get the cloth's distance constraints and traverse through the batches but I can't figure out how to find the correct constraint.

Thanks


RE: Manually tear the cloth - Andrew Graham - 09-06-2020

(31-05-2020, 03:27 PM)bluedrag0n Wrote: Hi, 

I need to manually tear the cloth based on the particle I selected. I have the particleindex of the selected particle and need to tear that particle from the particle above it, or remove the distance constraint. Is there a way to do it without using physics/force? I can get the cloth's distance constraints and traverse through the batches but I can't figure out how to find the correct constraint.

Thanks

I would also be interested in this. I am trying to implement a knife that will instantly cut the cloth whenever it comes into contact with it. It there a way to do this with Obi Cloth?

Thanks.


RE: Manually tear the cloth - josemendez - 09-06-2020

(09-06-2020, 09:31 AM)Andrew Graham Wrote: I would also be interested in this. I am trying to implement a knife that will instantly cut the cloth whenever it comes into contact with it. It there a way to do this with Obi Cloth?

Thanks.

Hi Andrew,

Sure, there's three steps involved:
  • Detect contacts between the knife and the cloth particles. See:
    http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html
  • Get the contact particle index, and find out which constraint (s) involve that particle by iterating over all constraint batches.
  • Call cloth.Tear() passing a StructuralConstraint struct, that references the constraint and its batch.

You can see an example of the last two steps in ObiTearableCloth's ApplyTearing method: It iterates over all constraint batches, finds the ones whose force exceeds a threshold (you would find the ones in contact with the knife instead), then calls Tear() for them.

Here's an example of this made by a fellow user, found it in reddit recently: