JunkBox_Lib  1.10.2
bvh_tool.h
Go to the documentation of this file.
1 #ifndef __JBXL_BVH_TOOL_H_
2 #define __JBXL_BVH_TOOL_H_
3 
10 #include "ttree.h"
11 #include "matrix.h"
12 
13 //
14 #define BVH_NODE_HIERARCHY 0
15 #define BVH_NODE_ROOT 1
16 #define BVH_NODE_JOINT 2
17 #define BVH_NODE_END 3
18 
19 #define BVH_STR_HIERARCHY "HIERARCHY"
20 #define BVH_STR_MOTION "MOTION"
21 
22 #define BVH_STR_ROOT "ROOT"
23 #define BVH_STR_JOINT "JOINT"
24 #define BVH_STR_END "End"
25 
26 #define BVH_STR_OFFSET "OFFSET"
27 #define BVH_STR_CHANNELS "CHANNELS"
28 
29 #define BVH_STR_FRAMES "Frames:"
30 #define BVH_STR_FRAME "Frame"
31 #define BVH_STR_TIME "Time:"
32 
33 #define BVH_STR_FRAME_TIME "Frame Time:"
34 #define BVH_STR_PX "Xposition"
35 #define BVH_STR_PY "Yposition"
36 #define BVH_STR_PZ "Zposition"
37 #define BVH_STR_RX "Xrotation"
38 #define BVH_STR_RY "Yrotation"
39 #define BVH_STR_RZ "Zrotation"
40 
41 
42 /*
43 hierarchy データ
44  int ldat.id ノードの種別.BVH_NODE_HIERARCHY, BHV_NODE_ROOT, BVH_NODE_JOINT, BVH_NODE_END
45  int ldat.lv CHANNELS 6/3
46  int ldat.sz sizeof(vector)
47  Buffer ldat.key 関節名
48  Buffer ldat.val 自由度 "P#P#P#R#R#R#" の形式
49  void* ldat.ptr OFFSET の vector へのポインタ
50  tTree* ldat.lst NULL
51 
52  tTree* next 子ノード(長女)へのポインタ
53  tTree* prev 親ノードへのポインタ
54  tTree* altp その他へのポインタ(汎用)
55  tTree* back 子ノード(末っ子)へのポインタ
56  tTree* esis 前の姉妹(姉)ノードへのポインタ
57  tTree* ysis 次の姉妹(妹)ノードへのポインタ
58 
59  int depth 深さ
60  int num 子ノードの数(全ての子ノードの数)
61  int ctrl 制御用
62  int state ノードの状態
63 */
64 
65 
66 struct _bvh_data
67 {
68  int joint_num;
69  int frame_num;
70  double frame_time;
71  int framepsec;
72  int channels;
73  int state;
74 
76  double* motion;
78 };
79 
80 typedef struct _bvh_data BVHData;
81 
82 
84 // Basic
85 
86 BVHData* new_BVHData(void);
87 void del_BVHData(BVHData** bvh);
88 
89 void init_BVHData (BVHData* bvh);
90 void clear_BVHData(BVHData* bvh);
91 
92 #define free_BVHData(t) del_BVHData(t)
93 
95 // Tiny Tool
96 
97 tList* bvh_get_seq_data(FILE* fp);
98 tList* bvh_find_line(FILE* fp, const char* key);
99 
100 int bvh_count_joints(tTree* tree);
101 int bvh_count_channels(tTree* tree);
102 void bvh_get_offset(tTree* tree, vector** vect);
103 void bvh_get_parameter(BVHData* bvh);
104 
105 void _bvh_recsv_get_parameter(tTree* tree, BVHData* bvh);
106 void _bvh_space_format(FILE* fp, int depth);
107 
109 // File I/O
110 
111 BVHData* bvh_read_file (const char* fn);
112 int bvh_write_file(const char* fn, BVHData* bvh);
113 
114 #define bvh_read_data(f) bvh_parse_data((f))
115 
116 int bvh_print_data(FILE* fp, BVHData* bvh);
117 int bvh_print_hierarchy(FILE* fp, BVHData* bvh);
118 int bvh_print_motion(FILE* fp, BVHData* bvh);
119 
120 int _bvh_recsv_print_hierarchy(FILE* fp, tTree* tree);
121 
123 // Parser
124 
125 BVHData* bvh_parse_data(FILE* fp);
126 tTree* bvh_parse_hierarchy(tTree* tree, FILE* fp);
127 void bvh_parse_motion(BVHData* bvh, FILE* fp);
128 
129 
130 #endif
void bvh_get_parameter(BVHData *bvh)
Definition: bvh_tool.c:205
BVHData * new_BVHData(void)
Definition: bvh_tool.c:15
void bvh_parse_motion(BVHData *bvh, FILE *fp)
Definition: bvh_tool.c:480
tTree * bvh_parse_hierarchy(tTree *tree, FILE *fp)
Definition: bvh_tool.c:522
tList * bvh_get_seq_data(FILE *fp)
Definition: bvh_tool.c:87
BVHData * bvh_read_file(const char *fn)
Definition: bvh_tool.c:251
void _bvh_recsv_get_parameter(tTree *tree, BVHData *bvh)
Definition: bvh_tool.c:216
void bvh_get_offset(tTree *tree, vector **vect)
Definition: bvh_tool.c:180
void clear_BVHData(BVHData *bvh)
Definition: bvh_tool.c:51
int bvh_print_hierarchy(FILE *fp, BVHData *bvh)
Definition: bvh_tool.c:307
int bvh_count_joints(tTree *tree)
Definition: bvh_tool.c:155
int bvh_print_data(FILE *fp, BVHData *bvh)
Definition: bvh_tool.c:289
BVHData * bvh_parse_data(FILE *fp)
Definition: bvh_tool.c:418
tList * bvh_find_line(FILE *fp, const char *key)
Definition: bvh_tool.c:121
void del_BVHData(BVHData **bvh)
Definition: bvh_tool.c:28
void init_BVHData(BVHData *bvh)
Definition: bvh_tool.c:40
int _bvh_recsv_print_hierarchy(FILE *fp, tTree *tree)
Definition: bvh_tool.c:320
int bvh_write_file(const char *fn, BVHData *bvh)
Definition: bvh_tool.c:274
int bvh_print_motion(FILE *fp, BVHData *bvh)
Definition: bvh_tool.c:389
int bvh_count_channels(tTree *tree)
Definition: bvh_tool.c:138
void _bvh_space_format(FILE *fp, int depth)
Definition: bvh_tool.c:234
マトリックス&ベクトルライブラリ ヘッダ
double * motion
MOTION データへのポインタ joint_num*frame_num.
Definition: bvh_tool.h:76
vector * offset
関節のOFFSET
Definition: bvh_tool.h:77
int channels
総チャンネル数.チャンネル数の合計.モーションデータの数.
Definition: bvh_tool.h:72
int framepsec
FPS = (int)(1.0/frame_time)
Definition: bvh_tool.h:71
double frame_time
フレーム間の時間 sec
Definition: bvh_tool.h:70
int state
データの状態
Definition: bvh_tool.h:73
int frame_num
フレームの数
Definition: bvh_tool.h:69
tTree * hierarchy
関節部のツリーデータへのポインタ.上記参照.
Definition: bvh_tool.h:75
int joint_num
関節の数
Definition: bvh_tool.h:68
Definition: matrix.h:29
Tiny Tree Graph 構造ライブラリヘッダ