X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=inline;f=player_drive.c;fp=player_drive.c;h=1c082121026d50934fc01958a9739e35588c99cf;hb=01e2535f8daaab0e3d46dcc61a08a9268babd47c;hp=0000000000000000000000000000000000000000;hpb=cca3ca3a92572c77f34a99ffa2f3d9a69d029000;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_drive.c b/player_drive.c new file mode 100644 index 0000000..1c08212 --- /dev/null +++ b/player_drive.c @@ -0,0 +1,82 @@ +#ifndef PLAYER_DRIVE_C +#define PLAYER_DRIVE_C + +#include "player.h" + +VG_STATIC void player__drive_pre_update( player_instance *player ) +{ + struct player_drive *drive = &player->_drive; + drivable_vehicle *vehc = drive->vehicle; + + vehc->steer = vg_lerpf( vehc->steer, + player->input_walkh->axis.value * 0.4f, + k_rb_delta * 8.0f ); + vehc->drive = player->input_walkv->axis.value; +} + +VG_STATIC void player__drive_update( player_instance *player ) +{ +} + +VG_STATIC void player__drive_post_update( player_instance *player ) +{ + struct player_drive *drive = &player->_drive; + v3_copy( drive->vehicle->obj.rb.co, player->rb.co ); + v3_copy( drive->vehicle->obj.rb.v, player->rb.v ); + v4_copy( drive->vehicle->obj.rb.q, player->rb.q ); + v3_copy( drive->vehicle->obj.rb.w, player->rb.w ); +} + +VG_STATIC void player__drive_animate( player_instance *player, + player_animation *dest ) +{ + struct player_drive *drive = &player->_drive; + struct skeleton *sk = &player->playeravatar->sk; + skeleton_sample_anim( sk, drive->anim_drive, 0.0f, dest->pose ); + v3_copy( player->rb.co, dest->root_co ); + v4_copy( player->rb.q, dest->root_q ); +} + +VG_STATIC void player__drive_post_animate( player_instance *player ) +{ + if( player->camera_mode == k_cam_firstperson ) + player->cam_velocity_influence = 0.0f; + else + player->cam_velocity_influence = 1.0f; + + rigidbody *rb = &gzoomer.obj.rb; + float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ), + pitch = atan2f + ( + -rb->to_world[2][1], + sqrtf + ( + rb->to_world[2][0]*rb->to_world[2][0] + + rb->to_world[2][2]*rb->to_world[2][2] + ) + ); + + player->angles[0] = yaw; + player->angles[1] = pitch; +} + +VG_STATIC void player__drive_im_gui( player_instance *player ) +{ + player__debugtext( 1, "Nothing here" ); +} + +VG_STATIC void player__drive_bind( player_instance *player ) +{ + struct player_drive *drive = &player->_drive; + struct player_avatar *av = player->playeravatar; + struct skeleton *sk = &av->sk; + + drive->vehicle = &gzoomer; + drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" ); +} + +VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp ) +{ +} + +#endif /* PLAYER_DRIVE_C */