// copyright Min Zhong, cs838 proj2, April, 2000 #ifndef MOTIONCAPTURER_H #define MOTIONCAPTURER_H #include "proj2.h" // for bvh parser, assume MAX MAX_CHILDREN joints from a root typedef struct Node Node; #define MAX_CHILDREN 10 // max 10 child nodes (joints) from a parent (root) #define NODE_SIZE sizeof(Node) typedef enum { ROOT = 0, JOINT = 1, END_SITE = 2 } Segtype; struct Node { char name[40]; Segtype type; double offset[3]; // translation offset. bad naming int e_off; // offset WITHIN A FRAME to the euler array in MotionCapturer. int q_off; // offset WITHIN A FRAME to the quatern array in MotionCapturer. int chan_cnt; // has to be 3 or 6 bool b_first3trans; /* indicate order of chans: 3 trans channels first or rot first true if first 3 chan are transl, false if rot first only used during parsing for generalized parsing. */ Node *children[MAX_CHILDREN]; int children_cnt; Node *parent; // parent joint. }; class MotionCapturer { public: Node *root; int rot_cnt; // number of nodes having rotations (root + joints) int frame_cnt; // number of frames in this anim double frame_time; // time in sec for each frame double *trans; /* arr of root's translation at each frame. arr size = 3 * root_cnt * frame_cnt, root_cnt is usually 1 */ double *euler; /* arr of euler rotations read from .bvh file. each rotation angle in zxy order. and each rotation specified in hierachy order. Also all rotations are specified for one frame before the next frame. arr size = 3 * node_cnt * frame_cnt. */ double *quatern; /* arr of quatern rotations converted from the 3 euler rotations for each node. and each rotation specified in hierachy order. Also all rotations are specified for one frame before the next frame. arr size = 3 * node_cnt * frame_cnt. */ double *expmap; /* arr of exponential map rotations converted from the 3 euler rotations for each node. and each rotation specified in hierachy order. Also all rotations are specified for one frame before the next frame. arr size = 4 * node_cnt * frame_cnt. */ double *einterp; /* arr to store euler interp rot data. same size as euler */ double *qinterp; /* arr to store quatern interp rot data. same size as quatern */ double *minterp; /* arr to store expmap interp rot data. same size as expmap */ double *mqinterp; /* conv emap to q for interp */ MotionCapturer::MotionCapturer() { root = NULL; frame_cnt = 0; }; ~MotionCapturer(); }; //--------- parser functions ------------- Status read_bvh_file(char *filename, MotionCapturer *motionCapturer); /* *****API**** called in viewer.cpp. read in file and fill a MotionCapturer object w/ hierarchical and motion data info return SUCCESS if read file ok FAILURE otherwise */ //--------- end parser functions----------- #endif