376

(9 replies, posted in Tutorials/Examples)

Introduction to .BVH files

A .bvh file is nothing more than a text file that has data that was captured from a moving skeletal system. Another name for this type of data capture is "Motion Capture" which has been abbreviated as mocap.

Explanations on BVH files :
http://centralsource.com/blender/bvh/what.htm

Short example :
http://www.youtube.com/watch?v=HUnivUVbwg8
to be simple, animations you see there can be applied to ANY humanoïd 3d model

Where to find them ?

- https://sites.google.com/a/cgspeed.com/ … conversion
- http://mocap.cs.cmu.edu/
- http://centralsource.com/blender/bvh/files.htm

First site have a 2500 motions released for FREE !
I never tested bvh of others site since with 2500 motions from CG i have more than i ever needed =p

Using BVHacker

http://davedub.co.uk/bvhacker/

BVHacker is a free tool to tweak and arrange BVH files if it doesnt fit your needs
With it, you can :

- View BVH anims
- Modify/reset Joint rotations & translation
- Crop an animation
- Divide Frame rate per 2/4/8/16...
- Add a first frame with a T pose on the bvh model
- Save/load bvh's
- And more but thats all we need to know

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
PREPARING BVH
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

To use a BVH in a game, let's say for a playable character, you must set translations of the animation to 0, wich will make it stay on place

- Reset the Translation Pivot in all bvh u gonna use, that will set rotations x, y, z to 0 (push XYZ button)
PunBB bbcode testPunBB bbcode test

This will make the animation to stay on place (and this is needed if you want combine
multiple BVH files -> more on this later)

NOTE. Don't reset the Rotation pivot otherwise the animation will look buggy (try urself)

A good thing to do is cropping an animation (because you dont need 1000 frames for a simple run loop, wich can be done in few frames

All you have to do is here :
PunBB bbcode test

Mark in : Select the beggining of the movement
Mark out : Select the last frame of the movement
Crop : Delete everything that is not between mark in and mark out
Knit : Delete some frames to make a seamless loop

Here's a cropped run cycle for example :
PunBB bbcode test

Note there is some movement's dont need to be a perfect loop, like a kick or something :
PunBB bbcode test
Because these ones will be played only one time in game

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
BLENDER PART
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

Simple use of a BVH file in blender

Step 1 : Load up 3D model
PunBB bbcode test

Step 2 : Go to File -> Import BVH motion capture

Step 3 : Don't touch anything and in armature tab, set "Rest position" and Enable X-rays
PunBB bbcode testPunBB bbcode test

Step 4 : Scale, Translate, Rotate the armature to fit in the model (as much as possible)
PunBB bbcode testPunBB bbcode testPunBB bbcode test

Step 5 : Select 3D model -> Hold Shift -> Select armature then press CONTROL + P, and select Set Parent To With Automatic Weights
PunBB bbcode testPunBB bbcode test

Step 6 : Under Armature tab, press "Pose position" and turn off X-rays
PunBB bbcode testPunBB bbcode test

Step 7 : Press play in the timeline and see the results
PunBB bbcode test

If theres problem with weight mapping, you can correct it with weight paint or vertex groups

Select all, export with maratis exporter (dont forget to activate animation) and ur done.


▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
MERGING BVH's TOGETHER
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

So here we will store all bvh anim we want to use in a single blender file

Step 1 : Open Blender and set a window to NLA Editor
PunBB bbcode test

Step 2 : File -> Import -> Import BVH
You will get this :
PunBB bbcode test

Step 3 : Push the thing that looks like a snowflake
You will get this :
PunBB bbcode test

Step 4 : Import another BVH file (you will have 2 Skeletons on the 3d scene now)
Step 5 : Repeat step 3

Step 6 : Select the first BVH track and in NLA Editor menu, press Add -> Add track(s)
PunBB bbcode test

Step 7 : Still in NLA Editor menu, press Add -> Add Action strip, a search window will pop up, just enter the name of your 2nd bvh file, then validate
PunBB bbcode test

Step 8 : You can now delete the 2nd Skeleton, as the animation is stored in the first skeleton, without overwriting the base animation

Step 9 : Select First animation bar and in tool shelt, set extrapola to "nothing" and blender to "replace"
PunBB bbcode test

Notes : With that method you can add any animation you want :
PunBB bbcode test
and easly adjust animation speed (edit -> scale) of every single anims

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
MERGING BVH's TOGETHER : Alternate method
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

You can use a simple text file editor to merge bvh files, for example
let's say we have two files : BVH1 and BVH2 ;

open BVH1 with any text editor and copy everything above "frame time". take note of the total ''frames" (10 in the screenshot)

PunBB bbcode test

now, close BVH1 and open BVH2. paste the stuff from BVH1 at the very end of BVH2.
then change the total frame number (just below frame time) for example, if BVH1 is 22 frames, and BVH2 is 77 frames put frames : 99 in BVH2 file.

Well thats all for now smile