location gui
authorhgn <hgodden00@gmail.com>
Sun, 28 May 2023 02:04:16 +0000 (03:04 +0100)
committerhgn <hgodden00@gmail.com>
Sun, 28 May 2023 02:04:16 +0000 (03:04 +0100)
gui.h
maps_src/mp_mtzero/main.mdl
maps_src/mp_spawn/main.mdl
player_common.h
render.h
world.c
world.h
world_audio.c

diff --git a/gui.h b/gui.h
index c057ce6ebd71f415b84ddd025a68457b9a511577..e4d0068889de65ee8abc83aa2cc2a1bd7f93c185 100644 (file)
--- a/gui.h
+++ b/gui.h
@@ -10,6 +10,9 @@ struct{
    helpers[4];
    u32 helper_count;
 
+   char location[64];
+   f64  location_time;
+
    f32 factive;
    font3d font;
 }
@@ -53,13 +56,46 @@ void gui_draw(void)
       render_fsquad1();
    }
 
+   f64 loc_t = (vg.time - gui.location_time) / 5.0;
+   if( (loc_t < 1.0) && (gui.location_time != 0.0) ){
+      /* yep this code is a mess, i dont care anymore */
+      glEnable(GL_BLEND);
+      glDisable(GL_DEPTH_TEST);
+      glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+      glBlendEquation(GL_FUNC_ADD);
+
+      f32 t = 1.0f-vg_minf(1.0f,vg_minf(loc_t*20.0f,2.0f-loc_t*2.0f)),
+          o = 1.0f-t*t*(2.0f-t);
+
+      shader_blitcolour_use();
+      shader_blitcolour_uColour( (v4f){ 0.0f, 0.0f, 0.0f, o*0.5f } );
+      render_fsquad2();
+      
+      f32 dy    = ft/0.79f,
+         scale = dy*0x1p-4f*0.5f;
+
+      m4x3f mmdl;
+      m3x3_identity( mmdl );
+      m3x3_scale( mmdl, (v3f){scale,scale,scale} );
+      v3_zero( mmdl[3] );
+
+      f32 pad = dy*0x1p-4f*0.125f;
+      f32 w = font3d_string_width( &gui.font,2,gui.location );
+
+      mmdl[3][0] = fr*0.5f - w*scale*0.5f;
+      mmdl[3][1] = 0.3f*ft+pad*2.0f;
+
+      font3d_bind( &gui.font, &ortho );
+      shader_model_font_uColour( (v4f){1.2f,1.2f,1.2f,o} );
+      font3d_simple_draw( &gui.font, 2, gui.location, &ortho, mmdl );
+   }
+
    font3d_bind( &gui.font, &ortho );
 
    float dy    = ft/0.79f,
          scale = dy*0x1p-4f*0.75f;
 
    m4x3f mmdl;
-   v4f q;
    m3x3_identity( mmdl );
    m3x3_scale( mmdl, (v3f){scale,scale,scale} );
    v3_zero( mmdl[3] );
@@ -104,9 +140,27 @@ void gui_helper_action( const char *bindstr, const char *text )
    helper->text = text;
 }
 
+VG_STATIC
+int gui_location_print_ccmd( int argc, const char *argv[] ){
+   if( argc > 0 ){
+      char new_loc[64];
+      vg_str str;
+      vg_strnull( &str, new_loc, 64 );
+      for( int i=0; i<argc; i++ ){
+         vg_strcat( &str, argv[i] );
+         vg_strcat( &str, " " );
+      }
+      if( !strcmp(gui.location,new_loc) ) return 0;
+      vg_strncpy( new_loc, gui.location, 64, k_strncpy_always_add_null );
+      gui.location_time = vg.time;
+   }
+   return 0;
+}
+
 VG_STATIC void gui_init(void)
 {
    font3d_load( &gui.font, "models/rs_font.mdl", vg_mem.rtmemory );
+   vg_console_reg_cmd( "gui_location", gui_location_print_ccmd, NULL );
 }
 
 #endif /* GUI_H */
index 32a44d909de9fc3422ea460af2f52254e65d2c9d..45ebbbf4930a979fc3078b66b486437c9e7b51f4 100644 (file)
Binary files a/maps_src/mp_mtzero/main.mdl and b/maps_src/mp_mtzero/main.mdl differ
index 56ef1b389b1bc3f1ab05c0fce11c7dd94eaec825..13847efcf3522ff1415744a6ce3f9e791c7d8ae6 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
index ab982289db1e72696d85be059fc07745b73ac921..2be689e09c3d397b8a7b816926f5dc3a439cb685 100644 (file)
@@ -9,8 +9,8 @@ VG_STATIC float
    k_cam_spring            =  20.0f,
    k_cam_damp              =  6.7f,
    k_cam_punch             = -1.0f,
-   k_cam_shake_strength    =  1.0f,
-   k_cam_shake_trackspeed  =  1.0f;
+   k_cam_shake_strength    =  0.0001f,
+   k_cam_shake_trackspeed  =  0.2f;
 
 VG_STATIC void player_look( player_instance *player, v3f angles );
 VG_STATIC void player__cam_iterate( player_instance *player );
index d626b7a0a013e07af77c64dfaac33d727237bca1..6b956de3eb867a8d261057c95dbf5b34e9243ba3 100644 (file)
--- a/render.h
+++ b/render.h
@@ -526,12 +526,14 @@ VG_STATIC void async_render_init( void *payload, u32 size )
       render_fb_allocate( fb );
    }
 
+   f32 rh = 0x1p-4f, ih = 0.3f;
+
    float quad[] = { 
       0.00f,0.00f, 1.00f,1.00f, 0.00f,1.00f,    /* fsquad */
       0.00f,0.00f, 1.00f,0.00f, 1.00f,1.00f,    
 
-      0.00f,0.00f, 1.00f,0x1p-4f,0.00f,0x1p-4f,    /* fsquad1 */
-      0.00f,0.00f, 1.00f,0.00f,  1.00f,0x1p-4f,
+      0.00f,0.00f, 1.00f,rh,     0.00f,rh,    /* fsquad1 */
+      0.00f,0.00f, 1.00f,0.00f,  1.00f,rh,
 
       /* 9x9 debug grid */
       /* row0 */
@@ -555,6 +557,9 @@ VG_STATIC void async_render_init( void *payload, u32 size )
       0.30f,0.60f, 0.60f,0.60f, 0.60f,0.90f,
       0.60f,0.60f, 0.90f,0.90f, 0.60f,0.90f,
       0.60f,0.60f, 0.90f,0.60f, 0.90f,0.90f,
+
+      0.00f,ih, 1.00f,ih+rh, 0.00f,ih+rh,    /* fsquad2 */
+      0.00f,ih, 1.00f,ih,    1.00f,ih+rh,
    };
 
    vg_console_reg_cmd( "fb", render_framebuffer_control, 
@@ -602,6 +607,12 @@ VG_STATIC void render_fsquad1(void)
    glDrawArrays( GL_TRIANGLES, 6, 6 );
 }
 
+VG_STATIC void render_fsquad2(void)
+{
+   glBindVertexArray( gpipeline.fsquad.vao );
+   glDrawArrays( GL_TRIANGLES, 66,6 );
+}
+
 /*
  * Call this inside the UI function
  */
diff --git a/world.c b/world.c
index 209de3e5d17e3275e8b1e5155bafc1f0e14944b0..5cc7841641acfe46e91e686079431440694bade0 100644 (file)
--- a/world.c
+++ b/world.c
@@ -179,6 +179,34 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
    }
    sfd_update();
 
+   /* volumes
+    * -------------------------------------------------------------------------
+    */
+
+   /* filter and check the existing ones 
+    * TODO: on change world, clear volumes list */
+   u32 j=0;
+   for( u32 i=0; i<world_static.active_trigger_volume_count; i++ ){
+      i32 idx = world_static.active_trigger_volumes[i];
+      ent_volume *volume = mdl_arritm( &world->ent_volume, idx );
+
+      v3f local;
+      m4x3_mulv( volume->to_local, pos, local );
+      if( (fabsf(local[0]) <= 1.0f) &&
+          (fabsf(local[1]) <= 1.0f) &&
+          (fabsf(local[2]) <= 1.0f) )
+      {
+         world_static.active_trigger_volumes[ j ++ ] = idx;
+         boxf cube = {{-1.0f,-1.0f,-1.0f},{1.0f,1.0f,1.0f}};
+         vg_line_boxf_transformed( volume->to_world, cube, 0xff00ccff );
+         /* triggr on stay ..... */
+      }
+      else{
+         /* trigger on exit...... */
+      }
+   }
+   world_static.active_trigger_volume_count = j;
+
    static float random_accum = 0.0f;
    random_accum += vg.time_delta;
 
@@ -198,14 +226,19 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
    bh_iter_init_box( 0, &it, volume_proximity );
    i32 idx;
 
-   int in_volume = 0;
-
    while( bh_next( world->volume_bh, &it, &idx ) ){
       ent_volume *volume = mdl_arritm( &world->ent_volume, idx );
 
       boxf cube = {{-1.0f,-1.0f,-1.0f},{1.0f,1.0f,1.0f}};
       
       if( volume->type == k_volume_subtype_trigger ){
+         for( u32 i=0; i<world_static.active_trigger_volume_count; i++ )
+            if( world_static.active_trigger_volumes[i] == idx )
+               goto next_volume;
+
+         if( world_static.active_trigger_volume_count > 
+               vg_list_size(world_static.active_trigger_volumes) ) continue;
+
          v3f local;
          m4x3_mulv( volume->to_local, pos, local );
 
@@ -213,20 +246,17 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
              (fabsf(local[1]) <= 1.0f) &&
              (fabsf(local[2]) <= 1.0f) )
          {
-            in_volume = 1;
-            vg_line_boxf_transformed( volume->to_world, cube, 0xff00ff00 );
-
-            if( !world_static.in_volume ){
-               ent_call basecall;
-               basecall.function = k_ent_function_trigger;
-               basecall.id = mdl_entity_id( k_ent_volume, idx );
-               basecall.data = NULL;
+            ent_call basecall;
+            basecall.function = k_ent_function_trigger;
+            basecall.id = mdl_entity_id( k_ent_volume, idx );
+            basecall.data = NULL;
 
-               entity_call( world, &basecall );
-            }
+            entity_call( world, &basecall );
+            world_static.active_trigger_volumes[ 
+               world_static.active_trigger_volume_count ++ ] = idx;
          }
          else
-            vg_line_boxf_transformed( volume->to_world, cube, 0xff0000ff );
+            vg_line_boxf_transformed( volume->to_world, cube, 0xffcccccc );
       }
       else if( volume->type == k_volume_subtype_particle ){
          vg_line_boxf_transformed( volume->to_world, cube, 0xff00c0ff );
@@ -239,8 +269,8 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
             entity_call( world, &basecall );
          }
       }
+next_volume:;
    }
-   world_static.in_volume = in_volume;
 
 #if 0
    if( k_debug_light_indices )
@@ -261,7 +291,6 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
          vg_line_pt3( light->node->co, 0.25f, colour );
       }
    }
-
 #endif
 }
 
diff --git a/world.h b/world.h
index 58ff1b6bd4b4fb82a0b1f44f7124a22c390aa89c..a3f69a5dc5043dd9af02998f510d70bcd012a946 100644 (file)
--- a/world.h
+++ b/world.h
@@ -192,10 +192,11 @@ struct world_static {
    u32 current_run_version;
    double time, rewind_from, rewind_to, last_use;
 
-   int in_volume;
+   u32 active_trigger_volumes[8];
+   u32 active_trigger_volume_count;
 
    world_instance worlds[4];
-   u32            active_world;
+   i32            active_world;
 }
 static world_static;
 
index facbcc46c5373db8ba6c14e2bb288a4f561d23c7..ee1aeca7d7587db621b3d829fca5543bcbbb2ce9 100644 (file)
@@ -115,7 +115,7 @@ VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value )
 
    distances[si] = dist;
 
-   if( vg_lines.draw ){
+   if( vg_audio.debug_ui && vg_lines.draw ){
       for( int i=0; i<14; i++ ){
          if( distances[i] != 200.0f ){
             u32 colours[] = { VG__RED, VG__BLUE, VG__GREEN,