Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Paper (bank note) simulation
#13
(24-11-2021, 01:02 PM)Romahaaa Wrote: Ok, so I got this point on the bank note surface, but this point is pretty far (screenshot) from the actual particle positions. How can I apply the movement to the bank note? Checking ObiParticleDragger I see that it apply force to the single particle, but it's not always will be correct. Is there an east way to find the opposite particle and add force to both of them?

When you use surface collisions, the contact information given by raycast queries includes the index of the simplex hit. (if you're unsure of what a simplex is, check the surface collisions page)

The simplex in the case of cloth is a triangle, and it contains the 3 indices of the particles in it. See the examples in the queries manual page, specifically the single raycast one. Pasting it here for convenience:

Code:
// perform a raycast, check if it hit anything:
if (solver.Raycast(new Ray(Vector3.zero, Vector3.up), out QueryResult result, filter, 50, 0.1f))
{
            // get the start and size of the simplex that was hit:
            int simplexStart = solver.simplexCounts.GetSimplexStartAndSize(result.simplexIndex, out int simplexSize);

            // Debug draw the simplex:
            for (int i = 0; i < simplexSize; ++i)
            {
                int particleIndex = solver.simplices[simplexStart + i];
                Vector3 pos = solver.transform.TransformPoint(solver.positions[particleIndex]);
                Debug.DrawRay(pos, Vector3.up, Color.yellow);
            }
}

As you see, the code casts a ray and as a result you get the index of the simplex and the size of the simplex (for cloth is always 3, since it's made of triangles). Then the code iterates trough the simplices to draw them.

Having the simplex, then you can do one of several things: move all 3 particles in it, or use barycentric coordinates to apply different forces to each one, depending on the kind of interaction you're after.

Let me know if you need further help Sonrisa.
Reply


Messages In This Thread
Paper (bank note) simulation - by Romahaaa - 18-11-2021, 10:45 AM
RE: Paper (bank note) simulation - by josemendez - 18-11-2021, 12:23 PM
RE: Paper (bank note) simulation - by Romahaaa - 18-11-2021, 12:40 PM
RE: Paper (bank note) simulation - by josemendez - 18-11-2021, 01:04 PM
RE: Paper (bank note) simulation - by Romahaaa - 20-11-2021, 07:16 AM
RE: Paper (bank note) simulation - by josemendez - 22-11-2021, 08:48 AM
RE: Paper (bank note) simulation - by Romahaaa - 22-11-2021, 01:09 PM
RE: Paper (bank note) simulation - by josemendez - 22-11-2021, 01:20 PM
RE: Paper (bank note) simulation - by Romahaaa - 24-11-2021, 01:02 PM
RE: Paper (bank note) simulation - by josemendez - 24-11-2021, 01:31 PM
RE: Paper (bank note) simulation - by Romahaaa - 24-11-2021, 01:45 PM
RE: Paper (bank note) simulation - by josemendez - 24-11-2021, 02:02 PM
RE: Paper (bank note) simulation - by Romahaaa - 29-11-2021, 01:31 PM
RE: Paper (bank note) simulation - by josemendez - 29-11-2021, 02:24 PM
RE: Paper (bank note) simulation - by Romahaaa - 29-11-2021, 03:15 PM
RE: Paper (bank note) simulation - by josemendez - 29-11-2021, 03:48 PM
RE: Paper (bank note) simulation - by Romahaaa - 30-11-2021, 03:30 AM
RE: Paper (bank note) simulation - by josemendez - 30-11-2021, 09:00 AM
RE: Paper (bank note) simulation - by Romahaaa - 02-12-2021, 05:36 AM
RE: Paper (bank note) simulation - by josemendez - 02-12-2021, 11:58 AM
RE: Paper (bank note) simulation - by Romahaaa - 03-12-2021, 05:43 AM
RE: Paper (bank note) simulation - by josemendez - 22-11-2021, 08:49 AM
RE: Paper (bank note) simulation - by Romahaaa - 18-11-2021, 04:08 PM
RE: Paper (bank note) simulation - by Romahaaa - 20-11-2021, 05:26 AM