Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding the inner mechanics of softbody
#2
(07-06-2023, 12:45 AM)whatever Wrote: Hi,

I want to use Obi softbody as an input parameter to create a sound effect. I want to use the deformation factor as one of the controlling parameters. I saw DeformationToColors.cs, and I think it is pretty close to what I want to do with the asset, but I am having a little bit of a hard time understanding how it exactly works. Could you explain or point me to the right documentation location?

Hi!

This page explains how constraint data is laid out in Obi:
http://obi.virtualmethodstudio.com/manua...aints.html

And this one explains how constraints work internally, to impose conditions on how the particles move around:
http://obi.virtualmethodstudio.com/manua...gence.html

(07-06-2023, 12:45 AM)whatever Wrote: So, what I did was add and print this information in the loop of the batch.numIndices in DeformationToColors.cs:
logQueue.Enqueue($"Batch {j}, Constraint {i}, Index {k}, Deformation {deformation}, Norm {norms[p]}, Count {counts[p]}");

and this is what was logged in one of the instances
Batch 5, Constraint 2, Index 3, Deformation 0.0003457069, Norm 0.001275539, Count 5

As explained in the above links, constraints are grouped into batches. All constraints in the same batch are guaranteed to not share any particles, which allows for efficient parallelization.

So this data means you're looking at particle #3 in constraint #2 in batch #5, the Frobenius(*) norm of the constraint's deformation matrix is 0.0012, the overall accumulated deformation for that particle is 0.00034, and the amount of constraints that affect that particle so far is 5.

This specific script simply goes over all constraints in the body, and averages the amount of deformation "felt" by each particle as a result of all constraints affecting it. That's why it counts the amount of constraints affecting each particle ("Count", in your log) and accumulates the norm of the matrix into a "Deformation" variable, then it just divides the total deformation by the count to calculate an average, which is then mapped to a color.


kind regards,

(*) Deformation in Obi is stored as a 3x3 matrix, that encodes deformation shape in 3D. Extracting the deformation magnitude from the matrix (that is, how much it deviates from the identity matrix) can be done in a variety of ways, this sample script uses the Frobenius (aka Euclidean) norm which is just the square root of the sum of the squares of all elements in the matrix.
Reply


Messages In This Thread
RE: Understanding the inner mechanics of softbody - by josemendez - 07-06-2023, 09:50 AM