Mocap Madness

Here is a bvh importer I’ve been playing around with. Works in rev34992

Some features.

  • Rotate 90 to have z up
  • Import All mocaps in a folder
  • Import the action only
  • Change rest pose to the pose in first frame (Iffy)
  • Set common starting point… this enables me to top and tail
  • Scale and Rotation type

There is a work in progress mocap player to allow you to change the bvh easily and play… and an attempt to show the motion_path of the hip. Imported a few bvh’s from the mb2 conversion of the cmu database…

There is an object constrained to the hip which should allow the rig object to copy its rotation locaton to start next mocap to “chain them” together… hmmm meant to put in a turning bvh oh well…

Very much still a wip.

Python script is in the attached file.

Cool script - I’ll try it out with bvh from kinect I get from this script.

http://translate.google.com/translate?hl=en&sl=ja&tl=en&u=http://actinia-software.com/actinia_software_download.html&rurl=translate.google.com

Cool script; hope you’ll keep working on it!

(and telredge, maybe check out Brekel’s package for kinect -> bvh – www.brekel.com/?page_id=155 – seems like I’ve gotten better results with it vs. the Actinia utility)

Great work mate, i hope you continue with it

Here is an updated version that works for bvh’s with translations on all bones… like the tennis one sent to me by jor1980. Also added the keep timing from mocap file to the UI on the filebrowser.

Attached is the latest with a few minor changes.

Options explained

  • Load all in directory, this will load the first bvh with rig and all other bvh’s in directory as actions
  • Discard Rig on Import… load only as an action.
  • Rotation Mode … select the rotation mode of the bones
  • Scale: scale the original mocaps down by this factor… they are ofen huge so 0.1 has been chosen as default
  • TPose rest pose… make the pose in first frame the rest position… useful for bvh’s that have a Tpose in frame 1
  • Use timing from bvh : The bvh data has a frame length value, this emulates it wrt your scene frame rate.
  • Travel origin. Make the mocap start from (0,0) in its floor plane. Makes it easy to reposition.
  • Only rootbone rotations: Some mocaps don’t rely on the location of the pose bones apart from the root bone. Check this frame to ignore them and reducer overhead. LOL whoops i might rename this to Only root bone locations… makes sense…

Coming soon pose matching to find cycles within and branches to other mocaps… http://blenderartists.org/forum/showthread.php?t=201799

Exciting progress, batfinger! <dance emoticon needed>

Should I still be able to see the mocap madness player in the T-menu when loading the new blend?

Hi snowglobe,

thanks for the feedback… No I didn’t add the player to the latest examples… it’s undergoing an upgrade to allow for branches/cycles etc… If you wish to use it copy the script from the one that does have it, open a new text window change name Text to playmocap.py paste and run the script. Select the register checkbox if you want it to run when the file is loaded. Tis a pretty handy little script.

batFINGER,
Are you going to add re-targeting of bvh as well ? (meaning, reassigning animation to other sets of armatures) or is it already done?

Yeah, great little script. Are you planning to ultimately merge it in as a complete package with the importing functions?

I did go ahead and copy the playmocap script into the new blend, and it seemed to be incompatible somehow - player controls disappeared after doing an import. No worries though - I’ll watch for your next release, and help with bughunting then, if you like.

Hey snowglobe

working on ironing out a couple of bugs right now ( a big if statement feck up) … and am about to work on the playmocap bit to add the hip locator. I’m very keen to get the cycle branching stuff happening… getting some nice results in testing… I’ve got a map of the complete chapter 16 of the CMU at differing accuracies as to where to cycle / branch using the playmocap panel and NLA to create and visualize the path as you go.

Yes ultimately I’ll make it an add on that will load all the panels / operators… but for now i’m happy to plod along bit by bit.

Any help is always most appreciated.

PS … just noticed … for the playmocap to poll (show the panel when selected) it needs a custom property on the rig object named “MocapMadness” … You can add it manually using the custom properties panel on the object properties panel.

Excellent to hear it confirmed!

Cool - I’ll check that out later this evening, probably - thanks!

Where can I download the addon or the script? Would love to try it, but I didn’t see any attachments in your post… Thanks!

This is very much a WIP…and a “proof of concept” I’ve changed directions many times resulting in spaghetti coding… good, bad and mostly ugly… Rather than re target the actions to your character rig, I’ve had more success with driving a character rig with the bvh armature.

I’ll upload a zip file. (Remove the .blend extension) Ok for 2.59 use Move the MocapMadness folder into your addons folder. I’ve also included a folder CMU motions converted to 20fps using bvhacker to test with.


To import a bvh, go to the import menu and select Mocap Madness.
Options:

  • Dismiss Dialog, uncheck this if you want to return here and import another
  • Target Rig… not wired up yet… more on this later.
  • TPose rest pose… will convet the pose in first frame to a rest pose… doesn’t always work
  • rot90 makes it z up
  • action only: delete the rig created.
  • All in directory: load all the bvh files in the directory.
  • Use timing … make the timing match that of the mocap frametime.
  • Travel origin: start the animation from origin
  • Only root bone locations: don’t key in the locations for non root bones… saves overhead

For the sample file I moved 16_35.bvh to another folder. I imported it with MM using dismiss dialog off and actions only off. Now i have an armature and one action. I then checked all in directory, changed to testMM , made it actions only and imported all in the folder.

Ok onto the next step.

Attachments

MocapMadness.zip.blend (369 KB)MocapMadness2.59.zip.blend (369 KB)

… continued.

Now in the 3d screen select the armature and have the properties panel open “n”. You can change the actions here.


Cleaning the actions.

Go to the graph editor and press n for properties. You will see the poorly named “clean fcurves” This brings up a menu. You can select to preclean with a tolerance, presmooth (not recommended unless you wanna turn the animations into skating) , resample … this will put the keyframes on integer frames, and post clean.

For the sample I chose preclean and resample.



resulting in.

This step can be skipped. My suggestion is save first then check out how the animations look. The undo is horrible seeing as i have used multiple operators.


Ok onto pose matching. MM will now run thru all the actions and check for matching poses from the hip down. The parameters are

  • fcurve difference: an addative tolerance in radians … as it checks thru the bones it sums the rotation difference in radians. If this gets above the tolerance set it goes to next action. I find around 3 gives good results for CMU rig.
  • Max euler rot diff in degrees: skip if any difference greater per bone
  • Check actions every “framestep” frames
  • Make cycles at least “cycle length”
  • background run… run as a thread… my athlon pussbox falls over at the mention of multithreading in blender.
  • run it … go have a cuppa …

Ok you now have a list of cycles within an action that can be repeated, and branches to other actions. The number of matches are displayed on the panel.

And now for the madness.

Goto the NLA editor and press N for properties and select your rig. Selecting from the NLA editor is preferable

Select the animation you want to begin with and have the timeline at the frame from which you wish to start… To add that track to the NLA click add new. Scrub the strip and if there is a branch or cycle it will show up on the panel. The button label will be "branch to actionname xx (yy) where xx is the frame to branch into and yy is the value of the match. The lower the better.

Cycles are much the same . choose the amount of repeats you want.

You can now use the mocaps to piece together a longer animation. There can be a jerkyness at the merge, this is mainly due to the rotation difference of the hip (root) bone. For instance it may be the same running pose but leaning right or left. Putting some corrective keys in the rigtrack to soften this is part of the next step.