Maxscript: Constrain to Biped 2.0 6


Two years ago, I wrote a post about a maxscript I had written that constrains a humanoid rig to the 3D Studio Max’s biped. Recently, I’ve been working on a fighitng game prototype. I’m using animations from an asset package for this, and though the animations are very nice, there are sometimes things missing or I wish I could make certain tweaks. I said to myself, “I wish there was a way to record these animations so I could edit them more easily.”

I know you can import a .fbx file, the format of the aforementioned animations, into 3DS Max, but every frame is keyed and making edits is rather difficult. I could try and use animation layers, but if I want to apply the animation to a different character, this can’t really be done either.

So, remembering the script I wrote awhile ago, I figured I would try and make a version, so I could record animations. At the same time, one issue with the previous script was that when using it, it forced the original rig to rotate so it would fit the biped. This would cause this strange “bulging” in various areas that some users, including myself, didn’t care for.

Before rigging [left] / After rigging [right]

Most of this is due to the fact that not all rigs are not perfectly aligned like the biped so when going from a rig’s t-pose to the biped’s, the rotation done to conform the rig to the biped results in some rotations that otherwise, the original rig wouldn’t utilize.

The New Script

Version 2.0

This new version has a few changes compared to the original:

  • The bone selection area has been separated into two columns for easier organization
  • The addition of a lot of new features and buttons
    • Quick Midpoint – creates a new midpoint between selected objects
    • Quick Connector – creates a new bone that connects two selected objects
    • Foot Angle Adjustment in Degrees: An angle, measured in degrees, used to more correctly size the created biped’s foot
    • Turn Figure Mode Off: A toggle button that turns figure mode on and off
    • Alignment Tools and Animation Recording, both of which will be explained later

How to Use

Preparing the Rig

So, like the original version, you start off by preparing the rig. You have to add make sure that all bones (besides the infamous bone #7) are assigned properly. This can be done using tools such as quick child.

Determining Foot Angle

One new value that should be assigned is Foot Angle Adjustment in Degrees. This value is used to determine how big to make the biped’s foot and when aligning the biped’s foot to the original rig’s, how much to rotate it back so it matches the original rig’s foot angle.

One way to determine this value is to go into rotation mode and the view coordinate system and select the original rig’s foot bone.

Here, my rotation values are -12.979, -0.169, and 172.337. The biped’s foot will always be rotated positively on its z axis, so for this rig, I would use 12.979 for this value. This can be a little trial and error unfortunately, but as long as this value isn’t changed after building the biped, the toes should stay aligned properly.

Building the Biped

Once all of the bones are assigned and the rig is validated, the biped can be built. You’ll notice that when doing so a “FAUX_RIG” is created as well as the creation of a bunch of dummy objects. These dummy objects are used to align the biped to your rig.

New biped and “faux rig”
Small spheres are also added to the top of the biped’s fingers to help indicate the “top” of the fingers better.

Aligning the Faux Rig

This, unfortunately, is probably the longest part of this new process. Using the Biped Alignment section, you set the index of the bone you want to edit. Then you click one of the rotate buttons. When time this button is clicked, it’ll realign the associated bone with the newly aligned faux dummy.

How a misaligned biped MAY appear depending on the rig.

Fortunately, every time you do a rotation, it is recorded so you can save it out and reload it at a later time or for new rigs that are similarly oriented.

You can also check the alignment by clicking Align Bone or Align All. Also thighs, calves, upper arms, and fore arms do not need to be aligned since aligning the biped’s hands and feet will automatically align these better.

Another note is that you should stay in figure mode when aligning the first spine bone, the clavicles, neck, head, toes, and fingers. This is because, while in figure mode, these items are all oriented AND positioned. Once out of figure mode, they will not be moveable.

Additional Alignment Notes

If you are doing this from scratch, you should note that the clavicles are rather difficult to rotate while in figure mode. They translate to the proper position but will not align properly, but once out of figure mode, they will. Additionally, because of this, I suggest putting a slight bend in both the original rig’s elbow if possible. Even if the clavicles are off a bit, if the hands can reach the original rig’s, they and the fingers will line up properly. This is also useful to do at the knees so after positioning the hands and feet, the rig’s knees and elbows can be positions correctly. If they are too straight, these sometimes will rotate incorrectly.

Aligned rig with slightly bent knees and elbows

Finishing the Rig

Once the rig is aligned properly and figure mode is exited, you can either create constraints, which will add orientation constraints and positions constraints to the original rig so they follow the biped OR record the character’s animation to the biped.

The Key Frame button will do just that, recording the pose of the original rig to the given frame. However, you can also record the entire animation. You can set an interval. An interval of 1 means it will records every frame. An interval of 2 means it will record every other frame, 3 every third, etc.

This process, unfortunately, is rather slow. A 100 frame animation can take almost 10 minutes if every frame is captured, but once finished, the biped’s new animation can be saved to a .bip file and applied or edited.

Final Notes and Areas of Improvement

This script, though usable, could probably use some improvements.

  • Sometimes the script will crash like if you, for example, try to rotate a faux transform without building it first; thus, requiring the user to close the window and rerun the script. Having more error-catching would probably be useful.
  • I think there is a memory leak somewhere; after using the script many times or opening and closing it several times, 3ds may sometimes crash when starting a new project.
  • The alignment process takes awhile in general; I wish there was an easier way to automate this. Fortunately, I’ve created a file for Character Creator 3 rigs that should align the rig properly and quickly after being loaded.
  • Recording animation can be slow.
  • Adding rig automation would be nice so the nubs don’t need to be added manually
  • Foot sizing and placement can still be rather troublesome

Updates

March 31, 2019 – Version 2.0.1

  • Added new button to quickly create nubs for the head, fingers, and feet, since these are usually missing.

Download

You can download the script here for free. If you use my script, credit would be nice but not necessary. Additionally, I would love to see what people do with it. Enjoy!


Leave a comment

Your email address will not be published. Required fields are marked *

6 thoughts on “Maxscript: Constrain to Biped 2.0

  • Brian Morris

    Hello,
    Your “Constrain to Biped” Maxscript is exactly what I have been looking for. I have an Daz Studio Genesis character that I need to animate in 3ds Max with Biped. Strangely I still need 3ds Max Biped even though I own the whole iClone 7, 3dXchange, CC3 pipeline suite, since the my character is walking up and down stairs for most of the scenes, and Biped footsteps seem to be the best way animate such things.

    I tried both ver 1.1.0 and ver 2.0.1 and got varying results. In the end v1.1.0 is working so far. Although in v1.1.0 there was some strange position offset of the biped hand and finger bones after adding animation keyframes. I was able to fix it by added and collapsing a biped animation layer.
    But in v2.0.1 I had to give up. I did like the better bone selection/match window, but aligning the bones was impossible. I was confused about the “index” number and which axis was x,y, or z. How do I know what index number to assign to the bone I select to rotate? In my case almost every bone was out of alignment and even starting at the hip/pelvis did not help much. Every time I assigned a index number it was a gamble if the correct bone would rotate.

    But thanks for the scripts. I would happily purchase such a script if it was a tiny bit more staple and there was a bit more documentation (mostly on the index number).
    TIP: The videos could be much more helpful if you lose the music and give some step by step narration (I make a lot of video tutorials myself :-)).

    Thanks again and keep up the good work!
    Brian

    • mattrified Post author

      Hey Brian,
      Thanks for the feedback. Some responses:

      How do I know what index number to assign to the bone I select to rotate?

      The bones are ordered in the columns. The first column is 1 through 35 and the second column is 36 to 67. I see the issue you are referring to though; adding numbers to the columns would help a lot.

      In my case almost every bone was out of alignment and even starting at the hip/pelvis did not help much. Every time I assigned a index number it was a gamble if the correct bone would rotate.

      That is an unfortunately accurate description of the rotation process. Because rigs can be so different between models, it feels like a guessing game to get the alignment right. Now, one thing to note is that you can hit rotations multiple times in a row. Sometimes I found I’d have to rotate like twice on the Y at -90 and once on the Z at 90, things like that. The text file included has an example of different rotation patterns for a CC3 model. If you want, I can generate a rotation file for the genesis character.

      TIP: The videos could be much more helpful if you lose the music and give some step by step narration (I make a lot of video tutorials myself :-)).

      You say that, until you hear my voice, 😛 But seriously, sounds like something that could be useful for people, but a lack of an instructional tutorial is also why it’s free. I’ll think about it.

      Thanks again for the feedback. This will help a lot with future updates.

      • Brian Morris

        Thanks for the reply,
        Okay, I got the Index number info, that makes since.
        If it’s an easy thing to generate a rotation file for the genesis character it would for sure be useful, but for now v 1.1.0 worked and I am currently animated the character in biped. I do have students that sometimes need to animated Daz characters in 3ds max, and I will for sure use it again, so sure any rotation files would be helpful.

        Thank you again for the script it was very helpful.
        Brian

        • mattrified Post author

          You’re welcome. I’m glad I’m people are getting some use out of it. If you send me a Genesis char, I can probably generate a rotation file, but I do not have a Daz license at this time. You can email support@mattrifiedgames.com, and I’ll see what I can do.

          • Brian Morris

            Yes, I can send you the Daz Genesis character, but not sure which version I should send since there is are 4 releases, from Genesis 1, Genesis 2 ,Genesis 3, and the newest Genesis 8. Also what format should I send you FBXs ?
            By the way Daz Studio and all the base characters are free (and there is no “paid” Pro Version like in the past) the license is just a standard free Daz account.
            Brian

          • mattrified Post author

            FBX is fine, and I would say send whichever version you think is used the most.