From 2482eb7cc2281faf3513581ef7b9135feab51174 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 27 Dec 2024 15:27:44 +0000 Subject: [PATCH] it works, fuck you --- src/metascene.c | 60 +++++++++++++++++++++++++++++++++++------- src/metascene.h | 3 +++ src/skaterift.c | 33 +++++++---------------- src/skaterift_script.c | 4 ++- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/metascene.c b/src/metascene.c index 674337b..fed57f0 100644 --- a/src/metascene.c +++ b/src/metascene.c @@ -44,6 +44,28 @@ struct cs_instance *_cutscene_get_first_model_instance( const char *mdl_name ) return NULL; } +void _cutscene_play(void) +{ + _cutscene.state = k_cutscene_state_playing; +} + +void _cutscene_unload(void) +{ + vg_info( "Unloading cutscene\n" ); + + for( u32 i=0; i<_cutscene.unique_refs; i ++ ) + mdl_sync_std_unload( &_cutscene.refs[i].mdl ); + + vg_allocator_free( _cutscene.arena ); + _cutscene.arena = NULL; + _cutscene.active_camera = NULL; + _cutscene.strip = 0; + _cutscene.time = 0.0f; + _cutscene.active_samplers = 0; + _cutscene.state = k_cutscene_state_none; + _cutscene.player_binding = NULL; +} + /* * Find associated entity data. We should also probably do this on the world * thingy @@ -298,7 +320,7 @@ static int cmd_cutscene_play( int argc, const char *argv[] ) * Currently draws everything as skinned meshes. */ void cutscene_render_instance( struct cs_instance *ins, - world_instance *world, vg_camera *cam ) + world_instance *world, vg_camera *cam ) { struct model_ref *ref = &_cutscene.refs[ ins->ref_id ]; mdl_context *mdl = &ref->mdl; @@ -311,7 +333,7 @@ void cutscene_render_instance( struct cs_instance *ins, WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_character_view ); - glActiveTexture( GL_TEXTURE0 ); + glActiveTexture( GL_TEXTURE0 ); shader_model_character_view_uTexMain( 0 ); u32 armature_id = 0x00; @@ -331,16 +353,16 @@ void cutscene_render_instance( struct cs_instance *ins, m4x3f *skinning_data = ins->skinning_data + skele->skinning_offset; glUniformMatrix4x3fv( _uniform_model_character_view_uTransforms, - skele->sk.bone_count, - 0, - (const GLfloat *)skinning_data ); + skele->sk.bone_count, + 0, + (const GLfloat *)skinning_data ); } for( u32 j=0; jsubmesh_count; j ++ ) { mdl_submesh *sm = &mdl->submeshes[ mesh->submesh_start+j ]; VG_ASSERT( sm->material_id ); - + if( sm->material_id != material_id ) { mdl_material *m = &mdl->materials[ sm->material_id-1 ]; @@ -369,7 +391,7 @@ struct cs_link_info }; static bool link_internal_datapath( struct cs_asoc *asoc, const char *datapath, - struct cs_link_info *out_link ) + struct cs_link_info *out_link ) { VG_ASSERT( asoc->entity_type == k_ent_camera ); @@ -425,7 +447,7 @@ void cutscene_update( f32 delta ) for( u32 i=0; i<_cutscene.active_samplers; i ++ ) { struct cs_sampler *si = &_cutscene.samplers[i]; - + if( frame > (si->strip->offset + si->strip->length) ) { move = 1; @@ -437,7 +459,7 @@ void cutscene_update( f32 delta ) struct cs_sampler *sj = &_cutscene.samplers[j]; *sj = *si; } - + j ++; } } @@ -642,6 +664,12 @@ void cutscene_update( f32 delta ) ent_camera *cam = af_arritm( &_cutscene.meta.cameras, i ); vg_line_cross( cam->co, VG__RED, 0.2f ); } + + if( (_cutscene.strip == af_arrcount(&_cutscene.meta.strips)) && + (_cutscene.active_samplers == 0 ) ) + { + _cutscene.state = k_cutscene_state_done; + } } void cutscene_render( world_instance *world, vg_camera *cam ) @@ -662,6 +690,20 @@ void cutscene_render( world_instance *world, vg_camera *cam ) static void cb_cutscene_view( ui_context *ctx, ui_rect rect, struct vg_magi_panel *magi ) { + if( _cutscene.state == k_cutscene_state_none ) + { + ui_text( ctx, rect, "No cutscene loaded.", 1, + k_ui_align_middle_center, 0 ); + return; + } + + if( _cutscene.state == k_cutscene_state_loading ) + { + ui_text( ctx, rect, "Cutscene loading..", 1, + k_ui_align_middle_center, 0 ); + return; + } + ms_strip *usage[8]; for( u32 i=0; i= k_cutscene_state_ready) && _cutscene.player_binding ) + { + struct cs_instance *inst = _cutscene.player_binding; + struct skeleton *sk = &localplayer.skeleton; + for( u32 i=0; ibone_count; i ++ ) + { + m4x3_copy( inst->skinning_data[i], localplayer.final_mtx[i] ); + } + } + else if( skaterift.activity == k_skaterift_replay ) { player__animate_from_replay( &player_replay.local ); } @@ -519,8 +528,6 @@ static void render_main_game(void) localplayer.deferred_frame_record = 0; } - //temp_not_done_1(); - animate_remote_players(); player__pre_render(); @@ -695,23 +702,3 @@ void vg_gui( ui_context *ctx ) #include "control_overlay.c" #include "ent_camera.c" #include "skaterift_script.c" - -#if 0 -static void temp_not_done_1(void) -{ - if( _cutscene.ready ) - { - struct cs_instance *inst = _cutscene_get_first_model_instance( - "playermodels/skaterift_john/ch_john" ); - - if( inst ) - { - struct skeleton *sk = &localplayer.skeleton; - for( u32 i=0; ibone_count; i ++ ) - { - m4x3_copy( inst->skinning_data[i], localplayer.final_mtx[i] ); - } - } - } -} -#endif diff --git a/src/skaterift_script.c b/src/skaterift_script.c index 95fd7db..c0914e4 100644 --- a/src/skaterift_script.c +++ b/src/skaterift_script.c @@ -57,6 +57,8 @@ static bool _skaterift_script_test( enum escript_event ev ) { state = k_escript_state_playing; vg_info( "test:state = playing\n" ); + _cutscene.player_binding = override_inst; + _cutscene_play(); } else { @@ -72,7 +74,7 @@ static bool _skaterift_script_test( enum escript_event ev ) { state = k_escript_state_end; vg_info( "test:state = end\n" ); - // TODO: Unload cutscene? + _cutscene_unload(); return 1; } } -- 2.25.1