Obi Official Forum
Help Scaling Obi Objects - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Scaling Obi Objects (/thread-544.html)



Scaling Obi Objects - darkcser - 19-04-2018

It seems like scaling objects with Obi Cloth and Obi Rope components causes issues with the simulation. What is the workflow for scaling Obi Cloth objects? Do the mesh topology and the Obi Cloth objects have to have the same scale? Does this mean I have to figure out the scale in my 3D modeller before I export to Unity? 

I had a fbx of a belt mesh that I tried to turn into an Obi Cloth object but no matter what I did with the distance constraint and distance iterations in the solver it just sagged like a super elastic silk ribbon. Eventually I realized that the belt in Unity was scaled to 0.01 so I duplicated it and scaled it to 1, and the cloth simulation looked better. Of course now I have a belt 100x bigger than desired.

Out of curiosity I followed the flag demo, and then tried to resize the flag by scaling up. It looked odd as well. (I fixed it horizontally instead of vertically, so the oddity is how it stretches the top.)

I had similar issues regarding scaling with Obi Rope that I posted in the rope section.


RE: Scaling Obi Objects - josemendez - 20-04-2018

(19-04-2018, 09:41 PM)darkcser Wrote: It seems like scaling objects with Obi Cloth and Obi Rope components causes issues with the simulation. What is the workflow for scaling Obi Cloth objects? Do the mesh topology and the Obi Cloth objects have to have the same scale? Does this mean I have to figure out the scale in my 3D modeller before I export to Unity? 

I had a fbx of a belt mesh that I tried to turn into an Obi Cloth object but no matter what I did with the distance constraint and distance iterations in the solver it just sagged like a super elastic silk ribbon. Eventually I realized that the belt in Unity was scaled to 0.01 so I duplicated it and scaled it to 1, and the cloth simulation looked better. Of course now I have a belt 100x bigger than desired.

Out of curiosity I followed the flag demo, and then tried to resize the flag by scaling up. It looked odd as well. (I fixed it horizontally instead of vertically, so the oddity is how it stretches the top.)

I had similar issues regarding scaling with Obi Rope that I posted in the rope section.

Deformable objects (cloth, ropes, fluid) cannot be transformed directly at runtime (translated, rotated, or scaled). Not Obi's limitation, it's just a fundamental consequence of how transform math works: scaling is an affine transformation, and works relative to a reference point, or center. A deformable piece of cloth (or any other non-rigid object) has no clearly defined "center", so it cannot be transformed.

When you transform a cloth, only its fixed particles will be scaled (as they are statically attached to the object's frame) and the rest of the cloth simulation will just follow their new shape, stretching or compressing where needed. If no particles are fixed, transforming the cloth will have no effect at all. Unity's default cloth works the same way.

There's one workaround though: if you simulate the cloth in local space, you can transform the space in is simulated in instead. This will result in a more traditional scaling behavior. To do this, enable "simulate in local space" in the ObiSolver, parent the cloth under the solver, then scale/rotate/translate the solver itself.

Now, regarding the initial scale of your objects and your export/import workflow, Unity's mesh importer has a "scale factor" option specifically designed for this: it sets the actual scale at which your mesh is imported, and this size is regarded as its "rest" size (their size when the transform's scale is set to 1,1,1)

You should also strive to model your meshes -and your entire scene- using real-world units. This is extremely important when working with physics. 1 Unity unit = 1 meter, as fas as the physics engine is regarded. If you set your modeling package's units to meters, you will be able to use a scale factor of 1 in Unity's import options. If you set them to centimeters, you'll have to use a scale factor of 0.01, etc. See "using the right size":
https://docs.unity3d.com/Manual/class-Rigidbody.html

Do not change the size of your objects by altering their transform's scale in editor, this is generally regarded as bad practice and will make it very difficult to get relative sizes of different objects in your scene right. You should only use transform scaling when making an object bigger or smaller than its natural size in your game's world.

kind regards,


RE: Scaling Obi Objects - darkcser - 28-04-2018

(20-04-2018, 08:59 AM)josemendez Wrote: Deformable objects (cloth, ropes, fluid) cannot be transformed directly at runtime (translated, rotated, or scaled). Not Obi's limitation, it's just a fundamental consequence of how transform math works: scaling is an affine transformation, and works relative to a reference point, or center. A deformable piece of cloth (or any other non-rigid object) has no clearly defined "center", so it cannot be transformed.

When you transform a cloth, only its fixed particles will be scaled (as they are statically attached to the object's frame) and the rest of the cloth simulation will just follow their new shape, stretching or compressing where needed. If no particles are fixed, transforming the cloth will have no effect at all. Unity's default cloth works the same way.

There's one workaround though: if you simulate the cloth in local space, you can transform the space in is simulated in instead. This will result in a more traditional scaling behavior. To do this, enable "simulate in local space" in the ObiSolver, parent the cloth under the solver, then scale/rotate/translate the solver itself.

Now, regarding the initial scale of your objects and your export/import workflow, Unity's mesh importer has a "scale factor" option specifically designed for this: it sets the actual scale at which your mesh is imported, and this size is regarded as its "rest" size (their size when the transform's scale is set to 1,1,1)

You should also strive to model your meshes -and your entire scene- using real-world units. This is extremely important when working with physics. 1 Unity unit = 1 meter, as fas as the physics engine is regarded. If you set your modeling package's units to meters, you will be able to use a scale factor of 1 in Unity's import options. If you set them to centimeters, you'll have to use a scale factor of 0.01, etc. See "using the right size":
https://docs.unity3d.com/Manual/class-Rigidbody.html

Do not change the size of your objects by altering their transform's scale in editor, this is generally regarded as bad practice and will make it very difficult to get relative sizes of different objects in your scene right. You should only use transform scaling when making an object bigger or smaller than its natural size in your game's world.

kind regards,

Thank you for this detailed response. I typically don't do much with physics in Unity beyond basic rigidbodies so this has been illuminating.