Adapting BVH to a Custom Skeleton

(Apollos) #1

Hey all,

I’m currently trying to adapt mocap (from the web) to a custom skeleton.

I’ve had reasonable success with using rotation constraints to copy rotations from the BVH armature bones to the custom ones, but when I try to bake it I get flat keys (no rotation). It’s as if the bone rotations are invisible when copy rotation constraints are applied.

I also tried applying Ipos directly on a bone for bone basis, and it seems like this might work, but the BVH skeleton comes in at weird angles, and I can’t seem to straighted them out at the Ipo level.

Is there currently a “right way” to apply imported BVH to a custom skeleton, if the custom skeleton needs to be exported with keys? Or, what are your opinions on the best way to do it? :confused:

Thanks in advance.:smiley:

(Vertex Pusher) #2

I think you have the option to import the BVH data as empties instead of as an armature . Use that option and then either use the track to constraint or the IK constraint (with a 1 chain length) and apply it to the appropriate bones …

Though if you mean by “custom” skeleton as somthing with a noticable differance in proportions to the generic human body , then your approach of using the copy rotations would be better …

… The problem you might be having is that you are seeing an animation with the BVH data but in your skeleton but you don’t have any keys to bake … i.e. the constraints are making your skeleton move because it is copying the BVH skeleton but they themselves do not have any keys or IPO data etc …

You are having a variant of the “help I posed my character with Auto IK on but the animation won’t key/play right” … The solution for that problem is the same for your problem . In that situation most people don’t realize that the rotations and poses caused by Auto IK don’t “bake” as it does with the IK constraint because Auto IK doesn’t have a target . They need to select every bone that they want to key in that pose otherwise they pose will not key, not just the bone they moved with Auto IK on .
So it is also with your problem . Just go to the first frame of the BVH and select all the bones and I -> Loc Rot (most likely) then at appropriate intervals (enough to make the BVH “stick”) insert more keys until the last frame of the BVH always with all the bones in your skeleton selected when keying . I only suggest using intervals because I don’t know how long the animation is and I would guess that Blender will do more then an adequate job of interpolating between the keys for you . Though you could set a key at every frame if you wanted … but that is what baking is for .

Good Luck !

(Apollos) #3

Vertex Pusher, thanks for the reply.

By custom I meant different from the BVH skeleton. I’ve been trying to take BVH and apply it to a human skeleton that doesn’t match on a bone for bone basis. I’ve also been trying to come up with a straightforward way that works for using multiple mocap files to export animation data on a separate skeleton.

For instance, suppose I had a rig for a video game, and I had all this BVH data that I wanted to generate animations for, using the game’s skeleton and its exporter. The trick is finding a way to export all those anims without repeating a complex setup every time.

I tried what you suggested with adding more keyframes. I had been adding some already, but only a few to kick off the baking process. Basically it was the same result. I manually added a key to every bone in the custom skeleton, every ten frames. In each case, these keys displayed no rotation data, they were all flat.

Looking at the transform properties for the bones, the ones with the Copy Rotation constraints all display a rotation of 0,0,0 all the time. The corresponding bones on the BVH skeleton display appropriate rotation coordinates, I’m guessing world space.

So apparently when I add a key for the constrained bones, it goes in at 1,0,0,0 (quat rotations, 000 xyz) regardless of its actual rotation. It’s totally flat. Perhaps I’m missing something obvious or fundamental. :spin:

Thanks again for the reply. I’ll take a shot at the empties setup you mentioned. Perhaps I can adapt this just as easily. :yes:

(Apollos) #4

OK I just did an IK test and it didn’t work as I expected, so either I’m doing something wrong, or I’m expecting Blender to do something and it just doesn’t work that way.

I set up a 2 bone armature with the second bone being the IK target of the first. I keyed some motion in the IK_Target bone to move the chain around, then I baked the action.

The IK_Target baked as expected, with a key at every frame. The IK constrained bone baked too, but its keys were all flat. The rotation of the constrained bone is ignored in the baking process.

What I’m expecting with the baking process: constrained bones get keyed every frame with the rotation produced by their constraints.

What I’m getting: constrained bones get keyed as if there were not constraints applied to them at all, totally motionless.

Perhaps I just need to read the docs again, or find a tutorial.

(Vertex Pusher) #5

You’re right … I have successfully baked an action before (or so I thought) … but that was a while ago … the last time I just had to hit the bake button and the keys were automatically generated and the constrained bones’ poses’ IPO curves reflected the changes … but now when I try it it doesn’t work anymore … everything other then the target bone flatlines like you said …

Well the tool tip for the bake button says “Create an action with the constraints effect converted into ipo keys” … So why isn’t it working ? …

I just did a search and apparently the bake functionality has been not working since 2.34 with regard to constraints and IK . Here is a script written by vladius that might work for you :

… did not know this … must not have checked the ipo curves the last time I tried baking (I only started using since 2.41a) …

Well hope the script works for you .

(Apollos) #6

Thanks for checking that out, and thanks for the script.:slight_smile: I was a little baffled by the tooltip myself, as it suggests that baking is intended for exactly what I’m trying to use it for.

I found this bug in the bug DB, it’s the closest thing I could find, but it’s relatively old (mid '06):

I’m downloading an SVN build to see if it has been fixed…I hope it has. I’ll see if I can get the script to work also.

Thanks again, it’s good to know that I’m not the only one. :wink:

(Apollos) #7

No change with latest SVN (Windows 13287, Jan 18).

(Vertex Pusher) #8

Heh … I just checked out a couple of recent SVN versions … No bake function anymore … The scripts is all we have for now …

(Apollos) #9

I didn’t even notice…I just tried setting some manual keys on an IK constrained bone. No workie.

I didn’t have any success with the script…I think it’s for action constraints. I guess I could try crawling over to the developer forums with sad, puppy eyes, and asking for a fix. :stuck_out_tongue: Or if I could convince them that a college coed pillow fighting team needs the feature…(hey it’s plausible!)

I could also attempt (probably futile) to write my own. :no:

(Vertex Pusher) #10

Actually I just tried it . It works beautifully . Just like you expect the bake function to do .

Just create an action by keyframing just your target bones for your constraint (I used IK) and then tab into Object Mode (you have to since there are no script links in Pose) and then run the script . It should automatically show up in Object -> Scripts if you just put the script in the Scripts directory in Blender . And you should find a new action named “baked_action” (assuming you didn’t change the default action name) .

It bakes all the bones with the appropriate changes for their ipo curves too, just like what we expected the bake to do .

(Apollos) #11

Oh! It does work! I must’ve been doing something wrong with the script. Fantastic! :smiley:

I keyed a start frame and end frame for all the constrained bones and it filled in the baked keys between.

Many thanks for your help on this. :slight_smile:

(Vertex Pusher) #12

Glad to be of help :slight_smile: Your problem helped me learn about an issue I had no idea about (I don’t use BVH files nor do I need to bake animations often - though I do know what they are supposed to do) . I’m just glad that there is a solution if ever I needed it . Hope the rest of your project goes smoothly .

… #[email protected]!!! the damn Packers/Giants game is going into overtime …

And oh btw if you have the odd question about using Blender it is actually better (clearer at any rate for me) to do a search using the forum’s search function rather then the developer’s forum at … that’s how I found the script . The developer’s forum is good for discovering new features someone might be working on, or if you’re like me and relatively new to Blender, finding out about old and obscure but still useful features from the release logs .

(Apollos) #13

Thanks. Right now I’m just tinkering and trying to perfect methods, learn Blender’s ins and outs, etc. :eyebrowlift2:

I wasn’t able to catch it!

Good to know. Thanks again and best of luck in your own endeavors. :smiley:

(ititrx) #14

Question, Im confused.

Please explain why it had to be baked in the first place? I thought I understood, but now am lost.

Is it because of the bvh? or because of the ik solvers?


(Apollos) #15

Hi ititrx,

When exporting animation to another format (like for video games), it is usually necessary to have keys on the bones you want moving, because formats outside of Blender don’t necessarily understand Blender’s constraints (IK Solvers, etc). Even Blender’s game engine needs real animations, not just animiated IK targets.

So if you are making use of IK or other constraints as animation aids, you will still need key frames on all the bones that are moving in order to export the animations. Game engines typically like to see real key frames on all bones, and won’t calculate IK on the fly based on animated IK targets, because it’s too CPU intensive.

(sjcomp) #16

That’s pretty interesting. Is it the process for this setup:

  1. Create your skeleton, let’s say with bone1 and bone2
  2. Import bvh data as empties, let’s say Empty1 and Empty2
  3. Set constraint for bone1: TrackTo with Empty1 as a target
  4. Set constraint for bone2: TrackTo with Empty2 as a target
  5. Go to the Pose Mode, select bone1 and bone2
  6. Go through the animation hitting Insert Frame a few times
  7. Bake animation with the script
    Am I understanding this correctly?

(Apollos) #17

That’s essentially correct. I am using rotation constraints myself.

For #6, I just set a start and end key frame, and the script baked everything in between, and didn’t bake anything after the last key I set.

(sjcomp) #18

Thanks Apollos. I’ll give it a try.

(adb) #19

Should “C Space” be set to Pose Mode ? What do the various settings here do ?

(sjcomp) #20

Sorry, it have been awhile when I was playing with it. So I do not remember the details. Maybe Apollo does.