From: hgn Date: Sun, 23 Mar 2025 02:24:25 +0000 (+0000) Subject: spinning, templates and uhhhh fixse X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=8758cb28edf2ae3f99174508b407aa1d88a0498e;p=carveJwlIkooP6JGAAIwe30JlM.git spinning, templates and uhhhh fixse --- diff --git a/content_skaterift/boards/welsh/board.mdl b/content_skaterift/boards/welsh/board.mdl new file mode 100644 index 0000000..8fd5ae9 Binary files /dev/null and b/content_skaterift/boards/welsh/board.mdl differ diff --git a/content_skaterift/maps/dev_flatworld/main.mdl b/content_skaterift/maps/dev_flatworld/main.mdl index 36d5e52..c86cf0f 100644 Binary files a/content_skaterift/maps/dev_flatworld/main.mdl and b/content_skaterift/maps/dev_flatworld/main.mdl differ diff --git a/content_skaterift/maps/mp_mtzero/before.mdl b/content_skaterift/maps/mp_mtzero/before.mdl index 67de6d3..861d534 100644 Binary files a/content_skaterift/maps/mp_mtzero/before.mdl and b/content_skaterift/maps/mp_mtzero/before.mdl differ diff --git a/content_skaterift/maps/mp_mtzero/main.mdl b/content_skaterift/maps/mp_mtzero/main.mdl index d7c2658..20e6aa9 100644 Binary files a/content_skaterift/maps/mp_mtzero/main.mdl and b/content_skaterift/maps/mp_mtzero/main.mdl differ diff --git a/content_skaterift/models/workshop/longboard.mdl b/content_skaterift/models/workshop/longboard.mdl new file mode 100644 index 0000000..c528204 Binary files /dev/null and b/content_skaterift/models/workshop/longboard.mdl differ diff --git a/content_skaterift/models/workshop/popsicle.mdl b/content_skaterift/models/workshop/popsicle.mdl new file mode 100644 index 0000000..676b2a0 Binary files /dev/null and b/content_skaterift/models/workshop/popsicle.mdl differ diff --git a/content_skaterift/models/workshop/regular.mdl b/content_skaterift/models/workshop/regular.mdl index c4d1e99..9a519d6 100644 Binary files a/content_skaterift/models/workshop/regular.mdl and b/content_skaterift/models/workshop/regular.mdl differ diff --git a/src/board_maker.c b/src/board_maker.c index 77c6eb3..35ab07a 100644 --- a/src/board_maker.c +++ b/src/board_maker.c @@ -77,7 +77,7 @@ static void _board_maker_image_thread( void *_ ) static void _async_board_maker_load_finish( void *payload, u32 size ) { _board_maker.state = k_board_maker_state_none; - _board_maker.model_loaded = 1; + _board_maker.template_loaded = _board_maker.template_selection; _board_maker.compositor_state = k_board_maker_compositor_dirty; _board_maker.base_shader = NULL; @@ -96,16 +96,26 @@ static void _async_board_maker_load_finish( void *payload, u32 size ) _board_maker.base_shader = mat0->props.compiled; } -static void _board_maker_load_template( void *_ ) +struct ui_enum_opt _board_maker_template_opts[] = { - vg_linear_clear( _board_maker.template_heap ); + { 0, "Old School" }, + { 1, "Popsicle" }, + { 2, "Longboard" } +}; - const char *mdl_path = "models/workshop/regular.mdl"; +const char *_board_maker_template_paths[] = +{ + [0] = "models/workshop/regular.mdl", + [1] = "models/workshop/popsicle.mdl", + [2] = "models/workshop/longboard.mdl" +}; - if( _board_maker.board_type == k_board_maker_type_regular ){} +static void _board_maker_load_template( void *_ ) +{ + vg_linear_clear( _board_maker.template_heap ); mdl_context *mdl = &_board_maker.template_mdl; - mdl_open( mdl, mdl_path, _board_maker.template_heap ); + mdl_open( mdl, _board_maker_template_paths[_board_maker.template_selection], _board_maker.template_heap ); mdl_load_metadata_block( mdl, _board_maker.template_heap ); /* we need this for compiling it back down */ @@ -233,7 +243,7 @@ void _board_maker_pre_update(void) if( _board_maker.state == k_board_maker_state_none ) { - if( _board_maker.model_loaded ) + if( _board_maker.template_loaded == _board_maker.template_selection ) { if( _board_maker.compositor_state == k_board_maker_compositor_dirty ) { @@ -250,7 +260,6 @@ void _board_maker_pre_update(void) shader_workshop_compositor_uTexMain( 0 ); shader_workshop_compositor_uTexDecal( 1 ); - if( _board_maker.base_shader ) { for( u32 i=0; ient_camera, mdl_entity_id_id(challenge->camera_id) ), &temp ); - //world_set_entity_driven_camera( &temp ); + _board_maker.zoom += _board_maker.zoom_v * vg.time_frame_delta; + _board_maker.zoom = vg_clampf( _board_maker.zoom, 0.1f, 2.0f ); + + vg_camera cam; + v3f v0; + v3_sub( _board_maker.origin, _board_maker.camera_pos, v0 ); + v3_normalize( v0 ); + v3_angles( v0, cam.angles ); + cam.fov = 90.0f; + v3_muladds( _board_maker.origin, v0, -_board_maker.zoom, cam.pos ); + world_set_entity_driven_camera( &cam ); + + v3f vx; + v3_cross( v0, (v3f){0,1,0}, vx ); + + v4f qy, qx; + q_axis_angle( qy, (v3f){0,1,0}, _board_maker.w[0] * vg.time_frame_delta ); + q_mul( qy, _board_maker.q, _board_maker.q ); + q_normalize( _board_maker.q ); + + q_axis_angle( qx, vx, _board_maker.w[1] * vg.time_frame_delta ); + q_mul( qx, _board_maker.q, _board_maker.q ); + q_normalize( _board_maker.q ); + + /* dampen movement */ + f32 damp = vg_maxf(0.0f, 1.0f-(vg.time_frame_delta * 5.0f) ); + _board_maker.zoom_v *= damp; + v2_muls( _board_maker.w, damp, _board_maker.w ); } void _board_maker_render( world_instance *world, vg_camera *cam ) @@ -338,7 +378,7 @@ void _board_maker_render( world_instance *world, vg_camera *cam ) if( _world.event != k_world_event_board_maker ) return; - if( _board_maker.model_loaded ) + if( _board_maker.template_loaded >= 0 ) { vg_framebuffer_bind_texture( &_board_maker.compositor_fb, 0, 0 ); @@ -351,14 +391,7 @@ void _board_maker_render( world_instance *world, vg_camera *cam ) m4x3f root_mmdl; m4x3_identity( root_mmdl ); - - v4f qx, qy, qq; - q_axis_angle( qx, (v3f){1,0,0}, vg.time*0.1f ); - q_axis_angle( qy, (v3f){0,1,0}, vg.time*0.2f ); - q_mul( qx, qy, qq ); - q_normalize( qq ); - q_m3x3( qq, root_mmdl ); - + q_m3x3( _board_maker.q, root_mmdl ); v3_copy( _board_maker.origin, root_mmdl[3] ); mdl_context *mdl = &_board_maker.template_mdl; @@ -621,6 +654,18 @@ void _board_maker_ui( ui_context *ctx ) ui_rect root = { 8, 8, 200, 600 }, panel; ui_panel( ctx, root, panel ); + ui_info( ctx, panel, "\xbf Drag and drop colors\n" + "to copy them." ); + + ui_enum( ctx, panel, "template", _board_maker_template_opts, 3, &_board_maker.template_selection ); + + bool click_out_of_panel = 1, + scroll_out_of_panel = 1; + + if( ui_inside_rect( root, ctx->mouse_click ) ) + click_out_of_panel = 0; + if( ui_inside_rect( root, ctx->mouse ) ) + scroll_out_of_panel = 0; if( !ui_click_up( ctx, UI_MOUSE_LEFT ) ) _board_maker.ui_dropper_colour = NULL; @@ -672,6 +717,8 @@ void _board_maker_ui( ui_context *ctx ) ui_fill( ctx, bib, colour ); } + ui_spacer( ctx, panel ); + ui_rect export_box; ui_standard_widget( ctx, panel, export_box, 2 ); if( ui_button_text( ctx, export_box, "Export", 1 ) == k_ui_button_click ) @@ -694,6 +741,11 @@ void _board_maker_ui( ui_context *ctx ) _board_maker.pop_panel[2] = 300; _board_maker.pop_panel[3] = 176; + if( ui_inside_rect( _board_maker.pop_panel, ctx->mouse_click ) ) + click_out_of_panel = 0; + if( ui_inside_rect( _board_maker.pop_panel, ctx->mouse ) ) + scroll_out_of_panel = 0; + ui_rect picker_panel, ok_box; ui_panel( ctx, _board_maker.pop_panel, picker_panel ); @@ -717,6 +769,12 @@ void _board_maker_ui( ui_context *ctx ) _board_maker.pop_panel[0] = root[0] + root[2] + 8; _board_maker.pop_panel[2] = 400; _board_maker.pop_panel[3] = 127; + + if( ui_inside_rect( _board_maker.pop_panel, ctx->mouse_click ) ) + click_out_of_panel = 0; + if( ui_inside_rect( _board_maker.pop_panel, ctx->mouse ) ) + scroll_out_of_panel = 0; + ui_panel( ctx, _board_maker.pop_panel, decal_panel ); /* top bar */ @@ -814,6 +872,9 @@ void _board_maker_ui( ui_context *ctx ) ui_rect fb_rect = { root[0]+root[2]+8, root[1], 800, 600 }; ui_panel( ctx, fb_rect, fb_rect ); + click_out_of_panel = 0; + scroll_out_of_panel = 0; + enum filebrowser_action action = vg_filebrowser_ui( ctx, fb_rect, _board_maker.browser ); if( action != k_filebrowser_action_none ) @@ -839,15 +900,31 @@ void _board_maker_ui( ui_context *ctx ) }; ui_start_modal( ctx, "Exit board maker?", "EXIT", UI_MODAL_OK|UI_MODAL_CANCEL, &callbacks ); } + + if( ui_clicking( ctx, UI_MOUSE_LEFT ) && click_out_of_panel ) + { + v2f a = { vg.mouse_delta[0], vg.mouse_delta[1] }; + v2_muladds( _board_maker.w, a, vg.time_frame_delta * 2.0f, _board_maker.w ); + } + + if( scroll_out_of_panel ) + { + _board_maker.zoom_v += (f32)vg.mouse_wheel[1] * vg.time_frame_delta * -15.0f; + } } void _board_maker_open(void) { VG_ASSERT( _board_maker.state == k_board_maker_state_not_ready ); - VG_ASSERT( _board_maker.model_loaded == 0 ); VG_ASSERT( _board_maker.static_heap == NULL ); VG_ASSERT( _board_maker.template_heap == NULL ); + q_identity( _board_maker.q ); + v3_zero( _board_maker.w ); + _board_maker.zoom = 1.0f; + _board_maker.template_loaded = -1; + _board_maker.template_selection = 0; + _board_maker.static_heap = _vg_create_linear_allocator( NULL, 8*1024*1024, VG_MEMORY_SYSTEM, "Board maker static" ); _board_maker.template_heap = _vg_create_linear_allocator( NULL, 16*1024*1024, VG_MEMORY_SYSTEM, "Board maker dynamic" ); @@ -865,6 +942,10 @@ void _board_maker_open(void) vg_filebrowser_set_path_to_home( browser ); browser->mode = k_filebrowser_mode_pick_file; browser->filter = 0x1 << k_media_type_image; + + localplayer.immobile = 1; + menu.disable_open = 1; + srinput.state = k_input_state_resume; } void _board_maker_close(void) @@ -886,5 +967,9 @@ void _board_maker_close(void) _board_maker.template_heap = NULL; _board_maker.state = k_board_maker_state_not_ready; mdl_sync_std_unload( &_board_maker.template_mdl ); - _board_maker.model_loaded = 0; + _board_maker.template_loaded = -1; + + localplayer.immobile = 0; + menu.disable_open = 0; + srinput.state = k_input_state_resume; } diff --git a/src/board_maker.h b/src/board_maker.h index 0494715..8bc485a 100644 --- a/src/board_maker.h +++ b/src/board_maker.h @@ -17,18 +17,18 @@ v4f _board_maker_default_colours[] = struct _board_maker { - enum board_maker_type - { - k_board_maker_type_regular - } - board_type; - v3f origin; - v3f angles; + v3f camera_pos; + + v4f q; + v3f w; + f32 zoom, zoom_v; + + i32 template_selection, + template_loaded; mdl_context template_mdl; array_file_ptr template_mdl_markers; - bool model_loaded; enum board_maker_state { diff --git a/src/scripts/generic.c b/src/scripts/generic.c index 9c983cb..4b35497 100644 --- a/src/scripts/generic.c +++ b/src/scripts/generic.c @@ -3,8 +3,6 @@ static bool _skaterift_script_board_maker( ent_script_event *event ) { if( on_function_trigger( event, 0 ) ) { - v3_zero( _board_maker.angles ); - if( world_set_event( k_world_event_board_maker ) ) { ent_list *list = event->entity_list; @@ -18,7 +16,17 @@ static bool _skaterift_script_board_maker( ent_script_event *event ) if( type == k_ent_marker ) { ent_marker *marker = af_arritm( &event->world->ent_marker, index ); - v3_copy( marker->transform.co, _board_maker.origin ); + + const char *alias = af_str( &event->world->meta.af, marker->pstr_alias ); + + if( !strcmp( alias, "$board_position" ) ) + { + v3_copy( marker->transform.co, _board_maker.origin ); + } + else if( !strcmp( alias, "$camera_position" ) ) + { + v3_copy( marker->transform.co, _board_maker.camera_pos ); + } } } _board_maker_open(); diff --git a/src/skaterift.c b/src/skaterift.c index ad67833..0edf3f1 100644 --- a/src/skaterift.c +++ b/src/skaterift.c @@ -131,6 +131,9 @@ void game_load(void) vg_loader_set_user_information( "Loading savedata" ); skaterift_load_mainsave(); + if( skaterift.override_load_world ) + _world.loader_reg = addon_mount_local_addon( skaterift.override_load_world, k_addon_type_world, ".mdl" ); + _world.loader_instance = &_world.main; _world.loader_preview_mode = 0; _world.loader_heap = _world.heap;