Game Development Reference
In-Depth Information
motion and the increment for a single frame expressed in seconds. The
remainder of the file contains the actual motion. Each subsequent line in
the file gives the channel value for every channel in the order that they
were given in the HIERARCHY section of the file. In this instance with
six channels of Hips being given first followed by three channels for the
Chest, the first nine values for each motion line will give the Xposition ,
Yposition , Zposition , Zrotation , Xrotation and Yrotation for the Hips
followed by the Zrotation , Xrotation and Yrotation for the Chest .
Remember that when orientation is defined using Euler angles, it is
important that the order of rotation is maintained. If the order of rotation
channels is X , Y , Z , then rotation order must be X , Y , Z . Similarly, if
the order of rotation channels is Z , X , Y , then rotation order must be
Z , X , Y .
Creating a BVH viewer
In creating any parser there are two parts. First, we must read and create
a skeleton. In the sample code we use a CBone class to hold the data for
each element. Since the sample code is an MFC application it used the
Document/View architecture. The Document contains a CBone variable
called bones . The CBone class is a singly linked list. Each member of the
class contains a next member variable that is a pointer to a CBone
element and a parent member variable is also a CBone pointer. Both
these pointers are initialized to NULL by the constructor. When parsing a
file for each ROOT or JOINT, a bone is added and the offset and channels
are initialized. When dealing with a hierarchical file a recursive function is
the best solution. Since any bone can have only a single parent, we need
only to set the parent in the recursive function call. When using a
recursive function there has to be an exit condition otherwise the function
will never return. In the following function which sets the hierarchy the exit
condition is the file position of the closing brace for the current ROOT or
JOINT section. Once this point is reached the function returns.
BOOL CBVHViewerDoc::LoadBVHHierarchy(CBone *parent, CStdioFile
&bvhfile, int endpos)
{
//This function is called recursively
//The function returns when the current file position for the
//bvhfile exceeds the supplied parameter endpos
CBone *bone;
Search Nedrilad ::




Custom Search