GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71817
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gk.c File Reference

OGSF library - setting and manipulating keyframes animation (lower level functions) More...

#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/ogsf.h>
Include dependency graph for gk.c:

Go to the source code of this file.

Functions

Keylistgk_copy_key (Keylist *k)
 Copy keyframes. More...
 
unsigned long gk_get_mask_sofar (float time, Keylist *keys)
 Get mask value. More...
 
int gk_viable_keys_for_mask (unsigned long mask, Keylist *keys, Keylist **keyret)
 ADD. More...
 
void gk_follow_frames (Viewnode *view, int numsteps, Keylist *keys, int step, int onestep, int render, unsigned long mode)
 Checks key masks. More...
 
void gk_free_key (Keylist *ok)
 Free keyframe list. More...
 
Viewnodegk_make_framesfromkeys (Keylist *keys, int keysteps, int newsteps, int loop, float t)
 Generate viewnode from keyframes. More...
 
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. More...
 
double lin_interp (float dt, float val1, float val2)
 Linear interpolation. More...
 
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. More...
 
Viewnodegk_make_linear_framesfromkeys (Keylist *keys, int keysteps, int newsteps, int loop)
 Generate viewnode from keyframe list (linear interpolation) More...
 
void correct_twist (Keylist *k)
 Correct twist value. More...
 
int gk_draw_path (Viewnode *views, int steps, Keylist *keys)
 Draw path. More...
 

Detailed Description

OGSF library - setting and manipulating keyframes animation (lower level functions)

GRASS OpenGL gsurf OGSF Library

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Bill Brown USACERL, GMSL/University of Illinois
Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)

Definition in file gk.c.

Function Documentation

void correct_twist ( Keylist k)

Correct twist value.

Parameters
kkeyframe list

Definition at line 700 of file gk.c.

References key_node::fields, KF_TWIST, key_node::next, NULL, and t.

Referenced by gk_make_framesfromkeys(), and gk_make_linear_framesfromkeys().

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.

Parameters
nvk
time
range
loop
karray
km1
km2
Returns
interval value

Definition at line 558 of file gk.c.

References NULL, and key_node::pos.

Referenced by gk_make_linear_framesfromkeys().

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.

Changed June 94 to handle masks - now need to have called get_viable_keys for appropriate mask first to build the ARRAY of viable keyframes.

Putting left (or equal) key at km1, right at kp1, 2nd to right at kp2, and second to left at km2. dt1 is given the length of the current + left intervals dt2 is given the length of the current + right intervals

Parameters
nvk
time
range
loop
karray
km1
kp1
kp2
km2
dt1
dt2
Returns
the length of the current interval
0 on error

Definition at line 455 of file gk.c.

References NULL, and key_node::pos.

Referenced by gk_make_framesfromkeys().

Keylist* gk_copy_key ( Keylist k)

Copy keyframes.

Parameters
ksource keyframes
Returns
pointer to Keylist struct (target)

Definition at line 45 of file gk.c.

References key_node::fieldmask, key_node::fields, KF_NUMFIELDS, key_node::look_ahead, key_node::next, NULL, key_node::pos, and key_node::prior.

int gk_draw_path ( Viewnode views,
int  steps,
Keylist keys 
)

Draw path.

Parameters
viewsViewnode struct
stepsstep value
keyskeyframe list
Returns
0 on failure
1 on success

Definition at line 738 of file gk.c.

References CM_COLOR, view_node::fields, key_node::fields, GS_background_color(), GS_default_draw_color(), GS_get_from(), GS_get_longdim(), gsd_bgnline(), gsd_color_func(), gsd_colormode(), gsd_endline(), gsd_linewidth(), gsd_vert_func(), gsd_x(), gsd_zwritemask(), KF_FROMX, key_node::next, and NULL.

Referenced by gk_follow_frames(), GK_set_tension(), and GK_show_path().

void gk_follow_frames ( Viewnode view,
int  numsteps,
Keylist keys,
int  step,
int  onestep,
int  render,
unsigned long  mode 
)
void gk_free_key ( Keylist ok)

Free keyframe list.

Parameters
okpointer to Keylist struct

Definition at line 271 of file gk.c.

References G_free(), and key_node::next.

Referenced by GK_clear_keys().

unsigned long gk_get_mask_sofar ( float  time,
Keylist keys 
)

Get mask value.

Get begin & end pos, AND all masks in keys <= pos

Time must be between 0.0 & 1.0

Parameters
timetimestamp
keyslist of keyframes
Returns
mask value

Definition at line 79 of file gk.c.

References key_node::fieldmask, key_node::next, and key_node::pos.

Referenced by gk_follow_frames().

Viewnode* gk_make_framesfromkeys ( Keylist keys,
int  keysteps,
int  newsteps,
int  loop,
float  t 
)

Generate viewnode from keyframes.

Here we use a cardinal cubic spline

Parameters
keyslist of keyframes
keystepskeyframe step
newstepsnew step value
looploop indicator
t
Returns
pointer to Viewnode
NULL on failure

Definition at line 301 of file gk.c.

References _, correct_twist(), view_node::fields, key_node::fields, G_free(), G_warning(), get_key_neighbors(), gk_viable_keys_for_mask(), KF_NUMFIELDS, lin_interp(), key_node::next, NULL, key_node::pos, and x.

Referenced by GK_update_frames().

Viewnode* gk_make_linear_framesfromkeys ( Keylist keys,
int  keysteps,
int  newsteps,
int  loop 
)

Generate viewnode from keyframe list (linear interpolation)

Here we use linear interpolation. Loop variable isn't used, but left in for use in possible "linear interp with smoothing" version.

Parameters
kesykeyframe list
keystepsstep value
newstepsnew step value
looploop indicator
pointerto viewnode struct
NULLon failure

Definition at line 604 of file gk.c.

References _, correct_twist(), view_node::fields, key_node::fields, G_free(), G_warning(), get_2key_neighbors(), gk_viable_keys_for_mask(), KF_NUMFIELDS, lin_interp(), key_node::next, NULL, and key_node::pos.

Referenced by GK_update_frames().

int gk_viable_keys_for_mask ( unsigned long  mask,
Keylist keys,
Keylist **  keyret 
)

ADD.

Parameters
maskmask value
keyslist of keyframes
[out]keyretoutput list of keyframes
Returns
number of output keyframes

Definition at line 112 of file gk.c.

References key_node::fieldmask, and key_node::next.

Referenced by gk_make_framesfromkeys(), and gk_make_linear_framesfromkeys().

double lin_interp ( float  dt,
float  val1,
float  val2 
)

Linear interpolation.

Parameters
dtcoeficient
val2value 2
val1value 1
Returns
val1 + dt * (val2 - val1)

Definition at line 539 of file gk.c.

Referenced by gk_make_framesfromkeys(), and gk_make_linear_framesfromkeys().