00001
00002 #ifndef __JBXL_BVH_TOOL_H_
00003 #define __JBXL_BVH_TOOL_H_
00004
00012 #include "ttree.h"
00013 #include "matrix.h"
00014
00015
00016
00017 #define BVH_NODE_HIERARCHY 0
00018 #define BVH_NODE_ROOT 1
00019 #define BVH_NODE_JOINT 2
00020 #define BVH_NODE_END 3
00021
00022 #define BVH_STR_HIERARCHY "HIERARCHY"
00023 #define BVH_STR_MOTION "MOTION"
00024
00025 #define BVH_STR_ROOT "ROOT"
00026 #define BVH_STR_JOINT "JOINT"
00027 #define BVH_STR_END "End"
00028
00029 #define BVH_STR_OFFSET "OFFSET"
00030 #define BVH_STR_CHANNELS "CHANNELS"
00031
00032 #define BVH_STR_FRAMES "Frames:"
00033 #define BVH_STR_FRAME "Frame"
00034 #define BVH_STR_TIME "Time:"
00035
00036 #define BVH_STR_FRAME_TIME "Frame Time:"
00037 #define BVH_STR_PX "Xposition"
00038 #define BVH_STR_PY "Yposition"
00039 #define BVH_STR_PZ "Zposition"
00040 #define BVH_STR_RX "Xrotation"
00041 #define BVH_STR_RY "Yrotation"
00042 #define BVH_STR_RZ "Zrotation"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 struct _bvh_data
00070 {
00071 int joint_num;
00072 int frame_num;
00073 double frame_time;
00074 int framepsec;
00075 int channels;
00076 int state;
00077
00078 tTree* hierarchy;
00079 double* motion;
00080 vector* offset;
00081 };
00082
00083 typedef struct _bvh_data BVHData;
00084
00085
00086
00088
00089
00090 BVHData* new_BVHData(void);
00091 void del_BVHData(BVHData** bvh);
00092
00093 void init_BVHData (BVHData* bvh);
00094 void clear_BVHData(BVHData* bvh);
00095
00096 #define free_BVHData(t) del_BVHData(t)
00097
00098
00100
00101
00102 tList* bvh_get_seq_data(FILE* fp);
00103 tList* bvh_find_line(FILE* fp, const char* key);
00104
00105 int bvh_count_joints(tTree* tree);
00106 int bvh_count_channels(tTree* tree);
00107 void bvh_get_offset(tTree* tree, vector** vect);
00108 void bvh_get_parameter(BVHData* bvh);
00109
00110 void _bvh_recsv_get_parameter(tTree* tree, BVHData* bvh);
00111 void _bvh_space_format(FILE* fp, int depth);
00112
00113
00115
00116
00117 BVHData* bvh_read_file (const char* fn);
00118 int bvh_write_file(const char* fn, BVHData* bvh);
00119
00120 #define bvh_read_data(f) bvh_parse_data((f))
00121
00122 int bvh_print_data(FILE* fp, BVHData* bvh);
00123 int bvh_print_hierarchy(FILE* fp, BVHData* bvh);
00124 int bvh_print_motion(FILE* fp, BVHData* bvh);
00125
00126 int _bvh_recsv_print_hierarchy(FILE* fp, tTree* tree);
00127
00128
00130
00131
00132 BVHData* bvh_parse_data(FILE* fp);
00133 tTree* bvh_parse_hierarchy(tTree* tree, FILE* fp);
00134 void bvh_parse_motion(BVHData* bvh, FILE* fp);
00135
00136
00137 #endif