k_srbind_trick0,
k_srbind_trick1,
k_srbind_trick2,
+ k_srbind_sit,
k_srbind_use,
k_srbind_reset,
k_srbind_camera,
[k_srbind_mopen] = controller_glyph( SDL_CONTROLLER_BUTTON_GUIDE ),
[k_srbind_replay_play]= controller_glyph( SDL_CONTROLLER_BUTTON_X ),
[k_srbind_replay_freecam]=controller_glyph(SDL_CONTROLLER_BUTTON_Y ),
-[k_srbind_replay_resume]=controller_glyph( SDL_CONTROLLER_BUTTON_A )
+[k_srbind_replay_resume]=controller_glyph( SDL_CONTROLLER_BUTTON_A ),
+ [k_srbind_sit] = controller_glyph( SDL_CONTROLLER_BUTTON_B )
};
const char *keyboard_table[ k_srbind_max ] = {
[k_srbind_replay_play]= KEYBOARD_GLYPH( "G" ),
[k_srbind_replay_freecam] = KEYBOARD_GLYPH( "F" ),
[k_srbind_replay_resume]= "\xa1",
+ [k_srbind_sit] = KEYBOARD_GLYPH( "Z" )
};
if( vg_input.display_input_method == k_input_method_controller )
setbtn( k_srbind_replay_play, vg_getkey(SDLK_g) );
setbtn( k_srbind_replay_freecam, vg_getkey(SDLK_f) );
setbtn( k_srbind_replay_resume, vg_getkey(SDLK_SPACE) );
+ setbtn( k_srbind_sit, vg_getkey(SDLK_z) );
/* axis
* --------------------------------------------*/
setbtn( k_srbind_replay_resume, buttons[ SDL_CONTROLLER_BUTTON_A ] );
setbtn( k_srbind_replay_play, buttons[ SDL_CONTROLLER_BUTTON_X ] );
setbtn( k_srbind_replay_freecam, buttons[ SDL_CONTROLLER_BUTTON_Y ] );
+ setbtn( k_srbind_sit, buttons[ SDL_CONTROLLER_BUTTON_B ] );
float *axis = controller->axises;
float *steer = srinput.joystick_states[ k_srjoystick_steer ][0],
static void player__walk_update(void){
struct player_walk *w = &player_walk;
+
+ v2f steer;
+ joystick_state( k_srjoystick_steer, steer );
+
+ if( w->state.activity == k_walk_activity_sit ){
+ if( w->state.sit_t < 1.0f )
+ w->state.sit_t += vg.time_delta;
+ else {
+ w->state.sit_t = 1.0f;
+
+ if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) ||
+ button_down(k_srbind_jump) ){
+ w->state.activity = k_walk_activity_sit_up;
+ }
+ }
+ return;
+ }
+ else if( w->state.activity == k_walk_activity_sit_up ){
+ if( w->state.sit_t > 0.0f ){
+ w->state.sit_t -= vg.time_delta;
+ return;
+ }
+ }
+ else
+ w->state.sit_t = 0.0f;
+
v3_copy( localplayer.rb.co, w->state.prev_pos );
v3_zero( localplayer.rb.w );
m3x3_mulv( localplayer.basis, forward_dir, forward_dir );
m3x3_mulv( localplayer.basis, right_dir, right_dir );
- v2f steer;
- joystick_state( k_srjoystick_steer, steer );
w->move_speed = localplayer.immobile? 0.0f: v2_length( steer );
if( w->state.activity == k_walk_activity_ground ){
v3_normalize( surface_avg );
+ if( button_down(k_srbind_sit) ){
+ w->state.activity = k_walk_activity_sit;
+ return;
+ }
+
v3f tx, ty;
v3_tangent_basis( surface_avg, tx, ty );
w->state.walk_timer = 0.0f;
animator->walk_timer = w->state.walk_timer;
+
if( !localplayer.immobile )
rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q );
else{
}
f32 walk_yaw = player_get_heading_yaw();
+
+ /* sitting */
+ animator->sit_t = w->state.sit_t;
+
+ {
+ f32 head_yaw = localplayer.angles[0] + VG_PIf,
+ y = vg_angle_diff( head_yaw, -walk_yaw ),
+ mp = VG_PIf / 4.0f,
+ p = vg_clampf( localplayer.angles[1], -mp, mp );
+
+ if( fabsf(y) > VG_PIf/1.7f ){
+ y = 0.0f;
+ p = 0.0f;
+ }
+ animator->yaw = vg_lerpf( animator->yaw, y, vg.time_delta*2.0f );
+ animator->pitch = vg_lerpf( animator->pitch, p, vg.time_delta*2.8f );
+ }
+
if( w->state.outro_type ){
struct player_avatar *av = localplayer.playeravatar;
struct skeleton_anim *anim =
skeleton_sample_anim( sk, w->anim_jump, vg.time*0.6f, bpose );
skeleton_lerp_pose( sk, apose, bpose, animator->fly, apose );
+ /* sit */
+ if( animator->sit_t > 0.0f ){
+ f32 sit_norm = (f32)(w->anim_sit->length-1)/30.0f,
+ st = vg_minf( 1.0f, animator->sit_t );
+ skeleton_sample_anim( sk, w->anim_sit, st*sit_norm, bpose );
+
+ v4f qy,qp;
+ f32 *qh = bpose[av->id_head-1].q;
+ q_axis_angle( qy, (v3f){0.0f,1.0f,0.0f}, animator->yaw*0.5f*st );
+ q_axis_angle( qp, (v3f){0.0f,0.0f,1.0f}, animator->pitch*st );
+ q_mul( qy, qh, qh );
+ q_mul( qh, qp, qh );
+ q_normalize( qh );
+
+ qh = bpose[av->id_chest-1].q;
+ q_axis_angle( qy, (v3f){0.0f,1.0f,0.0f}, animator->yaw*0.5f*st );
+ q_mul( qy, qh, qh );
+ q_normalize( qh );
+
+ skeleton_lerp_pose( sk, apose, bpose, vg_minf(1.0f,st*10.0f), apose );
+ }
+
if( animator->outro_type ){
struct skeleton_anim *anim = player_walk_outro_anim(animator->outro_type);
(const char *[]){ "k_walk_activity_air",
"k_walk_activity_ground",
"k_walk_activity_sleep",
- "k_walk_activity_lockedmove" }
+ "k_walk_activity_lockedmove",
+ "k_walk_activity_sit",
+ "k_walk_activity_sit_up" }
[w->state.activity] );
player__debugtext( 1, "surface: %s\n",
(const char *[]){ "concrete",
w->anim_jump_to_air = skeleton_get_anim( sk, "jump_to_air" );
w->anim_drop_in = skeleton_get_anim( sk, "drop_in" );
w->anim_intro = skeleton_get_anim( sk, "into_skate" );
+ w->anim_sit = skeleton_get_anim( sk, "sit" );
}
static void player__walk_transition(void){