From: hgn Date: Tue, 8 Aug 2023 17:58:51 +0000 (+0100) Subject: cool font shader and entity bvh fix X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=c16f95624c142beec1572baa24f262e8a661f3fb;p=carveJwlIkooP6JGAAIwe30JlM.git cool font shader and entity bvh fix --- diff --git a/blender_export.py b/blender_export.py index 52f674f..8d4c12f 100644 --- a/blender_export.py +++ b/blender_export.py @@ -4260,6 +4260,20 @@ def cv_draw():#{ data = obj.SR_data.ent_unlock[0] if data.target: cv_draw_arrow( obj.location, data.target.location, (0,1.0,0.0) ) + cc1 = (0.4,0.3,0.2) + info_cu = Vector((1.2,0.01,0.72))*0.5 + info_co = Vector((0.0,0.0,0.72))*0.5 + cv_draw_ucube( obj.matrix_world, cc1, info_cu, info_co) + + vs = [Vector((-0.2,0.0,0.10)),Vector((-0.2,0.0,0.62)),\ + Vector(( 0.2,0.0,0.62)),Vector((-0.2,0.0,0.30)),\ + Vector(( 0.1,0.0,0.30))] + for v in range(len(vs)):#{ + vs[v] = obj.matrix_world @ vs[v] + #} + + cv_view_verts += [vs[0],vs[1],vs[1],vs[2],vs[3],vs[4]] + cv_view_colours += [cc1,cc1,cc1,cc1,cc1,cc1] #} elif ent_type == 'ent_audio':#{ if obj.SR_data.ent_audio[0].flag_3d: diff --git a/highscores.c b/highscores.c index 77ffc41..6593b9a 100644 --- a/highscores.c +++ b/highscores.c @@ -402,26 +402,30 @@ VG_STATIC int highscore_intr( char *buf, int value, int len, char alt ) /* Print integer into buffer with max length len * retuns the number of digits written to buf */ -VG_STATIC int highscore_intl( char *buf, int value, int len ) -{ - char temp[32]; +VG_STATIC int highscore_intl( char *buf, int value, int len ){ + if( value ){ + char temp[32]; + int i=0; + while(value){ + if( i>=len ) + break; + + temp[ i ++ ] = '0' + (value % 10); + value /= 10; + } - int i=0; - while(value){ - if( i>=len ) - break; + if( i>len ) + i = len; - temp[ i ++ ] = '0' + (value % 10); - value /= 10; - } - - if( i>len ) - i = len; - - for( int j=0; jto_world, bound, (boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}} ); } + else if( type == k_ent_unlock ){ + ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index ); + + boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f}, + { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}}; + m4x3f transform; + mdl_transform_m4x3( &unlock->transform, transform ); + m4x3_expand_aabb_aabb( transform, bound, box ); + } + else{ + vg_fatal_error( "Programming error\n" ); + } } VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){ @@ -415,6 +427,15 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index ){ (boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}}, 0xf000ff00 ); } + else if( type == k_ent_unlock ){ + ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index ); + + boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f}, + { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}}; + m4x3f transform; + mdl_transform_m4x3( &unlock->transform, transform ); + vg_line_boxf_transformed( transform, box, 0xf0ff0000 ); + } else{ vg_fatal_error( "Programming error\n" ); } @@ -440,6 +461,10 @@ VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point, ent_volume *volume = mdl_arritm( &world->ent_volume, index ); v3_copy( volume->to_world[3], closest ); } + else if( type == k_ent_unlock ){ + ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index ); + v3_copy( unlock->transform.co, closest ); + } else{ vg_fatal_error( "Programming error\n" ); } diff --git a/world_render.c b/world_render.c index fc2d34f..55d13d4 100644 --- a/world_render.c +++ b/world_render.c @@ -418,7 +418,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, /* sort lists */ const f32 radius = 40.0f; bh_iter it; - bh_iter_init_range( 0, &it, pos, radius ); + bh_iter_init_range( 0, &it, pos, radius+10.0f ); i32 idx; u32 challenge_list[ 32 ], @@ -452,7 +452,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, if( challenge->flags & k_ent_challenge_hidden ) continue; f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius), - scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) ); + scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) ); v3_fill( challenge->transform.s, scale ); @@ -479,6 +479,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, shader_scene_font_uTexGarbage(0); shader_scene_font_uTexMain(1); shader_scene_font_uPv( skaterift.cam.mtx.pv ); + shader_scene_font_uTime( vg.time ); /* TODO: Code dupe... */ world_link_lighting_ub( world, _shader_scene_font.id ); @@ -498,11 +499,44 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, mesh_bind( &gui.font.mesh ); + char buf[32]; + u32 count = 0; + + for( u32 i=0; ient_unlock); i++ ){ + ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i ); + vg_line_point( unlock->transform.co, 0.2f, VG__GREEN ); + if( unlock->status ) count ++; + } + + int c=0; + c+=highscore_intl( buf+c, count, 3 ); + buf[c++] = '/'; + c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_unlock), 3 ); + buf[c++] = '\0'; + + f32 w = font3d_string_width( &gui.font, 1, buf ); + m4x3f mlocal; + m3x3_identity( mlocal ); + mlocal[3][0] = -w*0.5f; + for( u32 i=0; ient_unlock, index ); m4x3f mmdl; mdl_transform_m4x3( &unlock->transform, mmdl ); + m4x3_mul( mmdl, mlocal, mmdl ); + + vg_line_point( unlock->transform.co, 0.25f, VG__RED ); + + f32 dist = v3_dist( unlock->transform.co, pos ) * (1.0f/radius), + scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) ), + colour = 0.0f; + + if( unlock->status ) + colour = 1.0f; + + shader_scene_font_uOpacity( scale ); + shader_scene_font_uColourize( colour ); struct font3d_render render = { .font = &gui.font, @@ -510,7 +544,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, .shader = k_font_shader_world }; - font3d_begin( "Test!", &skaterift.cam, mmdl, &render ); + font3d_begin( buf, &skaterift.cam, mmdl, &render ); font3d_draw( &render ); } }