X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=skaterift.c;h=1db6db52ab3e8c4d939f4ea91d1a9cee95dd3557;hb=72c40f1bc7a732f6a628dbf8a4135ac0bf3efa4e;hp=ad01803a6d02ca2d76f2990b1ea5a064aff3b1fa;hpb=a9e3181f697ab37fc74f072cfcfdf44e2d659468;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/skaterift.c b/skaterift.c index ad01803..1db6db5 100644 --- a/skaterift.c +++ b/skaterift.c @@ -22,21 +22,18 @@ #include "player.h" -VG_STATIC player_instance localplayer; +static player_instance localplayer; VG_STATIC struct player_avatar localplayer_avatar; VG_STATIC glmesh localplayer_meshes[3]; vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" }; - - - - +player_instance *tmp_localplayer(void) +{ + return &localplayer; +} #include "network.h" - -#if 0 #include "menu.h" -#endif #include "vehicle.h" static int cl_ui = 1, @@ -72,17 +69,13 @@ VG_STATIC int __kill( int argc, const char *argv[] ) VG_STATIC int __respawn( int argc, const char *argv[] ) { - struct respawn_point *rp = NULL, *r; - + ent_spawn *rp = NULL, *r; world_instance *world = get_active_world(); - if( argc == 1 ) - { - for( int i=0; ispawn_count; i++ ) - { - r = &world->spawns[i]; - if( !strcmp( r->name, argv[0] ) ) - { + if( argc == 1 ){ + for( u32 i=0; ient_spawn); i++ ){ + r = mdl_arritm( &world->ent_spawn, i ); + if( !strcmp( mdl_pstr(&world->meta, r->pstr_name),argv[0] ) ){ rp = r; break; } @@ -92,32 +85,27 @@ VG_STATIC int __respawn( int argc, const char *argv[] ) vg_warn( "No spawn named '%s'\n", argv[0] ); } - if( !rp ) - { + if( !rp ){ float min_dist = INFINITY; - for( int i=0; ispawn_count; i++ ) - { - r = &world->spawns[i]; - float d = v3_dist2( r->co, localplayer.rb.co ); + for( u32 i=0; ient_spawn); i++ ){ + r = mdl_arritm( &world->ent_spawn, i ); + float d = v3_dist2( r->transform.co, localplayer.rb.co ); - vg_info( "Dist %s : %f\n", r->name, d ); - if( d < min_dist ) - { + if( d < min_dist ){ min_dist = d; rp = r; } } } - if( !rp ) - { + if( !rp ){ vg_error( "No spawn found\n" ); - if( !world->spawn_count ) + if( !mdl_arrcount(&world->ent_spawn) ) return 0; - rp = &world->spawns[0]; + rp = mdl_arritm( &world->ent_spawn, 0 ); } player__spawn( &localplayer, rp ); @@ -197,19 +185,19 @@ VG_STATIC void load_playermodels(void) ctx_outlaw, ctx_jordan; - mdl_open( &ctx_default, "models/ch_new.mdl" ); - mdl_load_metadata( &ctx_default, vg_mem.scratch ); - mdl_load_mesh_data( &ctx_default, vg_mem.scratch ); + mdl_open( &ctx_default, "models/ch_new.mdl", vg_mem.scratch ); + mdl_load_metadata_block( &ctx_default, vg_mem.scratch ); + mdl_load_mesh_block( &ctx_default, vg_mem.scratch ); mdl_close( &ctx_default ); - mdl_open( &ctx_outlaw, "models/ch_outlaw.mdl" ); - mdl_load_metadata( &ctx_outlaw, vg_mem.scratch ); - mdl_load_mesh_data( &ctx_outlaw, vg_mem.scratch ); + mdl_open( &ctx_outlaw, "models/ch_outlaw.mdl", vg_mem.scratch ); + mdl_load_metadata_block( &ctx_outlaw, vg_mem.scratch ); + mdl_load_mesh_block( &ctx_outlaw, vg_mem.scratch ); mdl_close( &ctx_outlaw ); - mdl_open( &ctx_jordan, "models/ch_jordan.mdl" ); - mdl_load_metadata( &ctx_jordan, vg_mem.scratch ); - mdl_load_mesh_data( &ctx_jordan, vg_mem.scratch ); + mdl_open( &ctx_jordan, "models/ch_jordan.mdl", vg_mem.scratch ); + mdl_load_metadata_block( &ctx_jordan, vg_mem.scratch ); + mdl_load_mesh_block( &ctx_jordan, vg_mem.scratch ); mdl_close( &ctx_jordan ); vg_acquire_thread_sync(); @@ -229,10 +217,14 @@ VG_STATIC void load_playermodels(void) vg_release_thread_sync(); } +void temp_update_playermodel(void){ + player__use_mesh( &localplayer, &localplayer_meshes[cl_playermdl_id] ); +} + VG_STATIC void vg_load(void) { vg_loader_step( render_init, NULL ); - //vg_loader_step( menu_init, NULL ); + vg_loader_step( menu_init, NULL ); vg_loader_step( world_init, NULL ); //vg_loader_step( player_init, NULL ); //vg_loader_step( vehicle_init, NULL ); @@ -246,7 +238,7 @@ VG_STATIC void vg_load(void) player__create( &localplayer ); player_avatar_load( &localplayer_avatar, "models/ch_new.mdl" ); player__use_avatar( &localplayer, &localplayer_avatar ); - player__use_mesh( &localplayer, &localplayer_meshes[0] ); + player__use_mesh( &localplayer, &localplayer_meshes[cl_playermdl_id] ); player__use_texture( &localplayer, &localplayer_texture ); player__bind( &localplayer ); @@ -254,17 +246,16 @@ VG_STATIC void vg_load(void) vg_bake_shaders(); vg_loader_step( audio_init, audio_free ); - world_audio_init(); /* 'systems' are completely loaded now */ /* load home world */ - world_load( &world_global.worlds[0], "maps/mp_home.mdl" ); + world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); #if 0 world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" ); - world_load( &world_global.worlds[2], "maps/mp_mtzero.mdl" ); world_link_nonlocal_gates( 0, 1 ); + world_load( &world_global.worlds[2], "maps/mp_mtzero.mdl" ); world_link_nonlocal_gates( 0, 2 ); #endif @@ -370,15 +361,12 @@ VG_STATIC void vg_update_post(void) float dist = 200.0f; - for( int i=0; i<10; i++ ) - { - if( ray_world( get_active_world(), rc, rd, &ray ) ) - { + for( int i=0; i<10; i++ ){ + if( ray_world( get_active_world(), rc, rd, &ray ) ){ dist = (float)i*5.0f + ray.dist; break; } - else - { + else{ v3_muladds( rc, rd, ray.dist, rc ); } } @@ -386,10 +374,8 @@ VG_STATIC void vg_update_post(void) distances[si] = dist; - for( int i=0; i<14; i++ ) - { - if( distances[i] != 200.0f ) - { + for( int i=0; i<14; i++ ){ + if( distances[i] != 200.0f ){ u32 colours[] = { VG__RED, VG__BLUE, VG__GREEN, VG__CYAN, VG__YELOW, VG__PINK, VG__WHITE }; @@ -414,12 +400,21 @@ VG_STATIC void vg_update_post(void) v3f ears = { 1.0f,0.0f,0.0f }; m3x3_mulv( main_camera.transform, ears, ears ); - v3_copy( ears, vg_audio.listener_ears ); - v3_copy( main_camera.transform[3], vg_audio.listener_pos ); + v3_copy( ears, vg_audio.external_listener_ears ); + v3_copy( main_camera.transform[3], vg_audio.external_listener_pos ); + + /* TODO: this is transformed back and fourth twice. */ + if( localplayer.gate_waiting ){ + m4x3_mulv( localplayer.gate_waiting->transport, + vg_audio.external_listener_pos, + vg_audio.external_listener_pos ); + } + + v3_copy( localplayer.rb.v, vg_audio.external_lister_velocity ); audio_unlock(); -#if 0 menu_update(); +#if 0 vehicle_update_post(); #endif } @@ -439,16 +434,14 @@ VG_STATIC void present_view_with_post_processing(void) glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); glBlendEquation(GL_FUNC_ADD); - if( cl_blur ) - { + if( cl_blur ){ shader_blitblur_use(); shader_blitblur_uTexMain( 0 ); shader_blitblur_uTexMotion( 1 ); shader_blitblur_uBlurStrength(cl_blur_strength / (vg.frame_delta*60.0f)); v2f menu_blurring; - //v2_muls( (v2f){ 0.04f, 0.001f }, menu_opacity, menu_blurring ); - v2_muls( (v2f){ 0.04f, 0.001f }, 0.0f, menu_blurring ); + v2_muls( (v2f){ 0.04f, 0.001f }, menu_opacity, menu_blurring ); shader_blitblur_uOverrideDir( menu_blurring ); if( cl_view_id == 0 ) @@ -460,8 +453,7 @@ VG_STATIC void present_view_with_post_processing(void) render_fb_bind_texture( gpipeline.fb_main, 1, 1 ); } - else - { + else{ shader_blit_use(); shader_blit_uTexMain( 0 ); render_fb_bind_texture( gpipeline.fb_main, 0, 0 ); @@ -500,36 +492,26 @@ VG_STATIC void render_scene(void) glEnable( GL_DEPTH_TEST ); world_instance *view_world = localplayer.viewable_world; - render_world( view_world, &main_camera ); - int player_transparent = 1, - player_draw = 1; + if( view_world == NULL ){ + glClearColor( 0.25f, 0.25f, 0.0f, 1.0f ); + glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); + return; + } -#if 0 - if( (localplayer.subsystem == k_player_subsystem_dead) || - (localplayer.camera_mode == k_cam_thirdperson) ) - player_transparent = 0; -#endif - - if( !player_transparent && player_draw ) - player__render( &main_camera, &localplayer ); + render_world( view_world, &main_camera, 0 ); - render_water_texture( view_world, &main_camera ); + render_water_texture( view_world, &main_camera, 0 ); render_fb_bind( gpipeline.fb_main ); render_water_surface( view_world, &main_camera ); - render_world_gates( view_world, &main_camera ); - if( player_transparent && player_draw ) - render_player_transparent(); -} + int depth = 1; + if( localplayer.gate_waiting ) depth = 0; + render_world_gates( view_world, &main_camera, depth ); -VG_STATIC void render_menu(void) -{ - glClear( GL_DEPTH_BUFFER_BIT ); -#if 0 - menu_render( &main_camera ); -#endif + if( !cl_menu ) + render_player_transparent(); } VG_STATIC void render_main_game(void) @@ -549,31 +531,33 @@ VG_STATIC void render_main_game(void) main_camera.fov = fov; #endif - /* copy camera from player. - * TODO: blend with camera from menu */ - - /* FIXME: TEMP!! */ player__pre_render( &localplayer ); - v3_copy( localplayer.cam.pos, main_camera.pos ); - v3_copy( localplayer.cam.angles, main_camera.angles ); - main_camera.fov = localplayer.cam.fov; + v3_lerp( localplayer.cam.pos, menu_camera_pos, menu_opacity, + main_camera.pos ); + main_camera.angles[0] = + vg_alerpf( localplayer.cam.angles[0], menu_camera_angles[0], + menu_opacity ); + main_camera.angles[1] = + vg_lerpf ( localplayer.cam.angles[1], menu_camera_angles[1], + menu_opacity ); + + main_camera.fov = vg_lerpf( localplayer.cam.fov, menu_smooth_fov, + menu_opacity ); main_camera.nearz = 0.1f; main_camera.farz = 2100.0f; camera_update_transform( &main_camera ); - if( localplayer.gate_waiting ) - { + if( localplayer.gate_waiting ){ m3x3_mul( localplayer.basis_gate, main_camera.transform, main_camera.transform ); } - else - { + else{ m3x3_mul( localplayer.basis, main_camera.transform, main_camera.transform ); } - + camera_update_view( &main_camera ); camera_update_projection( &main_camera ); camera_finalize( &main_camera ); @@ -581,15 +565,18 @@ VG_STATIC void render_main_game(void) /* ========== Begin Frame ========== */ render_scene(); - present_view_with_post_processing(); -#if 0 - if( cl_menu ) - { - render_menu(); + if( cl_menu ) { + glClear( GL_DEPTH_BUFFER_BIT ); + menu_render_bg(); + glEnable( GL_DEPTH_TEST ); render_player_transparent(); } -#endif + + present_view_with_post_processing(); + + if( cl_menu ) + menu_render_fg( &main_camera ); /* =========== End Frame =========== */ } @@ -610,7 +597,7 @@ VG_STATIC void vg_render(void) /* Other shite */ glDisable(GL_BLEND); - glDisable( GL_DEPTH_TEST ); + glDisable(GL_DEPTH_TEST); vg_lines_drawall(); glViewport( 0,0, vg.window_x, vg.window_y ); } @@ -618,12 +605,11 @@ VG_STATIC void vg_render(void) VG_STATIC void run_light_widget( struct light_widget *lw ); VG_STATIC void vg_ui(void) { +#if 0 player__im_gui( &localplayer ); +#endif world_instance *world = get_active_world(); - -#if 0 menu_crap_ui(); -#endif #if 0 if( cl_light_edit ) @@ -662,13 +648,6 @@ VG_STATIC void vg_ui(void) } #endif - //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - if( cl_ui ) - { - render_world_routes_ui( world ); - } - //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - audio_debug_soundscapes(); render_view_framebuffer_ui();