update helpers
[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 static void player__drive_pre_update(void){
8 drivable_vehicle *vehc = player_drive.vehicle;
9
10 v2f steer;
11 joystick_state( k_srjoystick_steer, steer );
12
13 vehc->steer = vg_lerpf( vehc->steer, steer[0] * 0.4f, k_rb_delta * 8.0f );
14 vehc->drive = steer[1];
15 }
16
17 static void player__drive_update(void){}
18
19 static void player__drive_post_update(void){
20 v3_copy( player_drive.vehicle->obj.rb.co,localplayer.rb.co );
21 v3_copy( player_drive.vehicle->obj.rb.v, localplayer.rb.v );
22 v4_copy( player_drive.vehicle->obj.rb.q, localplayer.rb.q );
23 v3_copy( player_drive.vehicle->obj.rb.w, localplayer.rb.w );
24 }
25
26 static void player__drive_animate(void){}
27
28 static void player__drive_pose( void *animator, player_pose *pose ){
29 struct skeleton *sk = &localplayer.skeleton;
30
31 skeleton_sample_anim( sk, player_drive.anim_drive, 0.0f, pose->keyframes );
32 v3_copy( localplayer.rb.co, pose->root_co );
33 v4_copy( localplayer.rb.q, pose->root_q );
34 }
35
36 static void player__drive_post_animate(void){
37 if( localplayer.cam_control.camera_mode == k_cam_firstperson )
38 localplayer.cam_velocity_influence = 0.0f;
39 else
40 localplayer.cam_velocity_influence = 1.0f;
41
42 rigidbody *rb = &gzoomer.obj.rb;
43 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
44 pitch = atan2f
45 (
46 -rb->to_world[2][1],
47 sqrtf
48 (
49 rb->to_world[2][0]*rb->to_world[2][0] +
50 rb->to_world[2][2]*rb->to_world[2][2]
51 )
52 );
53
54 localplayer.angles[0] = yaw;
55 localplayer.angles[1] = pitch;
56 }
57
58 static void player__drive_im_gui(void){
59 player__debugtext( 1, "Nothing here" );
60 }
61
62 static void player__drive_bind(void){
63 struct skeleton *sk = &localplayer.skeleton;
64 player_drive.vehicle = &gzoomer;
65 player_drive.anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
66 }
67
68 static void player__drive_reset( ent_spawn *rp ){
69 }
70
71 #endif /* PLAYER_DRIVE_C */