basic replayable replays
[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 player_animation *dest )
34 {
35 struct player_drive *drive = &player->_drive;
36 struct skeleton *sk = &player->playeravatar->sk;
37 skeleton_sample_anim( sk, drive->anim_drive, 0.0f, dest->pose );
38 v3_copy( player->rb.co, dest->root_co );
39 v4_copy( player->rb.q, dest->root_q );
40 }
41
42 VG_STATIC void player__drive_post_animate( player_instance *player )
43 {
44 if( player->cam_control.camera_mode == k_cam_firstperson )
45 player->cam_velocity_influence = 0.0f;
46 else
47 player->cam_velocity_influence = 1.0f;
48
49 rigidbody *rb = &gzoomer.obj.rb;
50 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
51 pitch = atan2f
52 (
53 -rb->to_world[2][1],
54 sqrtf
55 (
56 rb->to_world[2][0]*rb->to_world[2][0] +
57 rb->to_world[2][2]*rb->to_world[2][2]
58 )
59 );
60
61 player->angles[0] = yaw;
62 player->angles[1] = pitch;
63 }
64
65 VG_STATIC void player__drive_im_gui( player_instance *player )
66 {
67 player__debugtext( 1, "Nothing here" );
68 }
69
70 VG_STATIC void player__drive_bind( player_instance *player )
71 {
72 struct player_drive *drive = &player->_drive;
73 struct player_avatar *av = player->playeravatar;
74 struct skeleton *sk = &av->sk;
75
76 drive->vehicle = &gzoomer;
77 drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
78 }
79
80 VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp )
81 {
82 }
83
84 #endif /* PLAYER_DRIVE_C */