Back to index

extremetuxracer  0.5beta
Functions
keyframe.h File Reference
#include "pp_types.h"
#include "player.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void get_key_frame_data (key_frame_t **fp, int *n)
void init_key_frame ()
void reset_key_frame ()
void update_key_frame (Player &plyr, double dt)
void mirror_keyframe ()
void register_key_frame_callbacks (Tcl_Interp *ip)

Function Documentation

void get_key_frame_data ( key_frame_t **  fp,
int *  n 
)

Definition at line 35 of file keyframe.cpp.

{
    *fp = frames;
    *n = numFrames;
}

Here is the caller graph for this function:

void init_key_frame ( )

Definition at line 47 of file keyframe.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void mirror_keyframe ( )
void register_key_frame_callbacks ( Tcl_Interp *  ip)

Definition at line 248 of file keyframe.cpp.

{
    Tcl_CreateCommand (ip, "tux_key_frame", key_frame_cb,  0,0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void reset_key_frame ( )

Definition at line 41 of file keyframe.cpp.

{
    keyTime = 0;
    numFrames = 0;
} 

Here is the caller graph for this function:

void update_key_frame ( Player plyr,
double  dt 
)

Definition at line 60 of file keyframe.cpp.

{
    int idx;
    double frac;
    pp::Vec3d pos;
    double v;
    pp::Matrix cob_mat, rot_mat;

    char *root;
    char *lsh;
    char *rsh;
    char *lhp;
    char *rhp;
    char *lkn;
    char *rkn;
    char *lank;
    char *rank;
    char *head;
    char *neck;
    char *tail;

    root = ModelHndl->get_tux_root_node();
    lsh  = ModelHndl->get_tux_left_shoulder_joint();
    rsh  = ModelHndl->get_tux_right_shoulder_joint();
    lhp  = ModelHndl->get_tux_left_hip_joint();
    rhp  = ModelHndl->get_tux_right_hip_joint();
    lkn  = ModelHndl->get_tux_left_knee_joint();
    rkn  = ModelHndl->get_tux_right_knee_joint();
    lank = ModelHndl->get_tux_left_ankle_joint();
    rank = ModelHndl->get_tux_right_ankle_joint();
    head = ModelHndl->get_tux_head();
    neck = ModelHndl->get_tux_neck();
    tail = ModelHndl->get_tux_tail_joint();

    keyTime += dt;

    for (idx = 1; idx < numFrames; idx ++) {
        if ( keyTime < frames[idx].time )
            break;
    } 

    if ( idx == numFrames || numFrames == 0 ) {
        set_game_mode( RACING );
        return;
    } 

    reset_scene_node( root );
    reset_scene_node( lsh );
    reset_scene_node( rsh );
    reset_scene_node( lhp );
    reset_scene_node( rhp );
    reset_scene_node( lkn );
    reset_scene_node( rkn );
    reset_scene_node( lank );
    reset_scene_node( rank );
    reset_scene_node( head );
    reset_scene_node( neck );
    reset_scene_node( tail );

    check_assertion( idx > 0, "invalid keyframe index" );

    if ( fabs( frames[idx-1].time - frames[idx].time ) < EPS ) {
       frac = 1.;
    } else {
       frac = (keyTime - frames[idx].time) 
           / ( frames[idx-1].time - frames[idx].time );
    }

    pos.x = interp( frac, frames[idx-1].pos.x, frames[idx].pos.x );
    pos.z = interp( frac, frames[idx-1].pos.z, frames[idx].pos.z );
    pos.y = interp( frac, frames[idx-1].pos.y, frames[idx].pos.y );
    pos.y += find_y_coord( pos.x, pos.z );

    set_tux_pos( plyr, pos );

       cob_mat.makeIdentity();

    v = interp( frac, frames[idx-1].yaw, frames[idx].yaw );
    rotate_scene_node( root, 'y', v );
    rot_mat.makeRotation( v, 'y' );
    cob_mat=cob_mat*rot_mat;

    v = interp( frac, frames[idx-1].pitch, frames[idx].pitch );
    rotate_scene_node( root, 'x', v );
    rot_mat.makeRotation( v, 'x' );
    cob_mat=cob_mat*rot_mat;

    v = interp( frac, frames[idx-1].l_shldr, frames[idx].l_shldr );
    rotate_scene_node( lsh, 'z', v );

    v = interp( frac, frames[idx-1].r_shldr, frames[idx].r_shldr );
    rotate_scene_node( rsh, 'z', v );

    v = interp( frac, frames[idx-1].l_hip, frames[idx].l_hip );
    rotate_scene_node( lhp, 'z', v );

    v = interp( frac, frames[idx-1].r_hip, frames[idx].r_hip );
    rotate_scene_node( rhp, 'z', v );

    /* Set orientation */
    plyr.orientation = pp::Matrix( cob_mat); //make_quaternion_from_matrix( cob_mat );
    plyr.orientation_initialized = true;
} 

Here is the call graph for this function:

Here is the caller graph for this function: