Obi Official Forum
Scaling / Sizing a cloth - How? - 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: Scaling / Sizing a cloth - How? (/thread-226.html)



Scaling / Sizing a cloth - How? - csofrany - 04-11-2017

Hi there,
 
   I'm new to Obi in general, and just starting out with Obi Cloth. I have a scene where there are multiple differently sized items that I want to cover with pieces of cloth, to be uncovered later during runtime.

Now, in order to cover the different items, I'm using a simple plane that I add an Obi Cloth Component as outlined in the instructions. While this works in a general way, it seems to me that no matter what size of cloth i define (using the scale properties of the object's Transform), the resulting cloth expands/shrinks to the 1:1 scale as soon as I hit start, in effect negating any scale settings of the master Transform.

How do correctly size an Obi cloth so it stays at the size/scale I set? Do i have to create an appropriately sized mesh for each cloth, or can I use one mesh for all (as I'm doing now)?

Since this is a fairly basic issue, I assume I've missed an essential part of the manual - so any pointers appreciated.

Thanks,
ch  


RE: Scaling / Sizing a cloth - How? - josemendez - 04-11-2017

(04-11-2017, 04:20 PM)csofrany Wrote: Hi there,
 
   I'm new to Obi in general, and just starting out with Obi Cloth. I have a scene where there are multiple differently sized items that I want to cover with pieces of cloth, to be uncovered later during runtime.

Now, in order to cover the different items, I'm using a simple plane that I add an Obi Cloth Component as outlined in the instructions. While this works in a general way, it seems to me that no matter what size of cloth i define (using the scale properties of the object's Transform), the resulting cloth expands/shrinks to the 1:1 scale as soon as I hit start, in effect negating any scale settings of the master Transform.

How do correctly size an Obi cloth so it stays at the size/scale I set? Do i have to create an appropriately sized mesh for each cloth, or can I use one mesh for all (as I'm doing now)?

Since this is a fairly basic issue, I assume I've missed an essential part of the manual - so any pointers appreciated.

Thanks,
ch  
Hi!

Setting the scale (or position, or rotation) of any deformable object (cloth, rope, slime, etc) makes no sense at all in the general case. Consider this:

- what's the "position" of the cloth? the average of its vertices? its center of mass? any arbitrary vertex we define as its center?
- what's the "scale" of a cloth? if you stretch it by pulling, has it increased its scale? if it clumps into a small ball, has it been scaled down? in what direction? with respect to what point?
- same goes for rotation... if we twist both ends of a cloth strip in opposite directions, has the cloth (as a whole) rotated counter or clockwise?

Unity (and the current 3D graphics paradigm) makes use of affine transforms, that preserve points, lines and planes (straight shapes in general). Deformable objects lack this, since they can change their shape in a way that cannot be described by a simple affine transform. So in Obi, the transform only affects the fixed (red) particles in your cloth, since they are the only ones that can be rigidly transformed (not simulated). The same applies to Unity cloth, or any other cloth simulator, as this is just how geometry works (at least in this universe Guiño )

However, you can scale, rotate or translate the space in which the deformable object is simulated. Enter local space simulation. This requires a separate solver for each cloth object however:

- Parent your cloth object under the ObiSolver transform's. This transform will define the simulation space for your cloth.
- Enable "simulate in local space" in the ObiSolver inspector.
- You can now scale, rotate and translate the ObiSolver transform, and the cloth simulated "inside" of it will behave as you expect it to.

An alternative to this would be generate a different topology asset for each different size of your cloth mesh (have you noticed that the topology inspector has a "scale" property?), but this has several disadvantages:

- If you have more that say, 2 o 3 sizes of the same mesh, it can be tedious to set up.
- You cannot change the cloth size at runtime.

All this reminds me of one famous quote:
"Do not try and bend the spoon, that's impossible. There is no spoon. Then you'll see that it is not the spoon that bends, it is only yourself."
It is not the cloth that you scale, but the space around it.


RE: Scaling / Sizing a cloth - How? - csofrany - 04-11-2017

Thank you so much for the additional information

Quote:Setting the scale (or position, or rotation) of any deformable object (cloth, rope, slime, etc) makes no sense at all in the general case

Inside Obi, it would seem, not. For someone who's context is Unity it does very much. I wasn't aware that Unity cloth has the same restrictions, so thank you for pointing this out. This is going to require some re-thinking/coding of the scene. 


Quote:"Do not try and bend the spoon, that's impossible. There is no spoon. Then you'll see that it is not the spoon that bends, it is only yourself."

Ah, but it's literally the spoon's transformation *matrix* that I wanted to use for bending purpose, and it does not work in this case.

I'll take your kind instructions under advisement, and see how that works out.

Cheers,
-ch


RE: Scaling / Sizing a cloth - How? - josemendez - 04-11-2017

(04-11-2017, 05:16 PM)csofrany Wrote: Inside Obi, it would seem, not. For someone who's context is Unity it does very much. I wasn't aware that Unity cloth has the same restrictions, so thank you for pointing this out. This is going to require some re-thinking/coding of the scene. 

The bad news is that inside of Unity or outside of it, it does not make sense. It doesn't in the 3D vector algebra sense, not just in one particular program/work environment/paradigm. 

It just cannot be done for the reason I pointed out: mathematically there's no way to describe the state of a cloth (which can deform in a non-affine way) using a single affine matrix, like you can do with a rigid cube for instance (or any rigid shape).

You can however use a single matrix to "bend" the space in which the cloth lives, but this requires a second matrix describing the simulation space. Which is what the local space setup I described does.

If one really wanted though, it would be possible to design an engine such that each piece of cloth is simulated in its own space, described by its transformation matrix, instead of using it to transform the cloth vertices themselves. However, this would require to constantly convert values from one space to another when calculating stuff that involves other objects (collisions with rigidbodies or other cloth pieces, pinned vertices) or values described in world space (gravity, wind). Would also require you to define a separate transform for each and every pinned/fixed particle in the cloth. This is both extremely cumbersome from a workflow perspective and also very poor performance-wise. That's why you won't find a (good) cloth simulator designed this way. 

Let me know if you need help setting it up!

cheers!