Blender Wokflow: Using motioncapture files for character animation

This post is related to the discovery of the CMU’s motioncapture libaray announced here.

The aim of this post is to figure out how to prepare those data for usage within jme.

Basixs an me, who are kind of working on characteranimation currently, will talk about the “how to” in blender…

…hopefully we’ll get a step by step tutorial out of this progress.

If anybody is well versed in blender, characteranimation, or other related topics please join this discussion.  :slight_smile:



********** UpdateSection ***********



Current Achievements:



Tool to modify animations, alter bone names, reset restpost within a .bvh file -> BVHacker

Some information onto the first steps could be found on the homepage. i found it kind of strange, but had a quick look only



2 Approaches on how to get the imported animation onto your characters mesh (directly, by Puppeteering)

Btw, although I'm still somewhat of a noob at this, that's really cool data (at least for bipeds :slight_smile: ).  Great find!  What would be the goal in jME, to be able to load the data via some importer and then attach it to a mesh?

No, the primary goal is to use the data in a modelling tool like blender, 3dsMax for animation of a character. After this is done, you can easily export the animated character to .md5, .md2, .ogerXML which are all capable of storing animationdata (mesh, bones, vertexweights, animationkeys).



Then you can import the character into jme and play the animation. This is the default procedure in gamedevelopment, i guess. As long as you dont have a physics-space and want the characters motion to be affected by shockwaves, bullet-hits or whatever.

Therefor commonly a so called ragdoll is used, where you can use the just the bone and vertexweights information and move the bones manually/programmatically (e.g. by physics effects)

An exaple of this can be seen here

Regards to .:emp…HellG:.  :mrgreen:



peace und lange haare!

Just wanted to post what I have gotten done so far (the mesh animation is kind of ugly, since I was concentrating more on the skeleton and getting it to export/import correctly).



Marine_WalkCycle.zip



In the archive is the bvh walk cycle I created with BVHHacker, also there is the original mesh (and texture) as well as the blend project and the final product (MD5 model).



I think just what I have done so far is a nice start to a wiki article, maybe a 2 parter with better vertex weighting being the second part…

this second post may be more useful





HERE

Skunk wrote:
I  written a Script that import Bvh-motion directly to a Armature.
Armature setup is also done atomatically.
the script is a mod of the classical Bvh script in the blender scripts bundle.

The script is in that way composed:

1.little introduction to the source.
2.The Bvh Import script himself with the Armature setup and so on.
3.A BVH file at the end of the script(cut out that part and edit it in Spe
or something like that.safe it import it.test it.)What i need to know is
where this file istaken from(from which package).My importer works
only properly on this files.The BVH to Emptys is allways correct(it is
simply Ideasmans sccipt modded but for the correct bvh toArmature the
orientation of the importing skelleton struucture muast be the same like
in that file.Actually it works absolut correctly on 84 files.
All combat motions but from which package.
4.I

could this be of any use HERE I’m planning on trying it tonight before I rig my character.


jbperin;383623 wrote:
Hi everybody,

Here's a new release of my script which build an armature upon a heap of empties (like the one we get after a bvh import).

You can download it here

How to use this script:
==============

- Open a text editor with the script  in it.
- Import a BVH file into Blender (File-> Import-> BVH)
(Here, you can adapt the empties' rotation to fit your model. For instance, rotate shoulder empty 90 degrees so that arms are horizontal)
- Run the script (Alt-P)
- A GUI appears:
   StartFrame : the first frame of your anim
   EndFrame : the last frame of your anim
   FrameDecimation : the number of frame to skip between two action key
   Scale : use it to size your armature
- Press Create Armature

The armature is created

You can parent your model to the armature


Now, if you want to play an other BVH without losing your vertex assignment .. you can  apply  a new bvh to the same armature by following the procedure:

- Remove all the empties created during first import
- Import a new bvh (it must have the same structure than the previous one)
- Run the script again (with the same scale parameter)

If the joint's name are the same between both bvh .. the armature should play the second bvh ..


I've used imported motions into a game blender .. it works ..
It is also possible to make an armature play several BVH, one after the other, into a single anim by using strip NLA editor.

Please .. send me comments, questions and remarks


thanks to D.Lomas for frame decimation idea.
thanks to LOD for Beta testing, encouraging, and being so smart.
thanks to JMS for bringing us light.

Jean-Baptiste PERIN

Have fun !!!! 
;)

NB: the created armature is unparented .. I've made a script that build a parented armature on a single frame. it allows the users to swap between bvh animated armature and hand made animation. Feel free to e-mail me if you're interested in getting this script. (it doesn't yet deserve to be posted here)

jbperin;519284 wrote:
A new release for Blender 2.4x is available here

compared to 2.37 BVH2ARM script .. this one may appear to be a big regression .. because armature's bones  no longer follow bvh animated empties.

Due the a major rewriting of Python Armature API, I can't find a way to animate bones .. so this script only build a parented armature at rest pos..
and make this armature follow the hip bone empty created bu the BVH import script

Fortunatly .. thanks to Blender new IKSolver .. user can easily get the created armature moving by :
- putting proper IKSolver constraint on end effector bones (such as hands and feet)
- putting rotation limit on bones.

I'm currently making a more comprehensive tutorial on that topic ..
It will soon be available in the archive of BVH2ARM

Currently, the html doc included into the archive is just a too short tutorial.

Remark: BVH2ARM  is now released under GPL Licence

Jean-Baptiste



hm, i dunno if you took a look onto the newest version of blender, but it seems to me, that those scripts are allready included. Because if you import a .bvh into blender you get the choice of importing it as empties or armature.

Importing it as armature it seems to be exactly what the script is for.

You get an armature from the .bvh with the motions applied allready.



The problem of this thread is more about appling this imported armature/motion to an character. Of course you can apply the imported armature directly to your characters mesh, but then you have to edit the vertexweights for every motion you import by .bvh over and over again.

So it might be more usefull to have an armature with correct vertexweights applied to your character before you import the .bvh. And then just tell the characters armature to follow the movement of the imported one.

This way it might be easier/faster to use different .bvh motions on the same mesh.

.:emp...imm0|82:. said:

The problem of this thread is more about appling this imported armature/motion to an character. Of course you can apply the imported armature directly to your characters mesh, but then you have to edit the vertexweights for every motion you import by .bvh over and over again.
So it might be more usefull to have an armature with correct vertexweights applied to your character before you import the .bvh. And then just tell the characters armature to follow the movement of the imported one.
This way it might be easier/faster to use different .bvh motions on the same mesh.


hmm ahh yes i've never realized that import option before =p

hmm well as jbperin logically if the joint names are the same they won't have an issue playing the second .bvh file. and for switching out to keep it simple why not simply use Bone Heat Weighting and dual quanternions if u change the rig around to the pose of your character and make the character spread out enough it seems to work everytime at least with the .bvh files i tried anyway or is their an issue you see with it that I've not seen?
hmm well as jbperin logically if the joint names are the same they won't have an issue playing the second .bvh file.

ok, in this case i would agree. but only "if" the bone names are the same in every .bvh file. And if there is the same number of bones in the .bvh files.

and for switching out to keep it simple why not simply use Bone Heat Weighting and dual quanternions if u change the rig around to the pose of your character and make the character spread out enough it seems to work everytime at least with the .bvh files i tried

well, here it seems that you are more into blender then i am ;)
i've seen the "vertex weight from bone heat" option, but in my tests that had not the "perfect" results i'm expecting.
I dunno what you mean by the "dual quaternions"..

change the rig around to the pose of your character
This is a problem for me as well. As i understand it, you mean the procedure of changing the "rest pose" of the imported armature to match your characters mesh.
In my tests, as i scaled and/or rotated the bones of the imported armature in the restpose, the motions were totally ruined..
..have you experianced this as well?
How do you do it?
.:emp...imm0|82:. said:

well, here it seems that you are more into blender then i am ;)
i've seen the "vertex weight from bone heat" option, but in my tests that had not the "perfect" results i'm expecting.
I dunno what you mean by the "dual quaternions"..

This is a problem for me as well. As i understand it, you mean the procedure of changing the "rest pose" of the imported armature to match your characters mesh.
In my tests, as i scaled and/or rotated the bones of the imported armature in the restpose, the motions were totally ruined..
..have you experianced this as well?
How do you do it?


well actually srry i meant the other way around its not as hard as it seems to deform the mesh to that of the armatures though armatures definitly makes deformations easier lol

according to aligorith
Heat weighting works by determining the distance between the bones and the vertices in your model. Problems arise when certain parts of the model are so close to other "separate" parts (i.e. an example would be a model, whose thumbs intersect the thighs) that the computer considers all of the points in the vicinity of a given bone (i.e. thumb bones will be considered to be closer to both the verts defining the thumb AND the thigh) as belonging to the bone.


I'm by far not a skilled blender artist just I've been attempting to create a TPS for a while and have been thrawted by my inability to find a dedicated 3d graphical artist at least i have plenty of conceptual artist -_-
In my tests, as i scaled and/or rotated the bones of the imported armature in the restpose, the motions were totally ruined..

SMALL adjustments are possible but cannot 're-pose' the rest position.  Must repose the mesh...

Centering and removing the X/Z translations just requires maniplating the IPO curve data on the Pose node (Select Animation from "DataBlock" drop down on ToolBar).

Found easy way to 'tweak' armature, just slide the quaternion variable in the IPO data for the bone you want to tweak.



(Go into animation mode, put armature in Pose mode, then select the bone you want; now in the IPO curve editor just grab the curve you want (trial and error) and slide it.) :slight_smile:

ok, i spent the day again on this, and found a quite propper way. Basically its real “puppeteering”, which means that you have your character (allready with bones and vertexweights) on the one hand, and you have the imported and animated armature from the.bvh file on the other hand.



What you are doing then is to tell your character’s armature to follow the movements of the .bvh’s animation.

Therefore you add IK-Solver-/Copy Rotation-/ and copyPosition Constraints to your character’s armature, with the .bvh bones as targets.

I found a basic tutorial about this on BlenderUnderground.

It describes the basic approach quite well, and i got some quite good result with it.



Now we’ve got the point where there are 2 approaches:

  1. Applying the .bvh’s armature to the character’s mesh directly and weightpaint it. (Tutorial)
  2. Create your character, add an armature and vertexweights to it, then import a .bvh and connect the character’s armature with the imported one. (Tutorial)



    Thoughts on both approaches:



    1.)

    -ok, it works so far; small problems by tweaking the armature’s rest position. So you have to edit you mesh to match the restposition. Here i had some problems, because the proportions of the imported armature don’t match my character ones. And to squeeze or stretch e.g. the width of the shoulders isn’t that cool.

    -what if i would like to create a set of animations for my character? lets say i would like to have a walk, jump, and wave animation. If I’m not able to create one single .bvh (with bvHacker?!) which contains all 3 animations in a row, i would have to walk through the workflow (connect to armature, weightpaint, tweaks) 3 times.

    -Could this be prevented by using the same names (which definitely can be altered in bvHacker as well as in blender itself) for the imported bones, and the creation of correctly named vertexgroups on the mesh before importing the .bvh?  So that i could easily just adapt the existing vertexgroups for the next imported animation?hope this gets clear :wink:



    2.)

    -The idea is fine, the results “so far” as well. I have some problems with some rotations (e.g. hands in the case of the tutorial)

    -I guess it saves time to have to apply an armature to the model and weightpaint it only once.

    -I have not tested it with the case of different proportions of mesh and .bvh armature.

    -But it should definitely be possible to reuse the applied constraints, if the names of the imported bones are equal. But i haven’t tested this too, yet.







    But I’ve tested the md5 export from blender and the import into jme, which works fine so far.







    And I’ve made the first post of this thread as an “Achievements Overview” which i will update “quite” frequently.



    greetz

Weehhaa…

Proof of concept. Puppeteering works!

So i import one of the CMU-Mocaps.

I delete the whole animation stuff (delete keys in IPO-Editor for each bone) to get a "pure" Armature, with the same amount of bones and the same bonenames. Although this is not that important (you could do it with your own armature as well) i chose this, because all of the CMU-Data (as far as i have inspected it) have the same amount of bones and the same names. So its quite easy to get familiar with it.



Ok, then i apply this pure Armature to my charactermesh. I edit the bones to match the proportions, and do the weightpaints. Then i have a rigged character "ready to use".



Afterwards i follow the steps, which are explained in the "puppeteering tutorial". So i import a .bvh again, and connect the character's bones to the imported armature by adding the different constraints.

As the result my character moves corresponding to the .bvh animation.



If this is setup once, i'm able to delete the current .bvh-armature and import another one. The constraints of my characterbones are stored, at least their settings. So the only thing i have to do is to fill in the "Target names" in the constraints again. Which, if you know the names of the bones, takes about 2.5 minutes. Afterwards you have your character setup to the new animation.



This was just a proof of concept test, so i haven't done a perfect vertexweighting and stuff, but anyway, it works fine!

I'm looking really forward to your project, because it's my greatest hope for a nice animation!!

Keep your good work!!! XD

use 3dsMax, it's bipeds and its "stay in position" mode and you get nice animations within a few hours…

The problem is the tool of this topic :wink:

Very interesting, can't wait to try this once my artist gets done with modeling.  :smiley:

OK, after a lot of research and testing as well as some try'n'error…



I wasn't able to export the puppeteering stuff, because by using the constraints, you don't get keyframes onto your own armature. It just follows the original one… but without keyframes it's impossible to export the animation… so this is kind of dead end.



But i figured out that you are able to use the "actions" - which get imported by the .bvh - on another armature quite easy.

As i said, I'm a total blender noob, and in the tutorial the workflow uses the imported armature and the character mesh is skinned onto it. I thought that doing this for every imported .bvh is pain in the ass. And you don't have to do it for every .bvh! You can simply apply the actions onto your character's rig!



And this is quite easy.


  1. Create your character mesh.
  2. Use a imported -bvh-armature, or create your own with the same # of bones and the same boneNames.
  3. Parent the mesh to the armature (armature in Restpose, mesh matches the restpose, STRG-P) and select by boneHeat to get some first rough vertexweights.
  4. Alter your vertexweights by altering the vertexes in the vertexgroups or weightpainting the mesh.
  5. done!


  6. then import an .bvh of your choice. this makes a new action available in the "ActionEditor". Delete the imported armature, so that only your character and it's armature is in the scene.
  7. select your own armature and change to "ActionEditor".
  8. select the new action from 2nd dropdownlist (from the left)

    –> then your characters armature has the newly imported .bvh-motion

    And you can export it to MD5.



    But there are still some Problems to fix:



    For example - If the shoulders are to narrow for your character, so that your characters upperArms move through the chest-mesh, you are able to fix this afterwards in the IPO-Curve-Editor. Select the upperArm bone in "PoseMode", switch to the IPO-Curve-Editor (set it into posemode as well) and alter the curve, which is responsible for "how tight" the ellbow is to the chest.



    To keep the animation in place just delete the whole locationZ-curve for the hip-bone (RootBone).



    Another problem I'm facing is, that the motions of the .bvh files are kind of shaky… especially the toes and the neck.

    This can be reduced a bit by smoothing the IPO-Curves (select a corresponding, Shift-O).

    But anyway…if I export it to MD5 and import it into jme, the shaking is more powerful then it is in blender.

    Even the "modelviewer"  created by "der_ton" shows nice results.



    @Basixs one any other one who uses mocaps, blender, MD5 for jme:

    Have you experienced that as well??

    Have you found a way to get rid of this?



    I had a look onto the bvHacker, and its a good tool to crop motions for nice loops and altering some general rotation problems and stuff.

    But interpolating isn't possible with it, right?

    Though interpolating is possible in blender you have to select every bone and interpolate its curves.

    I haven't found out how to interpolate all curves of an armature in one step.





    so far…

Nice update .:emp…imm0|82:.



I have noticed the shaking also, are you using the 'upper' numbered bvh sets?

i don't really get what you mean by the "upper" numbered bvh's.



you men the subject nubers?

i currently test with subject#2 (2_1;2_2;), subject#8(8_2;8_3)



The shaking is really confusing.

As you (totally missed that) discussed this in the MD5Importer Thread, its a problem with the different Coordinate-Systems of blender and jme. Blender and MD5 have the same ones–> Z_UP



But as you mentioned, it helped adding (Root)Bone as a parent to the Hips?

I'would be really happy if this works.







After weeks of working with blender my opinion is still the same :wink: IT SUCKS