27 static float spl3(
float,
double,
double,
double,
double,
double,
double,
30 static float spl3(
float tension,
double data0,
double data1,
double x,
31 double x2,
double x3,
double lderiv,
double rderiv)
33 return ((
float)(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;
92 curpos = startpos + time * (endpos - startpos);
94 for (k = keys; k->
next; k = k->
next) {
95 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;
319 if (keys && keysteps) {
321 G_warning(
_(
"Need at least 3 keyframes for spline"));
327 for (k = keys; k->
next; k = k->
next)
330 startpos = keys->
pos;
332 range = endpos - startpos;
333 time_step = range / (newsteps - 1);
342 for (i = 0; i < newsteps; i++) {
347 time = startpos + i * time_step;
349 if (i == newsteps - 1) {
357 k = kp1 = kp2 = km1 =
NULL;
362 &kp1, &kp2, &km1, &dt1, &dt2);
369 if (len == 0.0 || nvk == 0) {
382 else if (!km1 && !kp2) {
390 x = (time - k->
pos) / len;
407 lderiv = (kp1->
fields[field] - km1->
fields[field]) / dt1;
418 lderiv = (kp1->
fields[field] - km1->
fields[field]) / dt1;
469 *km1 = *kp1 = *kp2 = *km2 =
NULL;
472 for (i = 0; i < nvk; i++) {
473 if (time < karray[i]->pos) {
484 *km1 = karray[nvk - 1];
489 *km1 = karray[i - 1];
491 len = karray[i]->
pos - karray[i - 1]->
pos;
496 *km2 = karray[nvk - 2];
497 *kp2 = karray[(i + 1) % nvk];
501 *kp2 = karray[i + 1];
505 else if (i == nvk - 1) {
508 *km2 = nvk > 2 ? karray[i - 2] : karray[1];
513 *km2 = karray[i - 2];
518 *km2 = karray[i - 2];
519 *kp2 = karray[i + 1];
522 *dt1 = (*km2) ? (*kp1)->
pos - (*km2)->pos : len;
523 *dt2 = (*kp2) ? (*kp2)->pos - (*km1)->pos : len;
525 if (i == 1 && loop) {
529 if (i == nvk - 1 && loop) {
547 return ((
double)(val1 + dt * (val2 - val1)));
573 for (i = 0; i < nvk; i++) {
574 if (time < karray[i]->pos) {
585 *km1 = karray[nvk - 1];
590 *km1 = karray[i - 1];
592 len = karray[i]->
pos - karray[i - 1]->
pos;
612 int newsteps,
int loop)
617 float startpos, endpos, dt, range, time, time_step, len;
628 if (keys && keysteps) {
630 G_warning(
_(
"Need at least 2 keyframes for interpolation"));
636 for (k = keys; k->
next; k = k->
next)
639 startpos = keys->
pos;
641 range = endpos - startpos;
642 time_step = range / (newsteps - 1);
651 for (i = 0; i < newsteps; i++) {
656 time = startpos + i * time_step;
657 if (i == newsteps - 1) {
678 if (len == 0.0 || nvk == 0) {
690 dt = (time - k1->
pos) / len;
718 for (c = k; c; c = c->
next) {
721 for (
t = c;
t;
t =
t->next) {
726 for (
t = k, j = 0; j < cnt; j++,
t =
t->next) {
756 if (!views || !keys) {
770 for (frame = 0; frame < steps; frame++) {
779 for (k = keys; k; k = k->
next) {
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
void GS_alldraw_cplane_fences(void)
Draw all cplace fences ?
void GS_draw_all_list(void)
Draw all glLists.
void GS_set_fov(int)
Set field of view.
void GS_get_viewdir(float *)
Get viewdir.
void GS_set_draw(int)
Sets which buffer to draw to.
unsigned int GS_default_draw_color(void)
Get default draw color.
void GS_get_from(float *)
Get viewpoint 'from' position.
void GS_alldraw_wire(void)
Draw all wires.
void gsd_x(geosurf *, float *, int, float)
Draw X symbol.
int GS_get_longdim(float *)
Get largest dimension.
void GS_set_twist(int)
Set viewpoint twist value.
void GS_setlight_position(int, float, float, float, int)
Set light position.
void GS_getlight_position(int, float *, float *, float *, int *)
Get light position.
void GS_set_viewdir(float *)
Set viewdir.
void GS_moveto(float *)
Move viewpoint.
void GV_alldraw_vect(void)
Draw all loaded vector sets.
void gsd_color_func(unsigned int)
Set current color.
void GVL_alldraw_vol(void)
Draw all volume sets.
unsigned int GS_background_color(void)
Get background color.
void GS_alldraw_surf(void)
Draw all surfaces.
void gsd_zwritemask(unsigned long)
Write out z-mask.
void gsd_linewidth(short)
Set width of rasterized lines.
void gsd_endline(void)
End line.
void gsd_colormode(int)
Set color mode.
void GS_clear(int)
Clear view.
void gsd_bgnline(void)
Begin line.
void GS_done_draw(void)
Draw done, swap buffers.
void gsd_vert_func(float *)
ADD.
void GP_alldraw_site(void)
Draw all available point sets.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
double lin_interp(float dt, float val1, float val2)
Linear interpolation.
void correct_twist(Keylist *k)
Correct twist value.
unsigned long gk_get_mask_sofar(float time, Keylist *keys)
Get mask value.
Keylist * gk_copy_key(Keylist *k)
Copy keyframes.
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.
void gk_free_key(Keylist *ok)
Free keyframe list.
double get_2key_neighbors(int nvk, float time, float range UNUSED, int loop UNUSED, Keylist *karray[], Keylist **km1, Keylist **kp1)
Finds interval containing time, putting left (or equal) key at km1, right at kp1.
int gk_draw_path(Viewnode *views, int steps, Keylist *keys)
Draw path.
Viewnode * gk_make_framesfromkeys(Keylist *keys, int keysteps, int newsteps, int loop, float t)
Generate viewnode from keyframes.
Viewnode * gk_make_linear_framesfromkeys(Keylist *keys, int keysteps, int newsteps, int loop)
Generate viewnode from keyframe list (linear interpolation)
int gk_viable_keys_for_mask(unsigned long mask, Keylist *keys, Keylist **keyret)
ADD.
void gk_follow_frames(Viewnode *view, int numsteps, Keylist *keys, int step, int onestep, int render, unsigned long mode)
Checks key masks.
float fields[KF_NUMFIELDS]
float fields[KF_NUMFIELDS]