/* counter-rotation */
if( v3_length2( s->state.up_dir ) > 0.001f ){
- if( v4_length(s->state.smoothed_rotation) <= 0.1f ||
- v4_length(s->state.smoothed_rotation) >= 1.1f ){
- vg_warn( "FIX THIS! CARROT\n" ); /* this never happens anymore? */
- v4_copy( player->rb.q, s->state.smoothed_rotation );
- }
v4_lerp( s->state.smoothed_rotation, player->rb.q,
2.0f*vg.time_frame_delta,
s->state.smoothed_rotation );
q_normalize( s->state.smoothed_rotation );
- v3f yaw_ref = {1.0f,0.0f,0.0f},
- yaw_smooth = {1.0f,0.0f,0.0f};
- q_mulv( player->rb.q, yaw_ref, yaw_ref );
+ v3f yaw_smooth = {1.0f,0.0f,0.0f};
q_mulv( s->state.smoothed_rotation, yaw_smooth, yaw_smooth );
m3x3_mulv( player->rb.to_local, yaw_smooth, yaw_smooth );
- m3x3_mulv( player->rb.to_local, yaw_ref, yaw_ref );
+ yaw_smooth[1] = 0.0f;
+ v3_normalize( yaw_smooth );
- f32 yaw_counter_rotate = v3_dot(yaw_ref,yaw_smooth);
- yaw_counter_rotate = vg_clampf(yaw_counter_rotate,-0.7f,0.7f);
+ f32 yaw_counter_rotate = yaw_smooth[0];
+ yaw_counter_rotate = vg_maxf( 0.7f, yaw_counter_rotate );
yaw_counter_rotate = acosf( yaw_counter_rotate );
yaw_counter_rotate *= 1.0f-animator->fly;
v3_normalize( ndir );
v3f up = { 0.0f, 1.0f, 0.0f };
-
float a = v3_dot( ndir, up );
a = acosf( vg_clampf( a, -1.0f, 1.0f ) );
v4f qcounteryaw, qfixup;
v3_cross( up, ndir, axis );
- q_axis_angle( qfixup, axis, a );
+ q_axis_angle( qfixup, axis, a*2.0f );
+
+ v3_cross( (v3f){1.0f,0.0f,0.0f}, yaw_smooth, axis );
+ q_axis_angle( qcounteryaw, axis, yaw_counter_rotate );
- q_axis_angle( qcounteryaw, (v3f){0.0f,1.0f,0.0f}, yaw_counter_rotate );
q_mul( qcounteryaw, qfixup, animator->qfixuptotal );
q_normalize( animator->qfixuptotal );
m3x3_mulv( player->rb.to_world, up, p1 );
m3x3_mulv( player->rb.to_world, ndir, p2 );
- vg_line_arrow( player->rb.co, p1, 0.25f, VG__PINK );
- vg_line_arrow( player->rb.co, p2, 0.25f, VG__PINK );
+ vg_line_arrow( player->rb.co, p1, 0.5f, VG__PINK );
+ vg_line_arrow( player->rb.co, p2, 0.5f, VG__PINK );
}
else q_identity( animator->qfixuptotal );
- q_identity( animator->qfixuptotal );
rb_extrapolate( &player->rb, animator->root_co, animator->root_q );
}
if( animator->trick_type == k_trick_type_kickflip ){
kf_foot_l->co[0] += animator->trick_foot * 0.2f;
+ kf_foot_l->co[1] -= animator->trick_foot * 0.18f;
}
else if( animator->trick_type == k_trick_type_shuvit ){
kf_foot_l->co[0] += animator->trick_foot * 0.1f;
kf_foot_r->co[0] -= animator->trick_foot * 0.15f;
+ kf_foot_l->co[1] -= animator->trick_foot * 0.18f;
+ kf_foot_r->co[1] -= animator->trick_foot * 0.18f;
}
else if( animator->trick_type == k_trick_type_treflip ){
kf_foot_l->co[0] += animator->trick_foot * 0.2f;
kf_foot_r->co[0] -= animator->trick_foot * 0.15f;
+ kf_foot_l->co[1] -= animator->trick_foot * 0.18f;
+ kf_foot_r->co[1] -= animator->trick_foot * 0.18f;
}
/*
q_normalize( kf_wheels[i]->q );
}
+#if 0
{
mdl_keyframe
*kf_head = &pose->keyframes[av->id_head-1],
q_mul( qrot, kf_head->q, kf_head->q );
q_normalize( kf_head->q );
}
+#endif
}
VG_STATIC void player__skate_post_animate( player_instance *player )