Game Development Reference
In-Depth Information
//Find matching brace
while (1){
if (!bvhfile.ReadString(line)) return FALSE;
if (line == braceline) break;
endpos = bvhfile.GetPosition();
bvhfile.Seek(filepos, CFile::begin);
while (filepos<endpos){
//Recusrsively call this function using new endpos and with
//current bone as parent
LoadBVHHierarchy(bone, bvhfile, endpos);
filepos = bvhfile.GetPosition();
return TRUE;
The first call to LoadBVHHierarchy with the ROOT object uses a NULL
pointer as the parent parameter and sets the 'endpos' to zero. The
function recognizes a zero value for 'endpos' as indicating that the entire
file should be searched. When this occurs 'endpos' is set to the current file
Having loaded a set of bones and initialized the hierarchy, offset and
number and type of motion channels, we can go on to load the motion. As
we learnt in the previous section, the motion section is preceded by a
single line that contains the upper case word MOTION. The following
function goes on to read the number of frames and the frame duration,
and store these values in member variables of the document class.
Assuming all went well to this stage, we are ready to create storage for the
key values. We leave this task to the bones themselves. Each bone
knows how many channels are used for the bone and so can assign the
appropriate key storage. In the BVHViewer project we have both position
keys represented as vectors and rotation keys represented as vectors. A
bone can have just position, just rotation or both position and rotation. If
any problems occurred allocating storage, then the current bones are
cleared and the function returns.
Finally, we have the data structure and storage to read in the motion
capture data. Each line of the file contains one set of key values. To
allocate the correct value to the appropriate bone and channel we go
Search Nedrilad ::

Custom Search