27-08-2019, 02:25 AM
(23-08-2019, 10:47 AM)josemendez Wrote: My apologies, since you were talking about character skin, I assumed we were talking about ObiCloth. Didn't even realize we are in the ObiSoftbody subforum .
Same thing applies to soft bodies though. Keep in mind that softbody generation involves two steps:
generate the particle representation using a skinned mesh, then bind another skinned mesh to it via ObiSoftbodySkinner. Both meshes don't need to be the same one.
I assume you use the same mesh for both generation and skinning. Once you have your bone scale baked into your shared mesh vertices as I described in the previous post (which is outside of the scope of Obi), generating the soft body is done by calling the GeneratePhysicRepresentationFromMesh coroutine.
Code:yield return softbody.StartCoroutine(actor.GeneratePhysicRepresentationForMesh());
After this coroutine is completed, then bind the skin by calling the skinner's BindSkin coroutine:
Code:yield return skinner.StartCoroutine(skinner.BindSkin());
Finally, assuming your softbody has been assigned a solver, add it to the solver to start simulation:
Code:softbody.AddToSolver(null);
Thank you very much! code examples are very helpful.
Saving a scaled mesh to another mesh asset sounds reasonable. I will give it a try.
Still have one question though, right after GeneratePhysicRepresentationFromMesh coroutine (the same with "Initialize" in editor?) is done,
is it possible to edit particles from scripts to tell which part of my mesh should be simulated?