move everything to animator based
[carveJwlIkooP6JGAAIwe30JlM.git] / player_drive.c
1 #ifndef PLAYER_DRIVE_C
2 #define PLAYER_DRIVE_C
3
4 #include "player.h"
5 #include "input.h"
6
7 VG_STATIC void player__drive_pre_update( player_instance *player )
8 {
9 struct player_drive *drive = &player->_drive;
10 drivable_vehicle *vehc = drive->vehicle;
11
12 v2f steer;
13 joystick_state( k_srjoystick_steer, steer );
14
15 vehc->steer = vg_lerpf( vehc->steer, steer[0] * 0.4f, k_rb_delta * 8.0f );
16 vehc->drive = steer[1];
17 }
18
19 VG_STATIC void player__drive_update( player_instance *player )
20 {
21 }
22
23 VG_STATIC void player__drive_post_update( player_instance *player )
24 {
25 struct player_drive *drive = &player->_drive;
26 v3_copy( drive->vehicle->obj.rb.co, player->rb.co );
27 v3_copy( drive->vehicle->obj.rb.v, player->rb.v );
28 v4_copy( drive->vehicle->obj.rb.q, player->rb.q );
29 v3_copy( drive->vehicle->obj.rb.w, player->rb.w );
30 }
31
32 VG_STATIC void player__drive_animate( player_instance *player ){}
33
34 VG_STATIC void player__drive_pose( player_instance *player, player_pose *pose ){
35 struct player_drive *drive = &player->_drive;
36 struct skeleton *sk = &player->playeravatar->sk;
37
38 skeleton_sample_anim( sk, drive->anim_drive, 0.0f, pose->keyframes );
39 v3_copy( player->rb.co, pose->root_co );
40 v4_copy( player->rb.q, pose->root_q );
41 }
42
43 VG_STATIC void player__drive_post_animate( player_instance *player )
44 {
45 if( player->cam_control.camera_mode == k_cam_firstperson )
46 player->cam_velocity_influence = 0.0f;
47 else
48 player->cam_velocity_influence = 1.0f;
49
50 rigidbody *rb = &gzoomer.obj.rb;
51 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
52 pitch = atan2f
53 (
54 -rb->to_world[2][1],
55 sqrtf
56 (
57 rb->to_world[2][0]*rb->to_world[2][0] +
58 rb->to_world[2][2]*rb->to_world[2][2]
59 )
60 );
61
62 player->angles[0] = yaw;
63 player->angles[1] = pitch;
64 }
65
66 VG_STATIC void player__drive_im_gui( player_instance *player )
67 {
68 player__debugtext( 1, "Nothing here" );
69 }
70
71 VG_STATIC void player__drive_bind( player_instance *player )
72 {
73 struct player_drive *drive = &player->_drive;
74 struct player_avatar *av = player->playeravatar;
75 struct skeleton *sk = &av->sk;
76
77 drive->vehicle = &gzoomer;
78 drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
79 }
80
81 VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp )
82 {
83 }
84
85 #endif /* PLAYER_DRIVE_C */