2 * Copyright 2021-2022 (C) Mount0 Software, Harry Godden - All Rights Reserved
3 * -----------------------------------------------------------------------------
7 * -----------------------------------------------------------------------------
20 k_walkspeed
= 7.0f
, /* no longer used */
22 k_board_radius
= 0.3f
,
23 k_board_length
= 0.45f
,
24 k_board_allowance
= 0.04f
,
25 k_friction_lat
= 8.8f
,
26 k_friction_resistance
= 0.01f
,
27 k_max_push_speed
= 16.0f
,
29 k_push_cycle_rate
= 8.0f
,
30 k_steer_ground
= 2.5f
,
32 k_steer_air_lerp
= 0.3f
,
35 k_jump_charge_speed
= (1.0f
/1.0f
),
40 k_walk_friction
= 8.0f
;
42 static int freecam
= 0;
43 static int walk_grid_iterations
= 1;
44 static float fc_speed
= 10.0f
;
47 * -----------------------------------------------------------------------------
49 * -----------------------------------------------------------------------------
55 rigidbody collide_front
, collide_back
;
59 rigidbody rb
, rb_gate_frame
;
60 float iY
, siY
; /* Yaw inertia */
62 v3f a
, v_last
, m
, bob
, vl
;
65 float vswitch
, slip
, slip_last
,
69 int in_air
, on_board
, jump_charge
, jump_dir
;
76 float pushing
, push_time
;
80 v3f land_target_log
[22];
81 u32 land_target_colours
[22];
84 v3f handl_target
, handr_target
,
90 v3f camera_pos
, smooth_localcam
;
92 m4x3f camera
, camera_inverse
;
114 struct skeleton_anim
*anim_stand
,
118 *anim_push
, *anim_push_reverse
,
119 *anim_ollie
, *anim_ollie_reverse
,
120 *anim_grabs
, *anim_stop
,
121 *anim_walk
, *anim_run
, *anim_idle
;
152 .collide_front
= { .type
= k_rb_shape_sphere
, .inf
.sphere
.radius
= 0.3f
},
153 .collide_back
= { .type
= k_rb_shape_sphere
, .inf
.sphere
.radius
= 0.3f
}
159 static float *player_get_pos(void);
160 static void player_kill(void);
161 static float *player_cam_pos(void);
162 static void player_save_frame(void);
163 static void player_restore_frame(void);
168 #include "player_physics.h"
169 #include "player_ragdoll.h"
170 #include "player_model.h"
171 #include "player_animation.h"
172 #include "player_audio.h"
175 * -----------------------------------------------------------------------------
177 * -----------------------------------------------------------------------------
180 static void player_register(void) /* 0 */
182 player_model_register();
185 static void player_init(void) /* 1 */
189 rb_init( &player
.collide_front
);
190 rb_init( &player
.collide_back
);
193 static void player_update(void) /* 2 */
195 struct player_phys
*phys
= &player
.phys
;
197 for( int i
=0; i
<player
.land_log_count
; i
++ )
198 vg_line_cross( player
.land_target_log
[i
],
199 player
.land_target_colours
[i
], 0.25f
);
201 if( vg_get_axis("grabl")>0.0f
)
204 player_restore_frame();
206 if( !phys
->on_board
)
208 player
.angles
[0] = atan2f( -phys
->rb
.forward
[2],
209 -phys
->rb
.forward
[0] );
212 player
.mdl
.shoes
[0] = 1;
213 player
.mdl
.shoes
[1] = 1;
215 world_routes_notify_reset();
218 if( vg_get_button_down( "switchmode" ) )
220 phys
->on_board
^= 0x1;
224 if( (glfwGetKey( vg_window
, GLFW_KEY_O
) ))
226 player_ragdoll_copy_model( phys
->rb
.v
);
233 player_ragdoll_iter();
234 player_debug_ragdoll();
237 player_animate_death_cam();
245 player_animate_camera();
251 player_camera_update();
255 static void draw_player(void) /* 3 */
258 player_model_copy_ragdoll();
260 shader_viewchar_use();
261 vg_tex2d_bind( &tex_characters
, 0 );
262 shader_viewchar_uTexMain( 0 );
263 shader_viewchar_uCamera( player
.camera
[3] );
264 shader_viewchar_uPv( vg_pv
);
265 shader_link_standard_ub( _shader_viewchar
.id
, 2 );
266 glUniformMatrix4x3fv( _uniform_viewchar_uTransforms
,
267 player
.mdl
.sk
.bone_count
,
269 (float *)player
.mdl
.sk
.final_mtx
);
271 mesh_bind( &player
.mdl
.mesh
);
272 mesh_draw( &player
.mdl
.mesh
);
276 * -----------------------------------------------------------------------------
278 * -----------------------------------------------------------------------------
281 static float *player_get_pos(void)
283 return player
.phys
.rb
.co
;
286 static void player_kill(void)
289 player_ragdoll_copy_model( player
.phys
.rb
.v
);
292 static float *player_cam_pos(void)
294 return player
.camera_pos
;
298 #endif /* PLAYER_H */