input update 1
[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 vehc->steer = vg_lerpf( vehc->steer, srinput.joy_steer[0] * 0.4f,
13 k_rb_delta * 8.0f );
14 vehc->drive = srinput.joy_steer[1];
15 }
16
17 VG_STATIC void player__drive_update( player_instance *player )
18 {
19 }
20
21 VG_STATIC void player__drive_post_update( player_instance *player )
22 {
23 struct player_drive *drive = &player->_drive;
24 v3_copy( drive->vehicle->obj.rb.co, player->rb.co );
25 v3_copy( drive->vehicle->obj.rb.v, player->rb.v );
26 v4_copy( drive->vehicle->obj.rb.q, player->rb.q );
27 v3_copy( drive->vehicle->obj.rb.w, player->rb.w );
28 }
29
30 VG_STATIC void player__drive_animate( player_instance *player,
31 player_animation *dest )
32 {
33 struct player_drive *drive = &player->_drive;
34 struct skeleton *sk = &player->playeravatar->sk;
35 skeleton_sample_anim( sk, drive->anim_drive, 0.0f, dest->pose );
36 v3_copy( player->rb.co, dest->root_co );
37 v4_copy( player->rb.q, dest->root_q );
38 }
39
40 VG_STATIC void player__drive_post_animate( player_instance *player )
41 {
42 if( player->camera_mode == k_cam_firstperson )
43 player->cam_velocity_influence = 0.0f;
44 else
45 player->cam_velocity_influence = 1.0f;
46
47 rigidbody *rb = &gzoomer.obj.rb;
48 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
49 pitch = atan2f
50 (
51 -rb->to_world[2][1],
52 sqrtf
53 (
54 rb->to_world[2][0]*rb->to_world[2][0] +
55 rb->to_world[2][2]*rb->to_world[2][2]
56 )
57 );
58
59 player->angles[0] = yaw;
60 player->angles[1] = pitch;
61 }
62
63 VG_STATIC void player__drive_im_gui( player_instance *player )
64 {
65 player__debugtext( 1, "Nothing here" );
66 }
67
68 VG_STATIC void player__drive_bind( player_instance *player )
69 {
70 struct player_drive *drive = &player->_drive;
71 struct player_avatar *av = player->playeravatar;
72 struct skeleton *sk = &av->sk;
73
74 drive->vehicle = &gzoomer;
75 drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
76 }
77
78 VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp )
79 {
80 }
81
82 #endif /* PLAYER_DRIVE_C */