Obi Official Forum

Full Version: Manually tear the cloth
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
(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.
(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/tutor...sions.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: