Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
about softbody Collision
#1
how to get the collision point?

thx for your help
Reply
#2
(11-03-2021, 12:33 PM)zero16832 Wrote: how to get the collision point?

thx for your help

It's part of the contact struct. You can get both the point on the simplex surface (as barycentric coordinates) or on the collider surface (expressed in solver space):

See:
http://obi.virtualmethodstudio.com/tutor...sions.html
Reply
#3
(11-03-2021, 12:40 PM)josemendez Wrote: It's part of the contact struct. You can get both the point on the simplex surface (as barycentric coordinates) or on the collider surface (expressed in solver space):

See:
http://obi.virtualmethodstudio.com/tutor...sions.html
I just need the first collision point witch api can i use?
Reply
#4
(11-03-2021, 12:48 PM)zero16832 Wrote: I just need the first collision point witch api can i use?

What do you mean by the "first" collision point? there can be multiple collision points at once in a single frame...
Reply
#5
(11-03-2021, 12:54 PM)josemendez Wrote: What do you mean by the "first" collision point? there can be multiple collision points at once in a single frame...
I make a ground and a control softbody in scene . when the sofybody collision with the ground,this first collision
Reply
#6
(11-03-2021, 12:58 PM)zero16832 Wrote: I make a ground and a control softbody in scene . when the sofybody collision with the ground,this first collision

It’s not entirely clear to me, sorry. First collision since when? in the game? since last time the ground and the softbody where in contact? First particle that contacts the ground? First contact reported in the list of contacts for a single frame?

An object might collide with another during a single frame, or multiple frames.
You can get all contacts for the current frame using the collision callbacks API, see the link above. You can simply subscribe to the OnCollision event and grab the first contact in the list, if that’s what you are after.
Reply
#7
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!
Reply
#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