Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sticking cloth on object in VR
#4
(16-10-2017, 02:56 AM)mbbmbbmm Wrote: Hello, I have a few questions! I am trying to achieve the following for a VR project (I'm using HTC Vive and Leap Motion):
I want to grab a texture object that uses the Obi cloth simulation and place it on a mesh object. The mesh object optionally has been changed before that so that it is necessary to update its mesh collider once. After the object is placed it should be possible to slide the texture/cloth over the object while still having cloth and mesh object stick together. In the end the cloth object should be frozen and optionally a new texture/cloth comes in - taking the old one out of the calculations to save performance etc.

1 For now I have put two handles on the upper corners of the cloth to grab it and place it. Could I turn these handles off after being done with the rough placement? Also it would be much more convenient to be able to grab the cloth anywhere so I wouldn't need dedicated handles. Is there something like temporary handles that could react to the grabbing gesture of the leap motion? Can I directly influence the positions of particles that are in a certain range of the hands?

2 How can I recalculate the Obi collider of the object from its mesh collider? I think I saw something in the API using the ColliderGroup, but this doesn't seem to exist anymore.. At the moment I just add a new collider once the mesh is ready - but I am not sure if that is a good solution... also the cloth seems to jump each time I do that. It doesn't bother me too much, just want to make sure if this would be expected behaviour.

3 Regarding the surface sliding I think I would need to have an Obi collision material that is very sticky with a small stick distance (so it doesn't stick to quickly) and also a low friction value. Then use Friction Combine Minimum and Stickiness Combine Maximum. Does that sound about right?

4 How many iterations of the distance constraints would be OK for VR? Maybe 20 or 30? With the default the cloth enters the mesh a little too frequently..

5 And a final question: There will be a lot of different combinations of objects and cloth textures coming in one after another. But only one combination would be active at a time. What would be the best way to set this up regarding performance and memory? Can I pool all the mesh objects and texture/cloth objects and have them share one Solver? Or would it be better to instantiate them from prefabs and/or have a different solver for each cloth texture object?

Thank you!
Jan

2) Go to ObiColliderBase.cs and change the "tracker" variable (line 46) from protected to public. Then, on a ObiCollider w/ Meshcollider, you should be able to do:

Code:
(obiCollider.tracker as ObiMeshShapeTracker).UpdateMeshData();

3) Sounds ok. Keep in mind that the combine mode determines how to combine the values for both objects involved in each contact, and the defaults when no collision material is present is zero for both friction and stickiness. So if your cloth has a material with 0.2 friction and combine set to "min", but your colliders have no material, the resulting friction between them will be min (0.2,0) = 0.

4) Well, the amount of iterations largely depends on your particular scenario, your performance budget, and how much deviation from a "perfect" simulation you can tolerate. Higher iteration counts will yield better simulation (the definition of "better" depends on what the particular constraint type does: for distance constraints = less stretchy cloth, for bending constraints = more rigid cloth), etc.

My advice, regardless of your target platform (VR or not) is to always use the lowest iteration count that yields acceptable results in your scenario. 20 distance constraint iterations is not crazy for a cloth-centered app, but would almost always be too much for character cloth in a third-person hack'nslash. 

5) I'd go with prefabs, and a single solver. Make a prefab out of each cloth object, and upon instantiation, set their solver. Having a separate solver for each one is also ok, you can adjust the particle pool sizes (solver.maxParticles) a bit better, also use independent solver settings for each cloth, but having multiple solvers has a slight performance hit. Might outweight the benefits, might not, all you can do is try. 

Start with one prefab per object, each one with its own solver (it's easier to set up). Measure performance, if it's enough you're done. If not, try a single solver.
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 josemendez - 19-10-2017, 02:43 PM
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