Animation from BVH Andrew Slatton
Biovision Hierarchy (BVH) Contains motion capture data 2 Major Components: –Hierarchy Formatted like a scene graph with parents, children, etc. –Motion data Number of frames, frame time A list of floating point values associated with “channels” of the hierarchy nodes
BVH Example of Hierarchy: HIERARCHY ROOT Hips { OFFSET CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation JOINT LeftUpLeg { OFFSET CHANNELS 3 Zrotation Xrotation Yrotation JOINT LeftUpLegRoll { OFFSET CHANNELS 3 Zrotation Xrotation Yrotation } … }
BVH Motion data example: MOTION Frames:119 Frame Time: e e e e e e e e e e e …
BVH Motion Data List of values Each value corresponds to a rotation or translation channel Listed in same order as hierarchy was parsed [Joint0, Channel0] [Joint0, Channel1] [Joint1, Channel0] [Joint1, Channel1] [Joint1, Channel2] … [X, Y, Z] x [Rotation, Translation]
Project Steps BVH Parser –Needs to read in and handle hierarchy, motion data –Similar to writing any other parser, so no need to discuss Skeleton drawing –Could handle this mostly in CPU or mostly in GPU –I chose GPU
Drawing the Skeleton High level implementation: –On CPU: Send skeleton object a time Skeleton object computes what frame should be displayed at that time Skeleton object sends appropriate data to shader –Shaders handle everything else
Drawing the Skeleton Vertex Shader –Given motion and hierarchy data –Computes positions of joints for the desired frame Geometry Shader –Given joint locations –Computes vertex positions and normals for limbs Fragment Shader –Phong illumination of limbs
Drawing the Skeleton Shader uniform variables: –Motion data for desired frame –Joint offsets –Channel ordering Could be Xrot, Yrot, Zrot, OR Zrot, Yrot, Xrot (or any other order) –Parent pointers Must apply ancestors’ transforms to find a joint’s location –Motion data pointers Some joints span six indices of motion data, some three, and some zero
Drawing the Skeleton Generating Limbs: –Simplest Method: Draw a sphere at the location of each joint Doesn’t give a vivid picture of the motion
Drawing the Skeleton Generating Limbs: –Could make a cylinder about each ParentJoint-ChildJoint segment –Notice the discontinuities at joints. This is ugly.
Drawing the Skeleton Generating Limbs: –Quick fix for final result Rotate y = x*x – 1 about each limb axis
Odds and Ends Could implement animation as loop that stops only when animation is complete: while(!skel.last_frame()) { skel.set_frame(elapsed_time); DrawScene(); } This locks up CPU No good if we want to allow keyboard/mouse inputs during animation Also, won’t work with glutPostRedisplay() because we must exit the loop before glutMainLoop can call glutDisplayFunction
Odds and Ends Use glutTimerFunc ! Animate(int delay){ skel.set_frame(elapsed_time); glutPostRedisplay(); if(!skel.last_frame()) { glutTimerFunc(delay,Animate,delay); }} Will call Animate once every delay milliseconds until we reach end of animation Allows glutMainLoop to continue execution during this delay time
Thank You!