Home Technical Talk

3DS Max - Convert geometry to bone for XNA or "flattening" animation to child

polycounter lvl 13
Offline / Send Message
Wesley polycounter lvl 13
Hey folks, got a small problem with some animations for a project we're working on. As it is now, we've got a few guns comprised of 80 odd separate parts, most of which animate using regular Max key-framing. We then used bones and skin modifiers for certain objects such as springs. The problem we're having is that in XNA it won't enable both regular Max key-framing and skinning using FBXs.

So a couple of solutions I've thought of included duplicating each object, converting it to a bone using the "Bone On" checker in Bone Tools and then adding a skin modifier to the original object and adding the duplicate as a bone. This will allow me to have a skinned object using a bone that has it's original animation.

Sounds kind of long winded I know, but it'd be easy to script and for the time spent on re-animating would be great. however, the only problem with this is that in XNA the new bone itself gives an error saying it has no skinning information. So it's obviously not acting like a "real" bone in XNA. I don't know how to get around this, is there a different way to convert geometry to a bone?

The only other thing I could think of is to create a bone for each object, link that bone to the object, and somehow copy the animation from the object to its' child. I don't know if that's even possible in Max (I don't do much animation). Then I'd be able to delete the original animation for the object, apple a skin and then add the bone.

Replies

  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Em.. yea if you have to go for the last option there then you could definitely "bake" the animation onto your joints.

    Just make a script that steps through each frame on the timeline, samples the position/rotation of the source object at that time and sets the position/rotation of the bone to match.

    Otherwise if you don't mind a manual step or two you can do this with max's XAF animation exporter (file > export animation) using the "key per frame" option. On import it'll let you make a remapping between the objects you exported from and the new export hierarchy in case the joint names need to be different or whatever.

    the xaf import/export process can also be scripted once you have a process worked out if that makes it easier (i.e. if you're going to be doing this for every animation throughout your project)

    Hope that helps a bit
  • Wesley
    Options
    Offline / Send Message
    Wesley polycounter lvl 13
    Hey cheers for the help Warheart, I've created a simple little script that creates a bone and then copies the animation for the frames. The only problem I'm having is that I don't know how to get MAXScript to check if a keyframe has been created for the object , and then copy just that frame. Right now it's just copying the position of the pbject for every frame.

    I swore I'd seen some kind of nextKey function or something in MAXScript but now I can't find it. Any ideas?

    Cheers for the help.

    EDIT: I was closer than I thought, just found the getNextKeyTime function!

    Double edit: Ok, so I just found the controller type, all is sorted. Thanks for the help again.
  • frankrs
    Options
    Offline / Send Message
    If you want to save yourself the hassle of writing a baking animation script yourself, there's a website scriptspot with dozens of scripts that do just that.
Sign In or Register to comment.