Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
about softbody Collision
#8
(20-02-2022, 05:07 AM)drmgmt32 Wrote: I'm hoping to get extra detail on this question.

Would it be possible to give an example or an explanation of how to convert from both barycentric coordinates and solver space to global space?

Thank you for any help you can give!

Unity has built-in functions to convert data between spaces, as it's very a basic and common operation. See the Transform class:
https://docs.unity3d.com/ScriptReference/Transform.html

The methods you're interested in are:
TransformPoint/Direction/Vector: from local space to global space.
InverseTransformPoint/Direction/Vector: from global space to local space.

So to transform a particle position from the solver's local space to global space:
Code:
var worldPos = solver.transform.TransformPoint(solver.positions[index]);

You should definitely get familiar with vector spaces and converting data between them, as it's paramount when making games of any kind. There's a lot of online resources regarding vector spaces. For instance:
https://m-ansley.medium.com/local-space-...0e0bfb7694
http://blog.lidia-martinez.com/transform...ebra-unity

Barycentric coordinates are also very common. Given the barycentric coordinates of a point in a triangle, you get the point by simply multiplying each coordinate by the corresponding vertex, and adding it all together:

Code:
// "t" is the triangle, "bary" the barycentric coords.
var point = t.vertex1 * bary.x + t.vertex2 * bary.y + t.vertex3 * bary.z;

If the triangle was expressed in some transform's local space -like a triangle simplex in Obi- and you want the result in global (aka "world") space, you'd just use the above functions.

let me know if you need further help. kind regards,
Reply


Messages In This Thread
about softbody Collision - by zero16832 - 11-03-2021, 12:33 PM
RE: about softbody Collision - by josemendez - 11-03-2021, 12:40 PM
RE: about softbody Collision - by zero16832 - 11-03-2021, 12:48 PM
RE: about softbody Collision - by josemendez - 11-03-2021, 12:54 PM
RE: about softbody Collision - by zero16832 - 11-03-2021, 12:58 PM
RE: about softbody Collision - by josemendez - 11-03-2021, 02:53 PM
RE: about softbody Collision - by drmgmt32 - 20-02-2022, 05:07 AM
RE: about softbody Collision - by josemendez - 21-02-2022, 08:29 AM