0

Have a usdz file with the typical one character and one animation.

    let p = Bundle.main.url(forResource: "Sitting Laughing", withExtension: "usdz")!
    let amyAsset = MDLAsset(url: p)
    amyAsset.loadTextures()
    let amy = SCNNode(mdlObject: amyAsset.object(at: 0))
    .. your node .. .addChildNode(amy)

You can now see "amy" perfectly in your scene.

If you try this, notice there are NO keys:

    for k in amy.animationKeys { print("keys? \(k)") }

however try this with the asset,

    for ob in amyAsset.animations.objects { print("ob \(ob)") }

And you'll see the MDLPackedJointAnimation for example

<<MDLPackedJointAnimation: 0x7ff7b0e18830>, Name: /High_Jump/mixamorig_Hips/Skeleton/Animation, Children: 0>

Alternately, say,

    let pjs = amyAsset.animations.objects.compactMap { $0 as? MDLPackedJointAnimation }
    for pj in pjs {
        print("... \(pj.name)")
    }

for the same info.

The "name" will look like /High_Jump/mixamorig_Hips/Skeleton/Animation

From there how the heck do you play that MDLPackedJointAnimation ???

I've tried everything and cannot :/

Fattie
  • 27,874
  • 70
  • 431
  • 719
  • do you involve any DAE files in your animation? – ZAY Jan 11 '23 at 20:51
  • is your goal to animate a Mixamo character? – ZAY Jan 11 '23 at 20:58
  • @ZAY exactly correct, mixamo. I am happy to use a dae file instead (and I'm, trying that as well, but it's definitley a bit weird). Using usdz (as above) you can indeed get the animation (well, the `MDLPackedJointAnimation`) I just can't figure out how the hell to (I assume) mak ethat a CAAnimation and then play it on the node ... :/ – Fattie Jan 11 '23 at 21:25
  • I made a question! @ZAY It seems totally impossible to simply get a Mixamo dae file to animate, in, a SceneKit scene :/ https://stackoverflow.com/questions/75090481 – Fattie Jan 12 '23 at 00:50

1 Answers1

0

It seems to be the case that the MDLPackedJointAnimation is a low-level representation of the animation(s) of the joints.

It's only possible to "play" a packed joint animation in the sense of completely manually animating it yourself using a display link and so on.

Article which touches on that:

https://medium.com/@warrenm/thirty-days-of-metal-day-28-skinning-690fe46785c9

It seems that MDLPackedJointAnimation is completely unrelated to the CAAnimation concepts in iOS, that is to say, there is no "command" or way whatsoever to "just play" a MDLPackedJointAnimation set of information.

Fattie
  • 27,874
  • 70
  • 431
  • 719