Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cloth Mesh disappearing when pressing play
#15
(26-01-2021, 01:38 PM)Merch137 Wrote: I was not scaling the way you told me to do it in blender, In which case I'm about to go do it soon and reset it up in unity. however transforms appear to be pretty simple to me, you want to scale the unit twice the size so it goes from 1 to 2 in all three scaling parts of the model. Its not much more difficult than that, and any kind of transforming of the model no matter where its done is going to be comparable maybe even using something like a gizmo to simply scale it like in zbrush [...]. Theres going to be very little to make it more difficult than how simple I just explained it.

For rigid objects and uniform scaling (same scaling in all 3 axis), it's as simple as you just described. However cloth is not a rigid object, and Unity does not restrict you to uniform scaling. So things become a bit more complex:

There's several kinds of transforms: affine, rigid, perspective, etc. The transforms used in Unity (and most 3D packages) are affine transforms. This means they have translation, rotation, scale (and shear/skew). If they had only translation and rotation, they'd be rigid transforms.

Now, here's the caveat: rigid transforms preserve euclidean distance, affine transforms do not. This means that if you have a line and you rigidly transform it (rotate or translate it) its length remains the same. But if you scale it (applying an affine transform) its length changes. If scaling is uniform, you can get the new length by multiplying the unscaled length by the scale. But if scaling is not uniform, there's no quick way to recover the new length from the old one (you'd have to do the full math of subtracting both ends of the line, dot product the resulting vector with itself and take the square root to recalculate the post-scale length).

What does this have to do with cloth and deformable objects in general? well, part of the information stored by cloth to remember its rest shape is the length of all edges in the mesh. This is so that the cloth can stretch/compress/bend, but still keep its original shape and return to it. So if you scale cloth, its rest shape remains unscaled, otherwise the rest shape would need to be recalculated every frame which is very costly. Scale is applied to the object after deformation, which can result in weird spiky meshes and all sorts of visual glitches.

For this reason, when you scale a piece of cloth (or any deformable object) it won't grow/shrink like a rigid object would. Only rigid transforms can be applied to deformable objects, affine transforms cannot. So if your cloth transform in the scene has a value of 200,200,200, you need to use a scale of 1/200, 1/200, 1/200 when generating the cloth blueprint, so that they compensate each other once an affine transform is applied to it. It can also lead to floating point precision issues, since the simulation would be performed using very tiny numbers (depending on how large your scale is, 1/200 is smaller than 1/100). This is cumbersome and not immediately obvious for most people. It's also not exclusive to Obi, all deformable physics engines I've ever used or heard of precalculate and store the rest shape of objects.

There's a lot of details I left on the table, but you get the idea. This is why I think using unit scaling is much simpler than dealing with all of the above, as a scale of 1,1,1 essentially turns your affine transform into a rigid transform. If you factor in things like import scale factor and units as I mentioned before, it gets even more confusing (at least to me). Please don't get offended if you already knew about this, I'm genuinely just trying to help.
Reply


Messages In This Thread
RE: Cloth Mesh disappearing when pressing play - by josemendez - 26-01-2021, 02:08 PM