26 static float spl3(
float,
double,
double,
double,
double,
double,
double,
29 static float spl3(
float tension,
double data0,
double data1,
double x,
30 double x2,
double x3,
double lderiv,
double rderiv)
33 (data0 * (2 * x3 - 3 * x2 + 1) + data1 * (-2 * x3 + 3 * x2) +
34 (
double)tension * lderiv * (x3 - 2 * x2 + x) +
35 (
double)tension * rderiv * (x3 - x2)));
82 float startpos, endpos, curpos;
83 unsigned long mask = 0xFFFFFFFF;
87 for (k = keys; k->
next; k = k->
next) ;
91 curpos = startpos + time * (endpos - startpos);
93 for (k = keys; k->
next; k = k->
next) {
94 if (k->
pos <= curpos) {
118 for (k = keys; k; k = k->
next) {
142 int onestep,
int render,
unsigned long mode)
151 for (frame = step - 1; frame < numsteps; frame++) {
174 G_debug(3,
"gk_follow_frames():");
175 G_debug(3,
" MASK: %lx", mask);
176 G_debug(3,
" FROM: %f %f %f", tmp[
X], tmp[
Y], tmp[
Z]);
198 G_debug(3,
"gk_follow_frames():");
200 G_debug(3,
" DIR: %f %f %f\n", tmp[X], tmp[Y], tmp[Z]);
306 Keylist *k, *kp1, *kp2, *km1, **tkeys;
307 float startpos, endpos;
308 double dt1, dt2,
x, x2, x3, range, time, time_step, len, rderiv, lderiv;
318 if (keys && keysteps) {
320 G_warning(
_(
"Need at least 3 keyframes for spline"));
326 for (k = keys; k->
next; k = k->
next) ;
328 startpos = keys->
pos;
330 range = endpos - startpos;
331 time_step = range / (newsteps - 1);
339 for (i = 0; i < newsteps; i++) {
344 time = startpos + i * time_step;
346 if (i == newsteps - 1) {
354 k = kp1 = kp2 = km1 =
NULL;
359 loop, tkeys, &k, &kp1, &kp2, &km1,
366 if (len == 0.0 || nvk == 0) {
379 else if (!km1 && !kp2) {
387 x = (time - k->
pos) / len;
394 lderiv = (3 * (kp1->
fields[field] -
395 k->
fields[field]) / dt1 - rderiv) / 2.0;
397 kp1->
fields[field], x, x2, x3,
402 lderiv = (kp1->
fields[field] - km1->
fields[field]) / dt1;
403 rderiv = (3 * (kp1->
fields[field] -
404 k->
fields[field]) / dt2 - lderiv) / 2.0;
406 kp1->
fields[field], x, x2, x3,
411 lderiv = (kp1->
fields[field] - km1->
fields[field]) / dt1;
414 kp1->
fields[field], x, x2, x3,
463 *km1 = *kp1 = *kp2 = *km2 =
NULL;
466 for (i = 0; i < nvk; i++) {
467 if (time < karray[i]->pos) {
478 *km1 = karray[nvk - 1];
483 *km1 = karray[i - 1];
485 len = karray[i]->
pos - karray[i - 1]->
pos;
490 *km2 = karray[nvk - 2];
491 *kp2 = karray[(i + 1) % nvk];
495 *kp2 = karray[i + 1];
499 else if (i == nvk - 1) {
502 *km2 = nvk > 2 ? karray[i - 2] : karray[1];
507 *km2 = karray[i - 2];
512 *km2 = karray[i - 2];
513 *kp2 = karray[i + 1];
516 *dt1 = (*km2) ? (*kp1)->
pos - (*km2)->pos : len;
517 *dt2 = (*kp2) ? (*kp2)->pos - (*km1)->pos : len;
519 if (i == 1 && loop) {
523 if (i == nvk - 1 && loop) {
541 return ((
double)(val1 + dt * (val2 - val1)));
566 for (i = 0; i < nvk; i++) {
567 if (time < karray[i]->pos) {
578 *km1 = karray[nvk - 1];
583 *km1 = karray[i - 1];
585 len = karray[i]->
pos - karray[i - 1]->
pos;
605 int newsteps,
int loop)
610 float startpos, endpos, dt, range, time, time_step, len;
620 if (keys && keysteps) {
622 G_warning(
_(
"Need at least 2 keyframes for interpolation"));
628 for (k = keys; k->
next; k = k->
next) ;
630 startpos = keys->
pos;
632 range = endpos - startpos;
633 time_step = range / (newsteps - 1);
641 for (i = 0; i < newsteps; i++) {
646 time = startpos + i * time_step;
647 if (i == newsteps - 1) {
666 if (len == 0.0 || nvk == 0) {
678 dt = (time - k1->
pos) / len;
707 for (c = k; c; c = c->
next) {
710 for (t = c;
t; t = t->
next) {
715 for (t = k, j = 0; j < cnt; j++, t = t->
next) {
745 if (!views || !keys) {
759 for (frame = 0; frame < steps; frame++) {
769 for (k = keys; k; k = k->
next) {
void gk_free_key(Keylist *ok)
Free keyframe list.
void GS_set_viewdir(float *)
Set viewdir.
unsigned long gk_get_mask_sofar(float time, Keylist *keys)
Get mask value.
double lin_interp(float dt, float val1, float val2)
Linear interpolation.
void GS_draw_all_list(void)
Draw all glLists.
void GVL_alldraw_vol(void)
Draw all volume sets.
void G_free(void *)
Free allocated memory.
Viewnode * gk_make_framesfromkeys(Keylist *keys, int keysteps, int newsteps, int loop, float t)
Generate viewnode from keyframes.
void GS_alldraw_cplane_fences(void)
Draw all cplace fences ?
void correct_twist(Keylist *k)
Correct twist value.
unsigned int GS_background_color(void)
Get background color.
void GS_get_from(float *)
Get viewpoint 'from' position.
void GS_clear(int)
Clear view.
void GS_alldraw_wire(void)
Draw all wires.
int gk_draw_path(Viewnode *views, int steps, Keylist *keys)
Draw path.
Viewnode * gk_make_linear_framesfromkeys(Keylist *keys, int keysteps, int newsteps, int loop)
Generate viewnode from keyframe list (linear interpolation)
void gsd_colormode(int)
Set color mode.
double get_key_neighbors(int nvk, double time, double range, int loop, Keylist *karray[], Keylist **km1, Keylist **kp1, Keylist **kp2, Keylist **km2, double *dt1, double *dt2)
Find interval containing time.
int gk_viable_keys_for_mask(unsigned long mask, Keylist *keys, Keylist **keyret)
ADD.
void gsd_color_func(unsigned int)
Set current color.
void GS_set_twist(int)
Set viewpoint twist value.
void gsd_endline(void)
End line.
void GS_alldraw_surf(void)
Draw all surfaces.
void gsd_x(geosurf *, float *, int, float)
Draw X symbol.
void gk_follow_frames(Viewnode *view, int numsteps, Keylist *keys, int step, int onestep, int render, unsigned long mode)
Checks key masks.
void GP_alldraw_site(void)
Draw all available point sets.
float fields[KF_NUMFIELDS]
void GS_done_draw(void)
Draw done, swap buffers.
void GS_setlight_position(int, float, float, float, int)
Set light position.
void gsd_zwritemask(unsigned long)
Write out z-mask.
void gsd_linewidth(short)
Set width of rasterized lines.
void GS_get_viewdir(float *)
Get viewdir.
void G_warning(const char *,...) __attribute__((format(printf
void GS_moveto(float *)
Move viewpoint.
int GS_get_longdim(float *)
Get largest dimension.
unsigned int GS_default_draw_color(void)
Get default draw color.
void GS_getlight_position(int, float *, float *, float *, int *)
Get light position.
double get_2key_neighbors(int nvk, float time, float range, int loop, Keylist *karray[], Keylist **km1, Keylist **kp1)
Finds interval containing time, putting left (or equal) key at km1, right at kp1. ...
void GS_set_draw(int)
Sets which buffer to draw to.
int G_debug(int, const char *,...) __attribute__((format(printf
Keylist * gk_copy_key(Keylist *k)
Copy keyframes.
void gsd_bgnline(void)
Begin line.
float fields[KF_NUMFIELDS]
void GV_alldraw_vect(void)
Draw all loaded vector sets.
void GS_set_fov(int)
Set field of view.
void gsd_vert_func(float *)
ADD.