GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bceeab9228
gk2.c File Reference

OGSF library - setting and manipulating keyframes animation. More...

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

Go to the source code of this file.

Functions

int GK_set_interpmode (int mode)
 Set interpolation mode. More...
 
void GK_set_tension (float tens)
 Set value for tension when interpmode is KF_SPLINE. More...
 
void GK_showtension_start (void)
 
void GK_showtension_stop (void)
 Show tension stop ? More...
 
void GK_update_tension (void)
 Update tension. More...
 
void GK_print_keys (const char *name)
 Print keyframe info. More...
 
void GK_update_frames (void)
 Recalculate path using the current number of frames requested. More...
 
void GK_set_numsteps (int newsteps)
 Set the number of frames to be interpolated from keyframes. More...
 
void GK_clear_keys (void)
 Deletes all keyframes, resets field masks. More...
 
int GK_move_key (float oldpos, float precis, float newpos)
 Move keyframe. More...
 
int GK_delete_key (float pos, float precis, int justone)
 
int GK_add_key (float pos, unsigned long fmask, int force_replace, float precis)
 Add keyframe. More...
 
void GK_do_framestep (int step, int render)
 Moves the animation to frame number "step". More...
 
void GK_show_path (int flag)
 Draw the current path. More...
 
void GK_show_vect (int flag)
 Show vector sets. More...
 
void GK_show_site (int flag)
 Show point sets. More...
 
void GK_show_vol (int flag)
 Show volumes. More...
 
void GK_show_list (int flag)
 Show list. More...
 

Detailed Description

OGSF library - setting and manipulating keyframes animation.

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 gk2.c.

Function Documentation

◆ GK_add_key()

int GK_add_key ( float  pos,
unsigned long  fmask,
int  force_replace,
float  precis 
)

Add keyframe.

The pos value is the relative position in the animation for this particular keyframe - used to compare relative distance to neighboring keyframes, it can be any floating point value.

The fmask value can be any of the following or'd together:

  • KF_FROMX_MASK
  • KF_FROMY_MASK
  • KF_FROMZ_MASK
  • KF_FROM_MASK (KF_FROMX_MASK | KF_FROMY_MASK | KF_FROMZ_MASK)
  • KF_DIRX_MASK
  • KF_DIRY_MASK
  • KF_DIRZ_MASK
  • KF_DIR_MASK (KF_DIRX_MASK | KF_DIRY_MASK | KF_DIRZ_MASK)
  • KF_FOV_MASK
  • KF_TWIST_MASK
  • KF_ALL_MASK (KF_FROM_MASK | KF_DIR_MASK | KF_FOV_MASK | KF_TWIST_MASK)

Other fields will be added later.

The value precis and the boolean force_replace are used to determine if a keyframe should be considered to be at the same position as a pre-existing keyframe. e.g., if anykey.pos - newkey.pos <= precis, GK_add_key() will fail unless force_replace is TRUE.

Parameters
posposition
fmaks
force_replace
precisprecision value
Returns
1 if key is added
-1 key not added

Definition at line 431 of file gk2.c.

◆ GK_clear_keys()

void GK_clear_keys ( void  )

Deletes all keyframes, resets field masks.

Doesn't change number of frames requested.

Definition at line 312 of file gk2.c.

References gk_free_key().

◆ GK_delete_key()

int GK_delete_key ( float  pos,
float  precis,
int  justone 
)

Delete keyframe

The values pos and precis are used to determine which keyframes to delete. Any keyframes with their position within precis of pos will be deleted if justone is zero. If justone is non-zero, only the first (lowest pos) keyframe in the range will be deleted.

Parameters
posposition
precisprecision
justonedelete only one keyframe
Returns
number of keys deleted.

Definition at line 369 of file gk2.c.

◆ GK_do_framestep()

void GK_do_framestep ( int  step,
int  render 
)

Moves the animation to frame number "step".

Step should be a value between 1 and the number of frames. If render is non-zero, calls draw_all.

Parameters
stepstep value
render

Definition at line 487 of file gk2.c.

◆ GK_move_key()

int GK_move_key ( float  oldpos,
float  precis,
float  newpos 
)

Move keyframe.

Precis works as in other functions - to identify keyframe to move. Only the first keyframe in the precis range will be moved.

Parameters
oldposold position
precisprecision value
newposnew position
Returns
number of keys moved (1 or 0)

Definition at line 338 of file gk2.c.

◆ GK_print_keys()

void GK_print_keys ( const char *  name)

Print keyframe info.

Parameters
namefilename

Definition at line 209 of file gk2.c.

References _, G_fatal_error(), name, and NULL.

◆ GK_set_interpmode()

int GK_set_interpmode ( int  mode)

Set interpolation mode.

Parameters
modeinterpolation mode (KF_LINEAR or KF_SPLINE)
Returns
1 on success
-1 on error (invalid interpolation mode)

Definition at line 140 of file gk2.c.

◆ GK_set_numsteps()

void GK_set_numsteps ( int  newsteps)

Set the number of frames to be interpolated from keyframes.

Parameters
newstepsnumber of frames

Definition at line 299 of file gk2.c.

◆ GK_set_tension()

void GK_set_tension ( float  tens)

Set value for tension when interpmode is KF_SPLINE.

Parameters
tensvalue tens should be between 0.0; 1.0.

Definition at line 155 of file gk2.c.

◆ GK_show_list()

void GK_show_list ( int  flag)

Show list.

Parameters
flag

Definition at line 609 of file gk2.c.

◆ GK_show_path()

void GK_show_path ( int  flag)

Draw the current path.

Parameters
flag

Definition at line 503 of file gk2.c.

◆ GK_show_site()

void GK_show_site ( int  flag)

Show point sets.

Parameters
flag

Definition at line 555 of file gk2.c.

◆ GK_show_vect()

void GK_show_vect ( int  flag)

Show vector sets.

Parameters
flag

Definition at line 529 of file gk2.c.

◆ GK_show_vol()

void GK_show_vol ( int  flag)

Show volumes.

Parameters
flag

Definition at line 582 of file gk2.c.

◆ GK_showtension_start()

void GK_showtension_start ( void  )

Definition at line 175 of file gk2.c.

◆ GK_showtension_stop()

void GK_showtension_stop ( void  )

Show tension stop ?

Use GK_showtension_start/GK_update_tension/GK_showtension_stop to initialize and stop multi-view display of path when changing tension.

Definition at line 187 of file gk2.c.

◆ GK_update_frames()

void GK_update_frames ( void  )

Recalculate path using the current number of frames requested.

Call after changing number of frames or when Keyframes change.

Definition at line 245 of file gk2.c.

◆ GK_update_tension()

void GK_update_tension ( void  )

Update tension.

Definition at line 195 of file gk2.c.