Obi Official Forum
Obi SoftBody with unity Mesh Collider and Mesh Filter - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html)
+--- Thread: Obi SoftBody with unity Mesh Collider and Mesh Filter (/thread-3738.html)



Obi SoftBody with unity Mesh Collider and Mesh Filter - ilyas_Gefeasoft - 20-01-2023

Hello,

I am trying to remove the triangles from the soft body, but I am having troubles. I am not able to access the mesh collider or Mesh filter of the soft body. When I am trying to set it up, it is ignored by the obi soft body, even though when I try to remove triangles it does remove but I am unable to see the result due to the Mesh Collider and Mesh Filter inaccessibility of the soft body Confundido . I was wondering if there is something special that I must do to achieve the result Idea .  As you can see in the attached image, the mesh collider is not attached with the soft body even though it is attached to the object. 

I will appreciate your help.  Sonrisa


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - josemendez - 20-01-2023

(20-01-2023, 11:20 AM)ilyas_Gefeasoft Wrote: I am trying to remove the triangles from the soft body, but I am having troubles.

Hi!

short answer: you can't.
long answer: it's possible but really costly and rather complex, since it involves updating the physical representation of the softbody, its mesh, and updating the skinning.

(20-01-2023, 11:20 AM)ilyas_Gefeasoft Wrote: I am not able to access the mesh collider or Mesh filter of the soft body.

Because there's no MeshCollider or MeshFilter in a softbody. MeshColliders are used together with rigidbodies, and MeshFilters are used for meshes that don't deform.

Obi is a particle-based engine, so collisions are handled by particles: there's no need for MeshColliders on Obi actors. The mesh of a softbody is deformed by skinning it to the underlying particles, so it uses a SkinnedMeshRenderer instead of a MeshRenderer.

I'm not sure what you're trying to do exactly, but I can tell you're rather confused. Could you explain what you're trying to achieve in more detail?


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - ilyas_Gefeasoft - 20-01-2023

(20-01-2023, 12:03 PM)josemendez Wrote: Hi!

short answer: you can't.
long answer: it's possible but really costly and rather complex, since it involves updating the physical representation of the softbody, its mesh, and updating the skinning.


Because there's no MeshCollider or MeshFilter in a softbody. MeshColliders are used together with rigidbodies, and MeshFilters are used for meshes that don't deform.

Obi is a particle-based engine, so collisions are handled by particles: there's no need for MeshColliders on Obi actors. The mesh of a softbody is deformed by skinning it to the underlying particles, so it uses a SkinnedMeshRenderer instead of a MeshRenderer.

I'm not sure what you're trying to do exactly, but I can tell you're rather confused. Could you explain what you're trying to achieve in more detail?
Thank you for you reply. Tímido

I am trying to remove or delete the part of a softbody when it is contacted by another game object using raycast. For example, if the game object is touching the surface of softbody, that part which is contacted gets removed, such as the cauterization method in tissue operation. 
I have implemented my algorithm on rigidbodies and it gives the result I was looking for but with softbodies, i am unable to get the same result perhaps, I have been treating softbodies same a as rigidbodies.  Huh


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - josemendez - 20-01-2023

(20-01-2023, 12:29 PM)ilyas_Gefeasoft Wrote: Thank you for you reply. Tímido

I am trying to remove or delete the part of a softbody when it is contacted by another game object using raycast. For example, if the game object is touching the surface of softbody, that part which is contacted gets removed, such as the cauterization method in tissue operation. 
I have implemented my algorithm on rigidbodies and it gives the result I was looking for but with softbodies, i am unable to get the same result perhaps, I have been treating softbodies same a as rigidbodies.  Huh

Rigidbodies and softbodies have very little in common, and what you are trying to do is *a lot*more complex to do in the case of a softbody than it is for a rigidbody.

A rigidbody -as the name implies- is "rigid". This means its mesh cannot deform at all due to collisions or external forces. As a consequence of this, its center of mass is fixed in its local frame of reference. As the rigidbody moves, you can basically transform all vertices in the mesh by the object's transform and you're done. MeshColliders take advantage of the fact that the mesh doesn't deform to implement collision detection efficiently:mesh data is preprocessed and stored in a spatial partitioning data structure (BVH, BIH, Kd-tree, etc), that stays the same throughout the lifetime of the rigidbody.

Removing a triangle from a rigidbody is as simple as taking out the triangle from the mesh, and telling its MeshCollider to update its internal data structure.

A softbody however, is "soft". Its mesh will deform, so you cannot easily define a single frame of reference for it, and you cannot use MeshColiders since that would require to update its internal stricture every frame which is terribly slow. So for physical simulation, multiple particles (each with their own position, mass, inertia tensor, etc) are used, and their positions re-used for collision detection, instead of using the mesh directly. Each individual vertex in the mesh is independently transformed (just like in an animated character) so SkinnedMeshRenderer must be used instead of a MeshRenderer.

Removing a triangle from a softbody requires taking it out from the mesh, updating its particle-based physical representation (the blueprint, in Obi's case) and also update the skinning information in the SkinnedMeshRenderer, used to transform the mesh's vertices as the softbody deforms.

I'd recommend reading up on particle position-based dynamics and linear blend skinning. There's a lot of new concepts you must understand before attempting to do what you want.

kind regards,


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - ilyas_Gefeasoft - 20-01-2023

(20-01-2023, 12:48 PM)josemendez Wrote: Rigidbodies and softbodies have very little in common, and what you are trying to do is *a lot*more complex to do in the case of a softbody than it is for a rigidbody.

A rigidbody -as the name implies- is "rigid". This means its mesh cannot deform at all due to collisions or external forces. As a consequence of this, its center of mass is fixed in its local frame of reference. As the rigidbody moves, you can basically transform all vertices in the mesh by the object's transform and you're done. MeshColliders take advantage of the fact that the mesh doesn't deform to implement collision detection efficiently:mesh data is preprocessed and stored in a spatial partitioning data structure (BVH, BIH, Kd-tree, etc), that stays the same throughout the lifetime of the rigidbody.

Removing a triangle from a rigidbody is as simple as taking out the triangle from the mesh, and telling its MeshCollider to update its internal data structure.

A softbody however, is "soft". Its mesh will deform, so you cannot easily define a single frame of reference for it, and you cannot use MeshColiders since that would require to update its internal stricture every frame which is terribly slow. So for physical simulation, multiple particles (each with their own position, mass, inertia tensor, etc) are used, and their positions re-used for collision detection, instead of using the mesh directly. Each individual vertex in the mesh is independently transformed (just like in an animated character) so SkinnedMeshRenderer must be used instead of a MeshRenderer.

Removing a triangle from a softbody requires taking it out from the mesh, updating its particle-based physical representation (the blueprint, in Obi's case) and also update the skinning information in the SkinnedMeshRenderer, used to transform the mesh's vertices as the softbody deforms.

I'd recommend reading up on particle position-based dynamics and linear blend skinning. There's a lot of new concepts you must understand before attempting to do what you want.

kind regards,
Thank you for your response, it is clear for me now, much appreciated.  Tímido


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - ilyas_Gefeasoft - 24-01-2023

(20-01-2023, 12:48 PM)josemendez Wrote: Rigidbodies and softbodies have very little in common, and what you are trying to do is *a lot*more complex to do in the case of a softbody than it is for a rigidbody.

A rigidbody -as the name implies- is "rigid". This means its mesh cannot deform at all due to collisions or external forces. As a consequence of this, its center of mass is fixed in its local frame of reference. As the rigidbody moves, you can basically transform all vertices in the mesh by the object's transform and you're done. MeshColliders take advantage of the fact that the mesh doesn't deform to implement collision detection efficiently:mesh data is preprocessed and stored in a spatial partitioning data structure (BVH, BIH, Kd-tree, etc), that stays the same throughout the lifetime of the rigidbody.

Removing a triangle from a rigidbody is as simple as taking out the triangle from the mesh, and telling its MeshCollider to update its internal data structure.

A softbody however, is "soft". Its mesh will deform, so you cannot easily define a single frame of reference for it, and you cannot use MeshColiders since that would require to update its internal stricture every frame which is terribly slow. So for physical simulation, multiple particles (each with their own position, mass, inertia tensor, etc) are used, and their positions re-used for collision detection, instead of using the mesh directly. Each individual vertex in the mesh is independently transformed (just like in an animated character) so SkinnedMeshRenderer must be used instead of a MeshRenderer.

Removing a triangle from a softbody requires taking it out from the mesh, updating its particle-based physical representation (the blueprint, in Obi's case) and also update the skinning information in the SkinnedMeshRenderer, used to transform the mesh's vertices as the softbody deforms.

I'd recommend reading up on particle position-based dynamics and linear blend skinning. There's a lot of new concepts you must understand before attempting to do what you want.

kind regards,
Hello Again,


Thank you, with the information I got from you, I was able to successfully implement the removing triangle on obi softbody Sonrisa. Now I would like to ask another question if it is ok with you. Tímido

I want to separate the object in two after I removed all the triangles from middle or while i am removing the triangles it gets separated from the part of removed triangles. Do i need to access particles or what?   Idea

P.S; I did not fix the culling that is why the other side of mesh seems empty. I also added the image for the cloth that I am trying now.
Best regards,


RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - josemendez - 24-01-2023

(24-01-2023, 12:54 PM)ilyas_Gefeasoft Wrote: Hello Again,


Thank you, with the information I got from you, I was able to successfully implement the removing triangle on obi softbody Sonrisa. Now I would like to ask another question if it is ok with you. Tímido

I want to separate the object in two after I removed all the triangles from middle or while i am removing the triangles it gets separated from the part of removed triangles. Do i need to access particles or what?   Idea

Hi!

You will need to access particles, constraints, or possibly both depending on what you want to do.

A softbody is built out of particles, that are bound to each other using shape matching constraints.
To learn how to access and modify particles, see: http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.html
To learn how to access and modify constraints, see: http://obi.virtualmethodstudio.com/manual/6.3/scriptingconstraints.html

Note this is an extremely advanced use case, you will possibly need information beyond what's covered in Obi's manual to get this to work. I'd suggest taking a look at the research articles used to write Obi, you can find a complete list here:
http://obi.virtualmethodstudio.com/references.html

Specially this one: https://matthias-research.github.io/pages/publications/orientedParticles.pdf

kind regards,