1 #include "player_drive.h"
4 struct player_drive player_drive
;
5 struct player_subsystem_interface player_subsystem_drive
=
7 .pre_update
= player__drive_pre_update
,
8 .update
= player__drive_update
,
9 .post_update
= player__drive_post_update
,
10 .animate
= player__drive_animate
,
11 .pose
= player__drive_pose
,
12 .post_animate
= player__drive_post_animate
,
13 .im_gui
= player__drive_im_gui
,
14 .bind
= player__drive_bind
,
16 .animator_data
= NULL
,
21 void player__drive_pre_update(void)
23 drivable_vehicle
*vehc
= player_drive
.vehicle
;
26 joystick_state( k_srjoystick_steer
, steer
);
28 vehc
->steer
= vg_lerpf( vehc
->steer
, steer
[0] * 0.4f
,
29 vg
.time_fixed_delta
* 8.0f
);
30 vehc
->drive
= steer
[1];
33 void player__drive_update(void){}
35 void player__drive_post_update(void)
37 v3_copy( player_drive
.vehicle
->rb
.co
,localplayer
.rb
.co
);
38 v3_copy( player_drive
.vehicle
->rb
.v
, localplayer
.rb
.v
);
39 v4_copy( player_drive
.vehicle
->rb
.q
, localplayer
.rb
.q
);
40 v3_copy( player_drive
.vehicle
->rb
.w
, localplayer
.rb
.w
);
43 void player__drive_animate(void){}
45 void player__drive_pose( void *animator
, player_pose
*pose
)
47 struct skeleton
*sk
= &localplayer
.skeleton
;
49 skeleton_sample_anim( sk
, player_drive
.anim_drive
, 0.0f
, pose
->keyframes
);
50 v3_copy( localplayer
.rb
.co
, pose
->root_co
);
51 v4_copy( localplayer
.rb
.q
, pose
->root_q
);
54 void player__drive_post_animate(void)
56 if( localplayer
.cam_control
.camera_mode
== k_cam_firstperson
)
57 localplayer
.cam_velocity_influence
= 0.0f
;
59 localplayer
.cam_velocity_influence
= 1.0f
;
61 rigidbody
*rb
= &gzoomer
.rb
;
62 float yaw
= atan2f( -rb
->to_world
[2][0], rb
->to_world
[2][2] ),
68 rb
->to_world
[2][0]*rb
->to_world
[2][0] +
69 rb
->to_world
[2][2]*rb
->to_world
[2][2]
73 localplayer
.angles
[0] = yaw
;
74 localplayer
.angles
[1] = pitch
;
77 void player__drive_im_gui(void)
79 player__debugtext( 1, "Nothing here" );
82 void player__drive_bind(void)
84 struct skeleton
*sk
= &localplayer
.skeleton
;
85 player_drive
.vehicle
= &gzoomer
;
86 player_drive
.anim_drive
= skeleton_get_anim( sk
, "idle_cycle+y" );