9
\$\begingroup\$

Please think of this in an engine-agnostic way first, and then we can talk about specific engines.

In my game, I have a 3D character which is wearing a hakama (think of it as a long pleated skirt). This character will be doing a lot of dancing, which I'm getting a lot of motion capture data for. This is how my character is rigged right now (view from Unity):

Character rig

This character has a standard 3D Studio Max humanoid rig, plus a bunch of bones for the "dangling" stuff such as the skirt, the sleeves, the long hair and other parts.

Unfortunately, motion capture can only give me data for the humanoid part, not for the additional parts, so I need a way to animate these. For now, let's focus on the hakama (skirt). I have a few ways of doing this:

  1. Removing the additional bones, and rig the cloth directly to the leg bones: This is my last resort, but one that I'd like to avoid, as the hakama will move directly with the legs as if it were a tight fit, losing a lot of realism.

  2. Keep the bones and animate them manually. There are just too many frames and too many characters for it to feasible to do this manually, so this is out of the question.

  3. Simulate the leg and cloth interaction in some way. Fortunately, the dancing is static (just for cutscenes), so I can do this offline, export the resulting bone transforms for each frame, and apply this to the character during playback.

Since Unity has a pretty mature physics engine, I am trying to hack an offline physics simulation that exports the resulting bone transforms for each frame, which I can then playback in real time in the actual game (which by the way is not Unity-based). So far, the sleeves and hair have shown some pretty good results, but the hakama is much more difficult, and I haven't gotten it to work even close to decently.

I have tried:

  • Setting colliders in the legs and the skirt, so when the legs push the skirt, the skirt moves. I can set a bunch of joints to set some constraints, but setting a correct shape and position for the skirt colliders is not trivial, since the leg colliders eventually find a hole between the skirt colliders, which leads to the leg intersecting with the skirt.

  • Instead of colliders, set spring joints between the leg bones and the skirt bones. Unfortunately, springs don't have a concept of "pushing" vs "pulling", and I can visualize a lot of cases where the simulation will lead to the leg intersecting the skirt.

Notice that I can't use Unity's cloth simulator, since this acts on polygons directly, and I need to be able to export the results of the simulation in terms of bone matrices.

It's not mandatory to use Unity. I just need to find a way to simulate the leg-cloth interaction and export the results in a series of bone transforms.

Any ideas on how to solve this problem?

\$\endgroup\$
16
  • 1
    \$\begingroup\$ Isn't cloth simulation an option? \$\endgroup\$
    – Bálint
    Commented Jan 8, 2018 at 10:54
  • \$\begingroup\$ @Bálint: No, as I said: "Notice that I can't use Unity's cloth simulator, since this acts on polygons directly, and I need to be able to export the results of the simulation in terms of bone matrices." \$\endgroup\$ Commented Jan 8, 2018 at 14:40
  • \$\begingroup\$ Used to artists hand-keyframing those extra bones for cloth and hair and so forth, but not so sure how to simulate dynamics in a way that outputs the results to bones. Is a geocache an option? Those tend to be kinda explosive in disk space use though. I'm a masochist so I'd be tempted to see if I could reverse engineer a dynamics simulation in a way where the bone figures out its rotation based on the deformations of the vertices weighted against it if there's no such solution. \$\endgroup\$
    – user77245
    Commented Jan 8, 2018 at 22:35
  • \$\begingroup\$ @DrunkCoder: What is a geocache? I only know about the gps activity \$\endgroup\$ Commented Jan 9, 2018 at 13:26
  • 1
    \$\begingroup\$ @Basic: what I eventually did was to do a cloth simulation, and store the positions for each vertex for each frame. That's a lot of data, but not as much as I had thought. \$\endgroup\$ Commented Nov 22, 2020 at 23:37

2 Answers 2

0
\$\begingroup\$

I know you said engine agnostic, but I can only tell you what I know... I don't know Unity, but Unreal Engine has the ability to apply physics simulation to bones. But it's not going to look like cloth if you're going that route. Its best used for things like pony tails, or pauldrons on armour...things that just need to shake a little. The only way it will look like cloth is to either do a physics simulation on the mesh (I don't understand why you say you can't) or to hand-animate it which would be brutally hard.

You also say a few confusing things. You say "Fortunately, the dancing is static". Static means unmoving, and by definition if they're dancing, they're not unmoving. Do you mean they're just dancing on spot? You also say doing it offline - Maybe this is a Unity term. Do you mean a pre-rendered sequence as opposed to a real-time simulation?

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for your comment. I had this issue 5 years ago, and I already found a solution. \$\endgroup\$ Commented Jul 10, 2023 at 9:34
  • \$\begingroup\$ Sorry, I'm new to Stack and didn't notice a date. You should post your solution for everyone else to learn from :) \$\endgroup\$
    – TorQue MoD
    Commented Jul 19, 2023 at 17:51
  • \$\begingroup\$ Certainly, but my solution involved reframing the problem altogether, and doing it in a manner that only really applies to my problem, so it really wouldn't be helpful to anybody else. Thanks for your reply though. \$\endgroup\$ Commented Jul 21, 2023 at 7:29
0
\$\begingroup\$

Revisiting this problem five years later to post the solution that I found.

In general, it's not really possible to get good results with skeletal animation. The cloth doesn't really move in a way that can be meaningfully represented as a skeletal animation.

Instead, and over-simplifying things, I ended up simulating the cloth offline with a semi-custom solution, and getting the actual vertex positions for each vertex for each frame of the animation. I then replay this when rendering the game.

It's a lot of data, but with some aggressive quantization, it was possible to get the data to a manageable size.

If there is something to learn from this, is that skeletal animation is meant for skeleton-like structures, and cloth is not like this.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .