Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sticking cloth on object in VR
#6
(22-10-2017, 11:47 PM)mbbmbbmm Wrote: Thanks so much for your help!
I nearly got it working. I tried to use the ObiParticleHandle class to AddParticle() and RemoveParticle() the closest particle, but while that kind of works for a short amount of time it gets really weird when the Leap Motion hands lose tracking / go out of the field of view (which happens very frequently). I thought I would use ObiParticleHandle.RemoveParticle(), but I think calling it from OnDisable might be to late? Gotta try that tomorrow.

As far as I understand, I can't create a reference to the particle itself, but have to use the indices. As long as there is only one actor / cloth - are the indices of the particles reliable or is it possible that they change some time after I have cached e.g. the index of the nearest particle?

@niZmo: That's super cool, I'm a big fan of VRTK! I looked at the code you posted, only could parse parts of it because it's so specifically for VRTK, and kind of complex ^^; ... but it helped me get a rough idea, thanks again.

This might help you a little better. I’ve been workin on and interaction system for Obi and wish I was further along to have a stable release but I grabbed a snippet for someone wanting to attach things to a cloth. It’s essentially the same to interact with an actor. I am at work, but I do have a method to use ObiParticleHandle in a similar fashion. A handle is better since the particles can’t influence the controller/hands. Anyway here is the link. I am assuming the leap hand object has an ObiCollider on it and your using the ObiSolver collision event to get what particle you are hitting with your hand. So with this snippet all you have to do is tell it the particle and its colliding ObiCollider and it will attach to the actor. It has a dictionary that will pair an ObiCollider with its pinnedIndex which is need for removing the pin constrint later on. The pin constraints pin index is NOT the same as the particle index its pinned to. It starts at 0 and counts up for every pin that’s added wether in the editor or added through code. Anyway it’ll be a little before I can post up how to dynamically use ObiParticleHandles for what you want to do. Got work then work again 8hrs after that lol. I do have a leap motion and this intrigues me to try it out. I remember TheStoneFox talk about putting leap support in VRTK, I don’t know it’s status though.

As far as particle referencing. The particles do not change. The particle are pool based but they won’t change unless they are put back into the pool by removing the actor from its solver. That being said the particles aren’t always in chronological order. To make it easier I’ll use ObiRope as an example since the particle are in line. Say you have Rope A that’s 10 particles long with indices 0 to 9. Then you make Rope B that’s 10 particle long with indices 10 to 19. You remove Rope A from the solver, and make a Rope C 20 particles long. It’ll use those recycled particles. The Particles of Rope C will be 0-9, 20-29. If you tear the rope between 7-8 it’ll take the next particle from the pool with is 30 and add it to one side of the cut. So Rope C’s particle order will be 0-7,30,8,20-29. Cloth is obviously a little different but if you are using a tearable cloth the particles being pulled from the solver is the same.
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