Hi!
I have simulated a rope made by spheres. To fix the spheres I am using point to point constraints, and everything work as I want.
Now I want to be able to take the last sphere of the rope with the mouse and move the whole rope, but I'm having a problem when rendering, as that sphere has a constraint with the previous one and when I try to move it, that second sphere pulls the first one, so what I see on the viewer is not good.
What can I do? Can I disable the constraint between this two spheres and then after moving the last sphere with the mouse enable it again? should I delete the constraint and then create it again?
Can anyone help me, please?
Thank you in advance!
disable a p2p constraint
-
- Posts: 18
- Joined: Thu Mar 22, 2012 9:29 am
Re: disable a p2p constraint
Since you want to move the whole rope by dragging one of its spheres, disabling the constraint will not produce the desired effect. Normally, if
the rigid bodies that belong to the rope are defined correctly, your rope should move when you dragged any of its spheres. I believe that there is something wrong in your setup, probably very large masses (or 0.0 mass on some of the rope parts ? ), that does not allow the rope to move. Note that if you are following the bullet examples, objects are mouse-picked and moved using a constraint, and this means that it mouse-moving cannot affect objects that are somehow firmly constrained on their position.
In any case, if you want to disable a constraint, just remove it before and add it after moving the sphere. To do so, you don't have to re-initialize the constraint, just use world->addConstraint() and world->removeConstraint() while maintaining a "global" pointer to your constraint object.
ps. i am not a bullet expert in any way, so i might be missing something.
the rigid bodies that belong to the rope are defined correctly, your rope should move when you dragged any of its spheres. I believe that there is something wrong in your setup, probably very large masses (or 0.0 mass on some of the rope parts ? ), that does not allow the rope to move. Note that if you are following the bullet examples, objects are mouse-picked and moved using a constraint, and this means that it mouse-moving cannot affect objects that are somehow firmly constrained on their position.
In any case, if you want to disable a constraint, just remove it before and add it after moving the sphere. To do so, you don't have to re-initialize the constraint, just use world->addConstraint() and world->removeConstraint() while maintaining a "global" pointer to your constraint object.
ps. i am not a bullet expert in any way, so i might be missing something.