Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manual tearing via cript
#11
(19-10-2017, 11:43 AM)josemendez Wrote: Hi,

Are you using tether constraints?
Yes,
I'm using Tether Scale = 1.05 , Stiffness = 1
Reply
#12
(19-10-2017, 12:13 PM)x-lab Wrote: Yes,
I'm using Tether Scale = 1.05 , Stiffness = 1

Tethers should not be used with breakable rope, since they directly link together all particles in the middle of the rope with those at the ends. So if you break the rope, particles will still try to keep a certain distance to the end they're no longer connected to. This is quite probably the cause of the weird behavior.

First try to disable them in editor and see if the behavior improves. If that's the case, you should just disable them the first time to call Tear().
Reply
#13
(19-10-2017, 01:09 PM)josemendez Wrote: Tethers should not be used with breakable rope, since they directly link together all particles in the middle of the rope with those at the ends. So if you break the rope, particles will still try to keep a certain distance to the end they're no longer connected to. This is quite probably the cause of the weird behavior.

First try to disable them in editor and see if the behavior improves. If that's the case, you should just disable them the first time to call Tear().


Hi I tried
1- to disable the Obi Tether Constrains component from the chain = Tether constrains still appeared
2- Hit button Clear Tethers (The visualization didnt show tethered constrains) = When the chain breaks the weird behavior persists
3- Unticked "Enable" in the Tether Constrain Parameters of Obi Solver = weird behavior persists

pd, i tried to remove Tethers via script.
Is it possible to attach/instantiate a Handle at the end of the Teared ropes? that way I could attach a small rigid object and give a nice behavior without deleting Tether constrains
Reply
#14
(19-10-2017, 03:34 PM)x-lab Wrote: Hi I tried
1- to disable the Obi Tether Constrains component from the chain = Tether constrains still appeared
2- Hit button Clear Tethers (The visualization didnt show tethered constrains) = When the chain breaks the weird behavior persists
3- Unticked "Enable" in the Tether Constrain Parameters of Obi Solver = weird behavior persists

pd, i tried to remove Tethers via script.
Is it possible to attach/instantiate a Handle at the end of the Teared ropes? that way I could attach a small rigid object and give a nice behavior without deleting Tether constrains

Hmm, that's weird. Have you tried enabling constraint visualization (the "visualize" checkbox in each constraint component) and see if there's any constraint still attaching both halves of the torn rope?

Unless I'm misunderstanding something, I don't see how adding rigidbody at the end of the rope would help you get rid of the weird behavior... at most you could keep the end of the rope static, but the rest of it would keep flailing.

Also try deactivating in the solver all constraints except distance constraints, then re-enable them one by one and see what's the one causing the issue.
Reply
#15
(19-10-2017, 04:13 PM)josemendez Wrote: Hmm, that's weird. Have you tried enabling constraint visualization (the "visualize" checkbox in each constraint component) and see if there's any constraint still attaching both halves of the torn rope?

Unless I'm misunderstanding something, I don't see how adding rigidbody at the end of the rope would help you get rid of the weird behavior... at most you could keep the end of the rope static, but the rest of it would keep flailing.

Also try deactivating in the solver all constraints except distance constraints, then re-enable them one by one and see what's the one causing the issue.

Hi,

Yes, I hit the visualization box. They are not visible, but the behavior of the broken ropes act as if were Tether constrains..

Adding a rigidbody at the end oh the rope gives a behavior similar to the Chain Sample scene of Obi Rope. 
I chose to detach the chain from my zombie and place a rigidBody at the end of rope.. And not dealing with Tearing at all, it looks cleaner and more realistic.

I'll add a video later, if it's of interest
Reply
#16
(20-10-2017, 11:14 AM)x-lab Wrote: Hi,

Yes, I hit the visualization box. They are not visible, but the behavior of the broken ropes act as if were Tether constrains..

Adding a rigidbody at the end oh the rope gives a behavior similar to the Chain Sample scene of Obi Rope. 
I chose to detach the chain from my zombie and place a rigidBody at the end of rope.. And not dealing with Tearing at all, it looks cleaner and more realistic.

I'll add a video later, if it's of interest

Did you try to leave distance constraints only, and see if the problem persists?

If constraints do not show up when visualized, it means they're not there (visualization grabs the active constraints only). It could be several other things: distance constraints clashing with particle collisions, bend constraints clashing with distance constraints... etc. That's why it is of interest seeing if distance constraints alone still cause the issue.
Reply
#17
(09-10-2017, 02:13 PM)josemendez Wrote: This. I couldn't have explained it better.

We should probably be checking that the range is correct inside Tear(), since tearing a constraint splits one of the particles at its ends: which one? the one with more mass, or a random one if both have the same. Torn particles (the original one and the new one added at the cut) then have their mass halved.

 In the edges of the rope of course, this can cause a cut to attempt to create an additional particle at the very beginning/end of the rope, which is illegal. We check for this whenever we use Tear() inside Obi, but it being a public function we should really perform the check inside of it. 

Thanks for pointing it out niZmo.
Hello.

I am trying to do something similar. I could get the cloth to be torn on collision via script but not at the point of collision. How do I get the the constraint index from particle index or contact point of the collision?
Code:
private void HandleClothCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
   {
       if (pressed)
       {
           foreach (Oni.Contact contact in e.contacts)
           {
               if (contact.distance < 0.01)
               {
                   Collider collider = ObiColliderBase.idToCollider[contact.other] as Collider;
                   ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];

                   if (collider.tag == "tool" && pa.actor.tag == "fat")
                   {
                       Debug.Log("called");
                       ObiTearableCloth cloth = pa.actor as ObiTearableCloth;
                       cloth.DistanceConstraints.RemoveFromSolver(null);
                       cloth.BendingConstraints.RemoveFromSolver(null);
                       cloth.Tear(contact.particle);
                       cloth.DistanceConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.SetActiveConstraints();
                       cloth.UpdateDeformableTriangles();
                       cloth.Solver.UpdateActiveParticles();
                   }
               }
           }
       }
   }

The code I have included tears the cloth but not at the point of collision. Please Help.

(31-07-2019, 06:48 AM)ctalDai Wrote: Hello.

I am trying to do something similar. I could get the cloth to be torn on collision via script but not at the point of collision. How do I get the the constraint index from particle index or contact point of the collision?
Code:
private void HandleClothCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
   {
       if (pressed)
       {
           foreach (Oni.Contact contact in e.contacts)
           {
               if (contact.distance < 0.01)
               {
                   Collider collider = ObiColliderBase.idToCollider[contact.other] as Collider;
                   ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];

                   if (collider.tag == "tool" && pa.actor.tag == "fat")
                   {
                       Debug.Log("called");
                       ObiTearableCloth cloth = pa.actor as ObiTearableCloth;
                       cloth.DistanceConstraints.RemoveFromSolver(null);
                       cloth.BendingConstraints.RemoveFromSolver(null);
                       cloth.Tear(contact.particle);
                       cloth.DistanceConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.SetActiveConstraints();
                       cloth.UpdateDeformableTriangles();
                       cloth.Solver.UpdateActiveParticles();
                   }
               }
           }
       }
   }

The code I have included tears the cloth but not at the point of collision. Please Help.
Nevermind figured out after spending some time in forum.  Gran sonrisa 
Heres the working code.
Code:
private void HandleClothCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
   {
       if (pressed)
       {
           foreach (Oni.Contact contact in e.contacts)
           {
               if (contact.distance < 0.01)
               {
                   Collider collider = ObiColliderBase.idToCollider[contact.other] as Collider;
                   ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];

                   if (collider.tag == "tool" && pa.actor.tag == "fat")
                   {
                       Debug.Log("called");
                       ObiTearableCloth cloth = pa.actor as ObiTearableCloth;
                       List<int> affectedConstraints = new List<int>();
                       foreach (ObiConstraintBatch batch in cloth.DistanceConstraints.GetBatches())
                       {
                           affectedConstraints = batch.GetConstraintsInvolvingParticle(contact.particle);
                       }
                       cloth.DistanceConstraints.RemoveFromSolver(null);
                       cloth.BendingConstraints.RemoveFromSolver(null);
                       for (int i = 0; i < affectedConstraints.Count; i++)
                       {
                           cloth.Tear(affectedConstraints[i]);
                       }
                       cloth.DistanceConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.AddToSolver(cloth);
                       cloth.BendingConstraints.SetActiveConstraints();
                       cloth.UpdateDeformableTriangles();
                       cloth.Solver.UpdateActiveParticles();
                   }
               }
           }
       }
   }
But I have another problem. I want the just holes to appear in the tear but no new triangles. I mean just cuts/tears but not triangular pieces.
Any ideas?
Reply
#18
I'm trying to accomplish this same thing, however the advice given in the thread is out of date. I have a tearable cable with one end attached to an object with the other end dangling like a strand of hair. i call rope.tear(rope.elements[10]) and sure enough the new particle spawned does the infinite mass thing and falls away, with the rest of the now cut rope acting as still connected to the original rope.  i would have expected it to cut and fall away as a whole piece of course. 

I've tried removing and re-adding the constraints before and after the tear (refactored from the code here to match the latest version of the asset) , but I cant seem to get a proper reference to the newly spawned infinite mass particle so i can assign the correct mass to it.

Here's my cut method:

Code:
   [ContextMenu("Test Cut")]
   public void Cut()
   {
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).RemoveFromSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).RemoveFromSolver();        
       TestRope.Tear(TestRope.elements[10]);
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).SetEnabled(true);
       TestRope.solver.UpdateParameters();
   }



i expect when this is figured out i will still need to fix the cut rope not falling away as well. 

any advice?

Thank you!
Reply
#19
Bump!

If the rope tearing is automatic using tear resistances, is there an event or a way to figure out the particle indices where the cut occurred, so you can apply a texture to fill the rope from the inside?
Reply
#20
(15-01-2020, 04:09 PM)Sether Wrote: I'm trying to accomplish this same thing, however the advice given in the thread is out of date. I have a tearable cable with one end attached to an object with the other end dangling like a strand of hair. i call rope.tear(rope.elements[10]) and sure enough the new particle spawned does the infinite mass thing and falls away, with the rest of the now cut rope acting as still connected to the original rope.  i would have expected it to cut and fall away as a whole piece of course. 

I've tried removing and re-adding the constraints before and after the tear (refactored from the code here to match the latest version of the asset) , but I cant seem to get a proper reference to the newly spawned infinite mass particle so i can assign the correct mass to it.

Here's my cut method:

Code:
   [ContextMenu("Test Cut")]
   public void Cut()
   {
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).RemoveFromSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).RemoveFromSolver();        
       TestRope.Tear(TestRope.elements[10]);
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).SetEnabled(true);
       TestRope.solver.UpdateParameters();
   }



i expect when this is figured out i will still need to fix the cut rope not falling away as well. 

any advice?

Thank you!

Hi there!

In 5.0, you don't need to remove constraints before and add them after. A single call to  RebuildConstraintsFromElements(); after tearing as many elements as you need will do. We still need to update the docs regarding this.

Code:
public class Tear : MonoBehaviour
{
   public ObiRope rope;

   public void Update()
   {
       if (Input.GetKeyDown(KeyCode.Space))
       {
           rope.Tear(rope.elements[10]);
           rope.RebuildConstraintsFromElements();
       }
   }
}

You can see an example of how its used in ObiRope's ApplyTearing() method, which is what is called each frame when automatic tearing is enabled.
Reply