kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

Animating more than 1 character is not working #49

Closed wave-electron closed 5 years ago

wave-electron commented 6 years ago

@kcoley @ox

I have two character animations I posted at fusionar.app

CarrotMan

BananaMan

For some reason the two characters don't play nicely as one scene file in usd or usdz. They work as dae files in both Cheetah3D and Blender. I've attached the glTF 2.0 files I was using for the conversion. The characters are animating ok in the sandbox glTF viewer. two_Characters.zip

I spent several hours on this today manually editing the usda file to see if I could find a hack... but lucked out!

I haven't even seen an example of a usdz animating more than 1 character... so I'm in unchartered waters!

kcoley commented 6 years ago

@wave-electron this is odd. I was not able to get it to work on my end either. Everything seems to be authored as expected, so could be a limitation on iOS. Though you're right in that you're in unchartered waters!

To verify, I can see if this at least works in USD Maya importer.

wave-electron commented 6 years ago

@kcoley I also found other issues as well. I took Apple's animating sample of the skinnedMeshAnimation and added the usda snippet for animating the cube to the usda file with CarrotMan animating by itself. I found that even this kind of pairing of two animations wouldn't preview in IOS 12 but worked fine in xcode.

I also heard from one of the pixar guys that... there's a bug in iOS 12 that can't handle USD instancing.... I guess at this early stage.... support for usd on IOS 12 is still very much a work-in-progress!

Anyway I've attached the usda & usdz file for your own reference.

CarrotManWithBouncingCube.zip

wave-electron commented 6 years ago

@kcoley Apple has at least given a live demo of two characters animating in the same file. So this would make you think it may not like something about the structure of our usd file.

radaraardvark
wave-electron commented 6 years ago

@kcoley I've attached a usda & usdz of CarrotMan animating next to a stationary cube. In xcode the cube doesn't move - correct. In IOS 12 the cube is moving with the movements of the CarrotMan - wrong!

I've tested this on a number of other animating characters and same result, the stationary objects are moving with the bone animation. I tried for a few hours to find a solution but could n't. It could be an an IOS 12 bug, and without any Apple usdz assets to verify against its pretty hard to know either way!

carrotManWithMesh.zip

wave-electron commented 5 years ago

@kcoley I'm still playing around trying to get more than 1 bone animation working in the same file.

In my experimentation... I discovered that if you save a second mesh of the same character (without bones), this 2nd mesh will also animate exactly the same way as the first character animation with bones in the same file in IOS12, but if you upload the file in xcode it doesn't!

I've attached the usdz file.

bone_animation_combined_with2ndMesh.usdz.txt .

wave-electron commented 5 years ago

@kcoley I got it working on iOS 12! You need to combined the multiple characters in 1 mesh, with 1 uv_map. It will work with your command tool as is...so I'm going to close this issue now.

kcoley commented 5 years ago

@wave-electron nice, good to know!

wave-electron commented 5 years ago

@kcoley Here's a link to a working usdz file for future reference. To recap, you need to merge separate character meshes into a combined mesh. This requires rebinding the mesh & re-doing poses, keyframes etc. You also need to have a single uv_map for the combined characters. The problem with this of course, multiple bone animations source online resources will most likely not work with usdz without a lot of reworking :(

combined

combined bone animation

wave-electron commented 5 years ago

@kcoley BTW, if I haven't said it before.... awesome usd conversion tool. This is by the far the best tool for doing this right now. It took me a few weeks to work out the the workflow, but its super reliable now. If usdz takes off the popularity of this command tool will continue to grow!

kcoley commented 5 years ago

@wave-electron thanks for the reference model. I'll look into the best way to implement that. And thanks for all the help with this tool!

wave-electron commented 5 years ago

@kcoley I created a more complex animation today using the gltf2usd tool. This animation had two bone characters & a separate mesh which I did a transform animation (moving the cheese). I did have some troubles getting the usdz to preview, but eventually got a format out of Cheetah 3D which worked for usdz.

To get the file ready for gltf2usd I export as a DAE file from Cheetah 3D, then use Blender to export the DAE -> GLTF 2.

I built the whole model including keyframe animation inside Cheetah 3D (don't do anything in Blender other than export). I used the same uv map for both characters & piece cheese. usdz file here

However, I did need to split the mesh for the transform animation (moving cheese off the mouse trap).

I'm still haven't worked out exactly, what will & won't work for usdz... but seem to be getting closer to resolving that issue. There are issues with scaling from time to time, but I think that has more to do with Cheetah 3D than usdz or gltf2usd. I've at least found a few workarounds in Cheetah 3d which seems to fix that issue when it arises.

Here's the basic structure of the Cheetah3D bones, mesh & UV's.

help