v3_copy( v, player_skate.state.cog_v );
v3_copy( v, localplayer.rb.v );
- player__begin_holdout();
+ player__begin_holdout( (v3f){0.0f,0.0f,0.0f} );
player__skate_reset_animator();
player__skate_clear_mechanics();
rb_update_transform( &localplayer.rb );
player_skate.state.activity_prev = k_skate_activity_ground;
player_skate.state.activity = k_skate_activity_ground;
- player__begin_holdout();
+ player__begin_holdout( (v3f){0.0f,0.0f,0.0f} );
player__skate_clear_mechanics();
player__skate_reset_animator();
static struct skeleton_anim *player_walk_outro_anim( enum walk_outro type ){
struct player_walk *w = &player_walk;
+ if( type >= k_walk_outro_max )
+ return NULL;
+
return (struct skeleton_anim *[]){
[k_walk_outro_none] = NULL,
[k_walk_outro_jump_to_air] = w->anim_jump_to_air,
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 ),
+ p = vg_clampf( localplayer.angles[1],
+ -k_sit_pitch_limit, k_sit_pitch_limit );
+
+ if( fabsf(y) > k_sit_yaw_limit ){
+ 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);
+
+ if( !anim ){
+ skeleton_copy_pose( sk, apose, pose->keyframes );
+ return;
+ }
f32 outro_length = (f32)anim->length / anim->rate,
outro_time = animator->outro_t*outro_length;
(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){
bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->walk );
bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->walk_timer );
- bitpack_bytes( ctx, 8, &animator->outro_type );
- if( animator->outro_type ){
- bitpack_bytes(ctx, sizeof(animator->foot_anchor), animator->foot_anchor );
- bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->outro_t );
- bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->commit_t );
+ for( int i=0; i<1; i++ ){ /* without this you get a warning from gcc. lol */
+ bitpack_bytes( ctx, 8, &animator->outro_type );
+ if( animator->outro_type ){
+ bitpack_bytes( ctx, sizeof(animator->foot_anchor),
+ animator->foot_anchor );
+ bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->outro_t );
+ bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->commit_t );
+ }
+ }
+
+ u32 code = bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->sit_t );
+ if( code ){
+ bitpack_qf32( ctx, 8, -k_sit_yaw_limit, k_sit_yaw_limit, &animator->yaw );
+ bitpack_qf32( ctx, 8, -k_sit_pitch_limit, k_sit_pitch_limit,
+ &animator->pitch );
}
}
#endif /* PLAYER_DEVICE_WALK_H */