kcoley / gltf2usd

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

Scale wrong - when using keyframes in GLTF file #73

Closed wave-electron closed 5 years ago

wave-electron commented 5 years ago

@kcoley I'm currently chasing another bug relating to scaling after adding keyframes to the GLTF. What you may not have picked up on the cubeBounce example I posted yesterday. The floor scale was not correct relative to the 3 cubes for the usdz version (that was because it was not key-framed).

So in a nutshell, whenever you keyframe a mesh, that key-framed mesh changes its scale, and it is not correct. The attached files is the same file, 1 without keyframing - the scale is correct. 2 with key framing the scale is wrong. If we can fix this issue, we might finally solve the issue with multiple animations getting out of whack. cubeBounce_scale_issue_with_keyframing.zip

wave-electron commented 5 years ago

@kcoley Just to be clear. This is how the scene is constructed flat hierarchy in Cheetah 3D. In the first file, I have no key-framing against any of the mesh, in the second file I keyframe each mesh, but don't actually move the mesh. I merely keyframe the start and end over a 4 second period. I purely studying the effect of no keyframes versus keyframes. Does that make sense?

screen shot 2018-10-09 at 4 02 26 pm
wave-electron commented 5 years ago

@kcoley This is what the preview in usdz looks like, the file has no keyframing and its scale exactly the same way as the GLTF file.

img_1813

After just keyframing each mesh of the GLTF file, they all become spread apart by a factor of something. They are so small the cubes and floor you can hardly see them!

img_1812

wave-electron commented 5 years ago

@kcoley Ok, I just manually edited the usda file with keyframing and removed everything related to scaling in the timeSamples and it fixed the scaling issue. Not surprising I know, but I just wanted to confirm that scaling is the culprit.

 float3 xformOp:scale:scale.timeSamples = {
            0: (0.01, 0.01, 0.01),

cubeBounce_with_keyframing_edited.usda.txt

kcoley commented 5 years ago

I think this is related to https://github.com/kcoley/gltf2usd/issues/76 as well

kcoley commented 5 years ago

@wave-electron just merged a fix for this https://github.com/kcoley/gltf2usd/pull/83