Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sticking cloth on object in VR
#7
Heading off to work now too, but will definitely check that out later!
I am not checking for collision at the moment but once the GrabStrength of the hand is strong enough I find the nearest particle and check if the distance is below a certain threshhold for grabbing. Pretty much like this:

Code:
IEnumerator GrabParticle(ObiParticleHandle currentHandle)
{
   if (actor.InSolver)
   {
       actor.Solver.RequireRenderablePositions();
       yield return null;

       float currentSqrMagnitude = float.MaxValue;
       float smallestSqrMagnitude = float.MaxValue;
       float smallestMagnitude = float.MaxValue;
       int currentIndex = 0;

       for (int i = 0; i < actor.invMasses.Length; i++)
       {
           currentSqrMagnitude = (actor.GetParticlePosition(i) - currentHandle.transform.position).sqrMagnitude;
           if (currentSqrMagnitude < smallestSqrMagnitude)
           {
               smallestSqrMagnitude = currentSqrMagnitude;
               currentIndex = i;
           }
       }
       smallestMagnitude = Mathf.Sqrt(smallestSqrMagnitude);
       if (smallestMagnitude < user.clothManipulate.grabThreshold)
       {
           currentHandle.AddParticle(currentIndex, actor.GetParticlePosition(currentIndex), cachedInvMass);
       }

       actor.Solver.RelinquishRenderablePositions();
   }
}
This is done "once per grabbing" so should be ok I guess, but maybe using Colliders would be better...
Reply


Messages In This Thread
Sticking cloth on object in VR - by mbbmbbmm - 16-10-2017, 02:56 AM
RE: Sticking cloth on object in VR - by niZmo - 19-10-2017, 12:51 AM
RE: Sticking cloth on object in VR - by mbbmbbmm - 19-10-2017, 01:26 AM
RE: Sticking cloth on object in VR - by mbbmbbmm - 22-10-2017, 11:47 PM
RE: Sticking cloth on object in VR - by niZmo - 23-10-2017, 01:43 AM
RE: Sticking cloth on object in VR - by mbbmbbmm - 23-10-2017, 06:57 AM
RE: Sticking cloth on object in VR - by mbbmbbmm - 25-10-2017, 07:08 PM