54 if (hierarchy!=NULL) {
74 for (
int j=0; j<joint_num; j++) {
97 if (bvh==NULL)
return;
99 joint_num = bvh->joint_num;
100 frame_num = bvh->frame_num;
101 frame_time = bvh->frame_time;
102 framepsec = bvh->framepsec;
103 channels = bvh->channels;
106 hierarchy = bvh->hierarchy;
107 motion = bvh->motion;
108 offset = bvh->offset;
118 bvh.joint_num = joint_num;
119 bvh.frame_num = frame_num;
120 bvh.frame_time = frame_time;
121 bvh.framepsec = framepsec;
122 bvh.channels = channels;
125 bvh.hierarchy = hierarchy;
140 if (fname==NULL || fname[0]==
'\0')
return FALSE;
143 if (sz==0)
return FALSE;
146 FILE* fp = fopen(fname,
"r");
147 if (fp==NULL)
return FALSE;
158 if (fp==NULL)
return FALSE;
162 if (ptr==NULL)
return FALSE;
178 if (fname==NULL || fname[0]==
'\0')
return FALSE;
183 if (state!=0)
return FALSE;
203 if (fname==NULL || fname[0]==
'\0')
return FALSE;
205 int echfrm = (int)(sec/frame_time);
206 int num = (frame_num + echfrm - 1)/echfrm;
207 if (num==0 || num>99)
return FALSE;
212 if (et!=NULL) et[-1] =
'\0';
226 for (
int i=0; i<num; i++) {
228 int outfrm = i*echfrm;
231 bvh_data.frame_num = frame_num - outfrm;
234 if ((num-1)*echfrm + space > frame_num) {
235 space = frame_num - (num-1)*echfrm;
237 bvh_data.frame_num = echfrm + space;
240 bvh_data.frame_num = echfrm + space;
243 if (i!=0 && space>0) {
244 bvh_data.frame_num++;
245 bvh_data.motion = &(motion[(outfrm-1)*channels]);
247 bvh_data.motion[0] = motion[0];
248 bvh_data.motion[1] = motion[1];
249 bvh_data.motion[2] = motion[2];
250 bvh_data.motion[3] = 0.0;
251 bvh_data.motion[4] = 0.0;
252 bvh_data.motion[5] = 0.0;
256 bvh_data.motion = &(motion[outfrm*channels]);
268 if (state!=0)
return FALSE;
276 if (fp==NULL)
return FALSE;
281 if (state!=0)
return FALSE;
301 if (offset==NULL)
return;
311 while(tree->esis!=NULL) tree = tree->esis;
319 ld->ptr = (
void*)malloc(ld->sz);
320 if (ld->ptr==NULL)
return;
321 memset(ld->ptr, 0, ld->sz);
323 *((
vector*)ld->ptr) = offset[*jnum];
327 if (tree->next!=NULL)
_set_offset(tree->next, jnum);
348 size_t len =
sizeof(int)*joint_num;
376 for (
int j=1; j<joint_num; j++) {
386 while(tree->esis!=NULL) tree = tree->esis;
402 if (tree->next!=NULL) {
419 if (frame<0 || frame>=frame_num)
return NULL;
423 if (vect==NULL)
return NULL;
424 memset(vect, 0, len);
426 int frm = frame*channels;
428 for (
int j=0; j<joint_num; j++) {
435 for (
int i=0; i<chnum; i++) {
436 if (tpchr[i*2]==
'P') {
438 index = frm + index + i;
444 vect[j].
set(0.0, 0.0, 0.0);
447 for (
int k=0; k<3; k++) {
449 if (tpchr[k2]==
'P') {
450 if (tpchr[k2+1]==
'X') vect[j].
x = motion[index+k];
451 else if (tpchr[k2+1]==
'Y') vect[j].
y = motion[index+k];
452 else if (tpchr[k2+1]==
'Z') vect[j].
z = motion[index+k];
463 if (frame<0 || frame>=frame_num)
return NULL;
467 if (quat==NULL)
return NULL;
468 memset(quat, 0, len);
474 double d2r =
PI/180.0;
475 int frm = frame*channels;
477 for (
int j=0; j<joint_num; j++) {
484 quat[j].
set(1.0, 0.0, 0.0, 0.0, 1.0);
487 for (
int i=0; i<chnum; i++) {
488 if (tpchr[i*2]==
'R') {
490 index = frm + index + i;
503 double th = motion[index]*d2r;
508 chnum = chnum - chfwd - 1;
509 if (chnum>0 && tpchr[2]==
'R') {
510 th = motion[index+1]*d2r;
516 if (chnum>0 && tpchr[4]==
'R') {
517 th = motion[index+2]*d2r;
534 if (vect==NULL)
return NULL;
535 memset(vect, 0, len);
537 for (
int j=0; j<joint_num; j++) {
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
Buffer init_Buffer()
初期化したBuffer型変数を返す.
Buffer dup_Buffer(Buffer buf)
Buffer型変数のコピーをつくる.
int cat_Buffer(Buffer *src, Buffer *dst)
Buffer変数 srcから dstへバッファを catする.
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
#define make_Buffer_bystr(str)
set_Buffer()
void set(T S, T X, T Y, T Z, T N=(T) 0.0, T C=(T) 1.0)
void setRotation(T e, Vector< T > v)
void set(T X, T Y=0, T Z=0, double N=0.0, double C=1.0, int D=0)
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
tTree * del_tTree(tTree **pp)
指定したノード以下のツリーを削除する.