22#include <grass/glocale.h>
23#include <grass/ogsf.h>
25static int _add_key(Keylist *,
int,
float);
26static void _remove_key(Keylist *);
28static Keylist *Keys =
NULL;
29static Keylist *Keytail =
NULL;
30static Viewnode *Views =
NULL;
31static float Keystartpos = 0.0;
32static float Keyendpos = 1.0;
33static float Tension = 0.8;
34static int Viewsteps = 0;
35static int Numkeys = 0;
36static int Interpmode = KF_SPLINE;
40static int _add_key(Keylist *newk,
int force_replace,
float precis)
42 Keylist *k, *tempk, *prev;
49 for (k = Keys; k; k = k->next) {
50 if (k->pos >= newk->pos - precis && k->pos <= newk->pos + precis) {
54 k->prior->next = newk;
62 newk->prior = k->prior;
76 if (newk->pos < Keys->pos) {
85 if (k->pos > newk->pos) {
97 Keytail = prev->next = newk;
103 Keys = Keytail = newk;
110static void _remove_key(Keylist *k)
113 k->prior->next = k->next;
115 k->next->prior = k->prior;
124 k->next->prior =
NULL;
127 k->next = k->prior =
NULL;
142 if (KF_LEGAL_MODE(mode)) {
157 Tension = tens > 1.0 ? 1.0 : (tens < 0.0 ? 0.0 : tens);
215 if (
NULL == (fp = fopen(
name,
"w"))) {
219 fprintf(fp,
"30 \n");
221 for (k = Keys; k; k = k->next) {
224 "{%f {{FromX %f} {FromY %f} {FromZ %f} {DirX %f} {DirY %f} "
225 "{DirZ %f} {FOV %f} {TWIST %f} {cplane-0 {{pos_x 0.000000} "
226 "{pos_y 0.000000} {pos_z 0.000000} {blend_type OFF} {rot "
227 "0.000000} {tilt 0.000000}}}} keyanimtag%d 0} ",
228 k->pos, k->fields[KF_FROMX], k->fields[KF_FROMY],
229 k->fields[KF_FROMZ], k->fields[KF_DIRX], k->fields[KF_DIRY],
230 k->fields[KF_DIRZ], k->fields[KF_FOV] / 10.,
231 k->fields[KF_TWIST], cnt);
255 if (k->fields[KF_FROMX] == Keys->fields[KF_FROMX] &&
256 k->fields[KF_FROMY] == Keys->fields[KF_FROMY] &&
257 k->fields[KF_FROMZ] == Keys->fields[KF_FROMZ]) {
262 Keystartpos = Keys->pos;
265 if (Interpmode == KF_LINEAR && Numkeys > 1) {
274 G_warning(_(
"Check no. of frames requested and keyframes marked"));
277 else if (Numkeys > 2) {
287 G_warning(_(
"Check no. of frames requested and keyframes marked"));
301 Viewsteps = newsteps;
342 for (k = Keys; k; k = k->next) {
343 if (k->pos >= oldpos - precis && k->pos <= oldpos + precis) {
346 _add_key(k, 1, precis);
374 for (cnt = 0, k = Keys; k;) {
377 if (k->pos >= pos - precis && k->pos <= pos + precis) {
431int GK_add_key(
float pos,
unsigned long fmask,
int force_replace,
float precis)
436 if (
NULL == (newk = (Keylist *)malloc(
sizeof(Keylist)))) {
437 fprintf(stderr,
"Out of memory\n");
444 newk->fields[KF_FROMX] = tmp[
X];
445 newk->fields[KF_FROMY] = tmp[
Y];
446 newk->fields[KF_FROMZ] = tmp[Z];
448 G_debug(3,
"KEY FROM: %f %f %f", tmp[
X], tmp[
Y], tmp[Z]);
459 newk->fields[KF_DIRX] = tmp[
X];
460 newk->fields[KF_DIRY] = tmp[
Y];
461 newk->fields[KF_DIRZ] = tmp[Z];
466 newk->fieldmask = fmask;
470 if (0 < _add_key(newk, force_replace, precis)) {
490 if (step > 0 && step <= Viewsteps) {
int G_debug(int level, const char *msg,...)
Print debugging message.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void G_warning(const char *msg,...)
Print a warning message to stderr.
void GK_set_tension(float tens)
Set value for tension when interpmode is KF_SPLINE.
int GK_set_interpmode(int mode)
Set interpolation mode.
void GK_show_vol(int flag)
Show volumes.
void GK_do_framestep(int step, int render)
Moves the animation to frame number "step".
void GK_show_vect(int flag)
Show vector sets.
void GK_update_tension(void)
Update tension.
void GK_showtension_stop(void)
Show tension stop ?
void GK_showtension_start(void)
void GK_show_path(int flag)
Draw the current path.
void GK_show_list(int flag)
Show list.
void GK_print_keys(const char *name)
Print keyframe info.
void GK_show_site(int flag)
Show point sets.
int GK_delete_key(float pos, float precis, int justone)
void GK_set_numsteps(int newsteps)
Set the number of frames to be interpolated from keyframes.
void GK_update_frames(void)
Recalculate path using the current number of frames requested.
int GK_move_key(float oldpos, float precis, float newpos)
Move keyframe.
int GK_add_key(float pos, unsigned long fmask, int force_replace, float precis)
Add keyframe.
void GK_clear_keys(void)
Deletes all keyframes, resets field masks.
void gk_free_key(Keylist *ok)
Free keyframe list.
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)
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.
int GS_get_twist(void)
Get twist value.
void GS_draw_all_list(void)
Draw all glLists.
void GS_get_from(float *fr)
Get viewpoint 'from' position.
void GS_get_viewdir(float *dir)
Get viewdir.
void GS_alldraw_wire(void)
Draw all wires.
void GS_clear(int col)
Clear view.
int GS_get_fov(void)
Get field of view.
unsigned int GS_background_color(void)
Get background color.
void GS_set_draw(int where)
Sets which buffer to draw to.
void GS_done_draw(void)
Draw done, swap buffers.
void GV_alldraw_vect(void)
Draw all loaded vector sets.
void GVL_alldraw_vol(void)
Draw all volume sets.