Obi Official Forum
ObiClothDragger question - 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: ObiClothDragger question (/thread-311.html)



ObiClothDragger question - rendezvous - 21-01-2018

Jose,

I was wondering if there's a way to modify the default behavior of picking/dragging a mesh and letting go. It seems that the stretched part of the mesh always snaps back to its initial form. Is there a way to make the mesh transformation remain the way you left it after picking & dragging?


RE: ObiClothDragger question - rendezvous - 30-01-2018

Bump - Just hoping to get an answer from Jose or any other savvy user as to whether this is possible.  Huh


RE: ObiClothDragger question - josemendez - 30-01-2018

(30-01-2018, 03:23 PM)rendezvous Wrote: Bump - Just hoping to get an answer from Jose or any other savvy user as to whether this is possible.  Huh

Hi there,

Just set the dragged particle's velocity and inverse mass to zero when the user releases it. That will fix it in place. See the last bit of http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html for info on how to do that.

Edit: To be more specific, modify the Picker_OnParticleReleased function of ObiClothDragger.cs so that it looks like this:

Code:
void Picker_OnParticleReleased (object sender, ObiClothPicker.ParticlePickEventArgs e)
{
    Oni.SetParticleInverseMasses(picker.Cloth.Solver.OniSolver,new float[]{0},1,picker.Cloth.particleIndices[e.particleIndex]);
    Oni.SetParticleVelocities(picker.Cloth.Solver.OniSolver,new Vector4[]{Vector4.zero},1,picker.Cloth.particleIndices[e.particleIndex]);
    picker.Cloth.Solver.RelinquishRenderablePositions();
}

As you can see, I simply replaced "originalMass" by zero and set the velocity to zero.