diff -urN wf-/data.c wf/data.c --- wf-/data.c 2015-12-24 00:00:00.000000000 +0900 +++ wf/data.c 2015-12-30 00:00:00.000000000 +0900 @@ -14,6 +14,8 @@ CASE_RET(type_cross); CASE_RET(type_square); CASE_RET(type_cube); + CASE_RET(type_circle); + CASE_RET(type_ball); CASE_RET(type_arr); CASE_RET(type_op_data_set); CASE_RET(type_slide); @@ -196,7 +198,7 @@ static void square_draw(prm_t *prm) { - pos_t wk[4*2]; + d3_t wk[4*2]; data_t data = { type_wire_frame, &(struct wire_frame){ @@ -210,7 +212,7 @@ static void cube_draw(prm_t *prm) { - pos_t wk[8*2]; + d3_t wk[8*2]; data_t data = { type_wire_frame, &(struct wire_frame){ @@ -226,6 +228,47 @@ } static void +circle_draw(struct circle *c, prm_t *prm) +{ + int i, n = c->n; + d3_t p[256*3]; + int odr[256+3]; + data_t data = { + type_wire_frame, + &(struct wire_frame){ n, p, odr, &p[n], &p[n*2] } + }; + + if(n > 256) ERR("n>256"); + + for(i=0; ir,0,0); + pos_rot(pp, &(line_t)LINE_Z, deg); + + odr[i] = i; + } + odr[n] = 0; + odr[n+1] = odr[n+2] = -1; + data_draw(&data, prm); +} + +static void +ball_draw(struct ball *ball, prm_t *prm) +{ + data_t op = { type_arr, (data_t[]){ + { type_copy_rot, &(struct copy_rot){ + .n=3, .l={D3_O,D3_I}, .init_deg=0, .step_deg=360/3 } }, + { type_copy_rot, &(struct copy_rot){ + .n=3, .l=LINE_Y, .init_deg=0, .step_deg=180.0/3 } }, + { type_end } }}; + + data_t data = { type_circle, &(struct circle){ .r=ball->r, .n=ball->n } }; + + op_data_draw(&op, &data, prm); +} + +static void arr_draw(data_t *data, prm_t *prm) { for(; data->type!=type_end; data++){ @@ -262,6 +305,12 @@ case type_cube: cube_draw(prm); break; + case type_circle: + circle_draw(data->p, prm); + break; + case type_ball: + ball_draw(data->p, prm); + break; case type_arr: arr_draw(data->p, prm); diff -urN wf-/data.h wf/data.h --- wf-/data.h 2015-12-24 00:00:00.000000000 +0900 +++ wf/data.h 2015-12-30 00:00:00.000000000 +0900 @@ -15,6 +15,8 @@ #define type_cross 2 #define type_square 3 #define type_cube 4 +#define type_circle 5 +#define type_ball 6 #define type_arr 10 #define type_op_data_set 11 @@ -51,6 +53,16 @@ int line_n; }; +struct circle{ + double r; + int n; +}; + +struct ball{ + double r; + int n; +}; + struct op_data_set{ data_t *op, *data; }; diff -urN wf-/eye.c wf/eye.c --- wf-/eye.c 2015-12-18 00:00:00.000000000 +0900 +++ wf/eye.c 2015-12-30 00:00:00.000000000 +0900 @@ -43,6 +43,8 @@ e->move_deg = 1; e->zoom_rate = 0.1; + e->liss_p = NULL; + e->way_cnt = 0; e->save = opt_str("-eye_save", ac, av, NULL); if((e->load = opt_str("-eye_load", ac, av, NULL)) != NULL){ @@ -59,6 +61,8 @@ &e->p_way.ts[i]); } fclose(fp); + }else if((e->liss_p = opt_str("-eye_liss_p", ac, av, NULL)) != NULL){ + way_liss_init_str(&e->wl_p, e->liss_p); }else{ alloc_way(e, 256); } diff -urN wf-/eye.h wf/eye.h --- wf-/eye.h 2015-12-18 00:00:00.000000000 +0900 +++ wf/eye.h 2015-12-30 00:00:00.000000000 +0900 @@ -17,6 +17,9 @@ struct way p_way, t_way; char *save, *load; double fps, start_sec, sec; + + char *liss_p; + struct way_liss wl_p; } eye_t; #define EYE_MOVE_MODE_N 4 diff -urN wf-/way.c wf/way.c --- wf-/way.c 2015-12-21 00:00:00.000000000 +0900 +++ wf/way.c 2015-12-30 00:00:00.000000000 +0900 @@ -1,4 +1,5 @@ #include +#include "util.h" #include "way.h" static int @@ -102,6 +103,72 @@ } } +void +way_liss_init(struct way_liss *wl, const pos_t *ps, const pos_t *pe, const d3_t *sec, const d3_t *init_sec) +{ + struct way *w; + + w = &wl->x; + w->n = 2; + w->vs = wl->vs[0]; + w->vs[0] = ps->x; + w->vs[1] = pe->x; + w->ts = wl->ts[0]; + w->ts[0] = w->ts[1] = sec->x * 0.5; + w->ps = NULL; + w->dg = 3; + + w = &wl->y; + w->n = 2; + w->vs = wl->vs[1]; + w->vs[0] = ps->y; + w->vs[1] = pe->y; + w->ts = wl->ts[1]; + w->ts[0] = w->ts[1] = sec->y * 0.5; + w->ps = NULL; + w->dg = 3; + + w = &wl->z; + w->n = 2; + w->vs = wl->vs[2]; + w->vs[0] = ps->z; + w->vs[1] = pe->z; + w->ts = wl->ts[2]; + w->ts[0] = w->ts[1] = sec->z * 0.5; + w->ps = NULL; + w->dg = 3; + + wl->init_sec = *init_sec; + d3_cen(&wl->cen, ps, pe); +} + +void +way_liss_init_str(struct way_liss *wl, const char *s) +{ + pos_t ps, pe; + d3_t sec, init_sec; + int n = sscanf(s, "ps=(%lf,%lf,%lf),pe=(%lf,%lf,%lf),sec=(%lf,%lf,%lf),init_sec=(%lf,%lf,%lf)", + &ps.x, &ps.y, &ps.z, &pe.x, &pe.y, &pe.z, + &sec.x, &sec.y, &sec.z, &init_sec.x, &init_sec.y, &init_sec.z); + if(n != 12) ERR("n != 12"); + + way_liss_init(wl, &ps, &pe, &sec, &init_sec); +} + +void +way_liss_get(struct way_liss *wl, double sec, pos_t *ret_p) +{ + way_get(&wl->x, sec + wl->init_sec.x); + ret_p->x = wl->x.ret_v; + + way_get(&wl->y, sec + wl->init_sec.y); + ret_p->y = wl->y.ret_v; + + way_get(&wl->z, sec + wl->init_sec.z); + ret_p->z = wl->z.ret_v; +} + + double interp3(double v0, double v1, const double *k0p, const double *k1p, double t_in) { diff -urN wf-/way.h wf/way.h --- wf-/way.h 2015-12-17 00:00:00.000000000 +0900 +++ wf/way.h 2015-12-30 00:00:00.000000000 +0900 @@ -28,9 +28,26 @@ pos_t ret_p; }; +#define WAY_V2(v1,v2,t1,t2,dg_) { .n=2, .vs=(double[]){v1,v2}, .ts=(double[]){t1,t2}, .ps=NULL, .dg=dg_ } + + void way_get(struct way *way, double t); +struct way_liss{ + struct way x, y, z; + + double vs[3][2]; + double ts[3][2]; + d3_t init_sec; + pos_t cen; +}; + +void way_liss_init(struct way_liss *wl, const pos_t *ps, const pos_t *pe, const d3_t *sec, const d3_t *init_sec); +void way_liss_init_str(struct way_liss *wl, const char *s); +void way_liss_get(struct way_liss *wl, double sec, pos_t *ret_p); + + /* interpolation 補間 diff -urN wf-/wf_ex.c wf/wf_ex.c --- wf-/wf_ex.c 2015-12-24 00:00:00.000000000 +0900 +++ wf/wf_ex.c 2015-12-30 00:00:00.000000000 +0900 @@ -64,6 +64,9 @@ e->p = e->p_way.ret_p; way_get(&e->t_way, sec); e->t = e->t_way.ret_p; + }else if(e->liss_p){ + way_liss_get(&e->wl_p, sec, &e->p); + e->t = e->wl_p.cen; } us = (1 / e->fps - (sec - e->sec)) * 1000000; if(us > 0) usleep(us); @@ -193,7 +196,8 @@ data_t *rcube = &(data_t){ type_op_data_set, &(struct op_data_set){ .op = &(data_t){ type_rdiv_way, &(struct rdiv_way){ .n=4, - .rate_way={ .n=2, .vs=(double[]){-0.5,1.0}, .ts=(double[]){3,3}, .ps=NULL, .dg=3 } } }, + //.rate_way={ .n=2, .vs=(double[]){-0.5,1.0}, .ts=(double[]){3,3}, .ps=NULL, .dg=3 } } }, + .rate_way=WAY_V2(-0.5,1.0, 3,3, 3) } }, .data = &(data_t){ type_cube } }}; data_t *cube = &(data_t){ type_op_data_set, &(struct op_data_set){ @@ -221,11 +225,11 @@ { type_copy_rot, &(struct copy_rot){ .n=4, .l=LINE_Z, .init_deg=0, .step_deg=90 } }, { type_rot_way, &(struct rot_way){ .l=LINE_Z, - .deg_way={ .n=2, .vs=(double[]){0,360*4}, .ts=(double[]){15,15}, .ps=NULL, .dg=3} } }, + .deg_way=WAY_V2(0,360*4, 15,15, 3) } }, { type_slide, &(d3_t){5,0,0} }, { type_rot_way, &(struct rot_way){ .l=LINE_Z, - .deg_way={ .n=2, .vs=(double[]){0,360*2}, .ts=(double[]){4,4}, .ps=NULL, .dg=3} } }, + .deg_way=WAY_V2(0,360*2, 4,4, 3) } }, { type_copy, &(struct copy){ .n={2,1,1}, .init={-2,0,0}, .step={4,0,0} } }, { type_end } }}, @@ -237,7 +241,7 @@ { type_copy_timeshift, &(struct copy_timeshift){ .n=12, .init_sec=0, .step_sec=10.0/12, .init={0,0,0}, .step={0,0,0} } }, { type_rot_way, &(struct rot_way){ - .l=LINE_Y, .deg_way={ .n=2, .vs=(double[]){0,-360}, .ts=(double[]){10,0}, .ps=NULL, .dg=1 } } }, + .l=LINE_Y, .deg_way=WAY_V2(0,-360, 10,0, 1) } }, { type_end } }}, .data = &(data_t){ type_arr, (data_t[]){ { type_op_data_set, &(struct op_data_set){ @@ -247,7 +251,7 @@ .op = &(data_t){ type_arr, (data_t[]){ { type_slide, &(d3_t){10,0,0} }, { type_rot_way, &(struct rot_way){ - .l=LINE_Y, .deg_way={ .n=2, .vs=(double[]){0,360}, .ts=(double[]){10,0}, .ps=NULL, .dg=1 } }}, + .l=LINE_Y, .deg_way=WAY_V2(0,360, 10,0, 1) }}, { type_slide, &(d3_t){0,0,-1} }, { type_end } }}, .data = &(data_t){ type_cube } }}, @@ -260,7 +264,7 @@ { type_slide, &(d3_t){-20,20,0} }, { type_copy_rot, &(struct copy_rot){ .n=8, .l=LINE_Z, .init_deg=0, .step_deg=45 } }, { type_rot_way, &(struct rot_way){ - .l=LINE_Z, .deg_way={ .n=2, .vs=(double[]){0,360}, .ts=(double[]){10,0}, .ps=NULL, .dg=1 } } }, + .l=LINE_Z, .deg_way=WAY_V2(0,360, 10,0, 1) } }, { type_copy_timeshift, &(struct copy_timeshift){ .n=3, .init_sec=0, .step_sec=2.0/3, .init={10+-3,-3,0}, .step={3,3,0} } }, { type_slide_way, &(struct way){ .n=2, .ps=(pos_t[]){{0,0,0},{0,0,3}}, .ts=(double[]){2,2}, .vs=NULL, .dg=3 } }, @@ -272,7 +276,7 @@ .op = &(data_t){ type_arr, (data_t[]){ { type_slide, &(d3_t){-20,20,-10} }, { type_rot_way, &(struct rot_way){ - .l=LINE_Y, .deg_way={ .n=2, .vs=(double[]){-90,90}, .ts=(double[]){5,5}, .ps=NULL, .dg=3} } }, + .l=LINE_Y, .deg_way=WAY_V2(-90,90, 5,5, 3) } }, { type_copy_rot, &(struct copy_rot){ .n=6, .l=LINE_Y, .init_deg=-45, .step_deg=(45.0-(-45))/(6-1) } }, { type_copy, &(struct copy){ .n={1,4,1}, .init={0,0,-10}, .step={0,3,0} }}, { type_end } }}, @@ -284,10 +288,10 @@ { type_copy_timeshift, &(struct copy_timeshift){ .n=10, .init_sec=0, .step_sec=-0.3, .init={-20,10,10}, .step={0,1,0} } }, { type_rot_way, &(struct rot_way){ - .l=LINE_Y, .deg_way={ .n=2, .vs=(double[]){0,360}, .ts=(double[]){2,0}, .ps=NULL, .dg=3} } }, + .l=LINE_Y, .deg_way=WAY_V2(0,360, 2,0, 3) } }, { type_slide, &(d3_t){0,0,2} }, { type_rot_way, &(struct rot_way){ - .l=LINE_Y, .deg_way={ .n=2, .vs=(double[]){0,-360}, .ts=(double[]){2,0}, .ps=NULL, .dg=3} } }, + .l=LINE_Y, .deg_way=WAY_V2(0,-360, 2,0, 3) } }, { type_rot, &(struct rot){ .l=LINE_X, .deg=90 } }, { type_end } }}, .data = &(data_t){ type_square } @@ -301,9 +305,9 @@ { type_slide_way, &(struct way){ .n=2, .ps=(pos_t[]){{0,-20,0},{0,20,0}}, .ts=(double[]){4.5,4.5}, .vs=NULL, .dg=3} }, { type_slide_way, &(struct way){ .n=2, .ps=(pos_t[]){{-20,0,0},{20,0,0}}, .ts=(double[]){3,3}, .vs=NULL, .dg=3} }, { type_rot_way, &(struct rot_way){ - .l={D3_O,D3_I}, .deg_way={ .n=2, .vs=(double[]){0,360*2}, .ts=(double[]){1,1}, .ps=NULL, .dg=3} } }, + .l={D3_O,D3_I}, .deg_way=WAY_V2(0,360*2, 1,1, 3) } }, { type_end } }}, - .data = &(data_t){ type_cube } + .data = &(data_t){ type_circle, &(struct circle){ .r=1,.n=10*4 } } }}; data.type = type_arr;