18-09-2023, 05:53 AM
(This post was last modified: 18-09-2023, 07:41 AM by josemendez.)
(17-09-2023, 02:09 AM)michendo Wrote: Is it possible to call the Obi Cloth Renderer "Bake Mesh" function from code?
Reason:
I have a complex inflating cloth object that is too slow to use OBI at run time when playing the game. So instead I want to perform the inflation in development version (slowly) and bake around 60 meshes, which I can then cycle through at runtime. So the OBI calculations will not happen at run time, I will just use the baked meshes.
Q1. To achieve this, I want to be able to spawn 60 meshes from code at various periods. Is there a way to call this method from code?
Q2. Is there a way to detect that the Solver sleep threshold has been met and the solver is asleep? This is the point in time I want to generate the baked mesh, then increase the inflation to capture the next frame.
Regards,
Michendo
Hi Michendo,
Q1. The "BakeMesh" button just takes ObiClothRenderer.clothMesh and saves it as an asset. The function that does this is
Code:
ObiEditorUtils.SaveMesh(Mesh mesh, string title, string name, bool makeNewInstance = true, bool optimizeMesh = true);
You can call this function in-editor yourself.
Q2. There's no such thing as a per-solver sleep threshold in Obi, it's a per-particle threshold. You can iterate trough all particles and check whether their energy level (squared velocity magnitude) is below the sleep threshold. To do this, use the particles API.
kind regards,