Home Technical Talk

rendering physics from keyframe animation with constraint

polycounter lvl 8
Offline / Send Message
Olli. polycounter lvl 8
lets say ive got a simple keyframe animation on object A. now what I want to do is attach object B to it with a hinge, and have the new object (B) swing realistically, as the parent objects (A) animation plays.

ive tried using reactors but i havnt worked with them before so im having trouble figuring out how to get the attached object to move along with the parent object and swing as it should.

Replies

  • Mark Dygert
    Options
    Offline / Send Message
    Is it for real time games or just a personal project in max?

    There are a few ways I can think of to do this in max. You could:

    1)
    Link B to A and assign a spring controller to B. It will jiggle a bit when the parent moves and take a while to settle in after it stops. This really won't work for real time unless the engine has some kind of jiggle bone set up.

    2)
    Use a strip of low poly cloth, skinned to Object A with a falloff group that transitions from skin weighting to cloth sim. Then attachment constrain points to the cloth so the points follow along and snap/key your bones to the cloth.
    Jim Jagger has a Animated Align script that works great for aligning and keying one object to another.
  • Olli.
    Options
    Offline / Send Message
    Olli. polycounter lvl 8
    what im trying to do is bake movement for some physical attachments to weapons ive made for a game. the animations are pre-made using a gun mesh physiqued to dummies. The idea is that i would render the physical interaction for the attachments on the gun (like straps, clips etc) based on the animations i made previously, then grab the new rendered animation, transfer it over to some dummies, rig a static version of the attachments to the dummies and export the animation so the engine can read it properly.

    option 1 doesnt seem like it would work very well, since the motions im talking about can be quite complex, and in any case i wont be able to rig the jiggle stuff in the engine anyway.

    option 2 sounds promising but i have no idea how to do all that.. could you explain in more detail perhaps?
  • Mark Dygert
    Options
    Offline / Send Message
    Olli. wrote: »
    option 2 sounds promising but i have no idea how to do all that.. could you explain in more detail perhaps?
    Something like this?

    http://www.polycount.com/forum/showthread.php?p=1021761#post1021761
  • Olli.
    Options
    Offline / Send Message
    Olli. polycounter lvl 8
    just to clarify, this is a picture of what im doing
    attachment.PNG

    and yes, Mark, that should be enough to get me started. Thanks.
  • Mark Dygert
    Options
    Offline / Send Message
    I don't think that cloth solution will work very well for that, it seems a bit more mechanical than organic like cloth. It's a lot more simple than I was thinking. I thought you had a gun strap or something more complex.

    I would actually look into using MassFX and the MassFX Constraint Helper. I believe it actually bakes out to keys also.

    The 3dsmax help file has a How-To if you search for "MassFX Constraint".
  • monster
    Options
    Offline / Send Message
    monster polycounter
    He mentioned Reactor, so he may not have MassFX Physics.

    Here is a quick hinge tutorial for Reactor:

    Completed Example File:
    http://dl.dropbox.com/u/2904948/Tutorials/ReactorHinge01.max

    Create the Hinge:
    1. Parent object b to object a.
    2. Change the pivot on object b so that rotating the Z axis gives the effect you want.
    3. Hold ALT + Shift and Right click for the reactor menu.
    4. Select Hinge Constraint and click on the ground near your objects.
    5. Select the Hinge object and in the modify panel set object B as the Child.
    6. Check the Parent option and set object A as the parent.
    7. Click on Child Space and Child Body.
    8. Don't worry about the Min and Max Angles, the collisions will take care of that.

    Create the Hinge Solver:
    1. Hold ALT + Shift and Right click for the reactor menu.
    2. Click on Constraint Solver and click on the ground near the objects to create one.
    3. Select the Solver and in the modify panel click on Pick and select the Hinge.
    4. Select object a and b
    5. Hold ALT + Shift and Right click for the reactor menu.
    6. Click on Rigid Body Colection, the selected objects will be added automatically.
    7. Select the Solver and in the modify panel set the RB Collection as the Rigid Body Collection object.

    Create the Rigid Body Collection:
    1. Open the Reactor right click menu and click on Open Property Editor
    2. Select object A, and in the Property Editor check Unyielding and set Shell to 0.
    3. (This means it's a hand keyed object that influences physics)
    4. Select object B and give it mass.
    5. (Doesn't matter how much, unless it hits other objects.)
    6. Also and set Shell to 0.

    Preview and Bake:
    1. Go to the utility panel and open the Reactor utility.
    2. Click on Preview animation.
    3. You can edit the Timing setting and preview again.
    4. If everything is cool you can click on Create Animation to bake.
  • Olli.
    Options
    Offline / Send Message
    Olli. polycounter lvl 8
    wow thanks that example file is neat, exactly what i was looking for :D
    and also, im using max 2011 and i beleive massFX was only in 2012.. so no i dont have that (yet)

    is it possible to achieve rotation on multiple axes with these hinge things?
  • monster
    Options
    Offline / Send Message
    monster polycounter
    To rotate on multiple axis, it's very similar, but use a Point-Point Constraint instead of a hinge constraint.
Sign In or Register to comment.