Obi Official Forum
Tearing cloth via code (Finding constraintIndex) - 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: Tearing cloth via code (Finding constraintIndex) (/thread-643.html)



Tearing cloth via code (Finding constraintIndex) - Cadpeople - 08-08-2018

Hey so I'm trying to tear a ribbon in half at a specific point. I've been doing as described on this page http://obi.virtualmethodstudio.com/tutorials/scriptingconstraints.html but I'm haivng a hard time figuring out where to tear. How do I figure out what the constraintindex of a specific point is? So far I've managed to guess my way to two out of three tear spots, but I've been guessing for a while now with no luck figuring out the last one...

Code:
public void CutAtPoints()
   {
       cloth.DistanceConstraints.RemoveFromSolver(null);
       cloth.BendingConstraints.RemoveFromSolver(null);
       for (int i = 0; i < constraintsToCut.Count; i++)
       {
           cloth.Tear(constraintsToCut[i]);
       }
       cloth.BendingConstraints.AddToSolver(cloth);
       cloth.DistanceConstraints.AddToSolver(cloth);
       cloth.BendingConstraints.SetActiveConstraints();
       cloth.UpdateDeformableTriangles();
       cloth.Solver.UpdateActiveParticles();
   }



RE: Tearing cloth via code (Finding constraintIndex) - Cadpeople - 08-08-2018

Alright I've guessed the last id. It's 110. I'd still like to know if there's a better way to figure it out, than guessing Sonrisa