update compiler for blender 3.4.1
authorhgn <hgodden00@gmail.com>
Sat, 31 Dec 2022 16:05:13 +0000 (16:05 +0000)
committerhgn <hgodden00@gmail.com>
Sat, 31 Dec 2022 16:05:13 +0000 (16:05 +0000)
blender_export.py
maps_src/mp_mtzero.mdl
menu.h
player.h
player_animation.h

index cf6d3f7dd9d4fcde68765723ec608ed3ffa2291a..8cd60ea7d15240eb82ade9c56dc8afb5471a9b93 100644 (file)
@@ -1009,8 +1009,8 @@ cxr_graph_mapping = \
          },
          "Mix":
          {
-            "Color1": material_tex_image("tex_diffuse"),
-            "Color2": material_tex_image("tex_decal")
+            "A": material_tex_image("tex_diffuse"),
+            "B": material_tex_image("tex_decal")
          },
       },
       "Normal":
@@ -1063,9 +1063,20 @@ def material_info(mat):
 
          if isinstance( link_def, dict ):
          #{
-            node_link = node.inputs[link]
+            node_link = None
+            for x in node.inputs:
+            #{
+               if isinstance( x, bpy.types.NodeSocketColor ):
+               #{
+                  if link == x.name:
+                  #{
+                     node_link = x
+                     break
+                  #}
+               #}
+            #}
 
-            if node_link.is_linked:
+            if node_link and node_link.is_linked:
             #{
                # look for definitions for the connected node type
                #
@@ -2551,6 +2562,12 @@ class CV_MATERIAL_PANEL(bpy.types.Panel):
 
       info = material_info( active_mat )
 
+      if 'tex_diffuse' in info:
+      #{
+         _.layout.label( icon='INFO', \
+            text=F"{info['tex_diffuse'].name} will be compiled" )
+      #}
+
       _.layout.prop( active_mat.cv_data, "shader" )
       _.layout.prop( active_mat.cv_data, "surface_prop" )
       _.layout.prop( active_mat.cv_data, "collision" )
index 33fda35b581b56a505aa69267691b06a0740ec9c..7654fcb64215a6088932293588978ba012f8cf5c 100644 (file)
Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ
diff --git a/menu.h b/menu.h
index 162b76e8771456ba8cdc6225f1ac5e4d99660603..d8b686452f73015bb1d47e7844ed2eb55c5e38ab 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -488,7 +488,7 @@ VG_STATIC void menu_page_map(void)
          audio_play_oneshot( &audio_rewind[4], 1.0f );
          audio_unlock();
 
-         if( v < 0.0f )
+         if( v > 0.0f )
          {
             game_menu.selected_map --;
 
index 8e4ae82b99d0ff547c8aa61d874359d395e9b7e9..2325f72e5c3fc71f38093f5d0851d62d45b8eb51 100644 (file)
--- a/player.h
+++ b/player.h
@@ -48,6 +48,7 @@ VG_STATIC float
 VG_STATIC int freecam = 0;
 VG_STATIC int walk_grid_iterations = 1;
 VG_STATIC float fc_speed = 10.0f;
+VG_STATIC int cl_thirdperson = 0;
 
 /* 
  * -----------------------------------------------------------------------------
@@ -347,6 +348,14 @@ VG_STATIC void player_init(void)                                         /* 1 */
       .persistent = 1
    });
 
+   vg_convar_push( (struct vg_convar){
+      .name = "cl_thirdperson",
+      .data = &cl_thirdperson,
+      .data_type = k_convar_dtype_i32,
+      .opt_i32 = { .min=0, .max=1, .clamp=1 },
+      .persistent = 1
+   });
+
    vg_convar_push( (struct vg_convar){
       .name = "fcs",
       .data = &fc_speed,
@@ -614,7 +623,12 @@ VG_STATIC void player_update_post(void)
       player_animate();
 
       if( !freecam )
-         player_animate_camera();
+      {
+         if( cl_thirdperson )
+            player_animate_camera_thirdperson();
+         else
+            player_animate_camera();
+      }
    }
 
    if( freecam )
index e08991014629b05224ab5babd4754873af2cdc6a..98aa25697e1e2c843c0566885a8dbff4c83e7ee7 100644 (file)
@@ -318,6 +318,53 @@ VG_STATIC void player_animate_death_cam(void)
    player.angles[1] = -asinf( delta[1] );
 }
 
+VG_STATIC void player_animate_follow_cam( v3f target, float dist, float speed )
+{
+   v3f delta;
+
+   v3_sub( target, player.camera_pos, delta );
+   v3_normalize( delta );
+
+   v3f follow_pos;
+   v3_muladds( target, delta, -dist, follow_pos );
+   v3_lerp( player.camera_pos, follow_pos,
+             speed * vg.time_delta, player.camera_pos );
+
+   /* 
+    * Make sure the camera stays above the ground
+    */
+   v3f min_height = {0.0f,1.0f,0.0f};
+
+   v3f sample;
+   v3_add( player.camera_pos, min_height, sample );
+   ray_hit hit;
+   hit.dist = min_height[1]*2.0f;
+
+   if( ray_world( sample, (v3f){0.0f,-1.0f,0.0f}, &hit ))
+      v3_add( hit.pos, min_height, player.camera_pos );
+
+#if 0
+   if( world.water.enabled )
+   {
+      player.camera_pos[1] = 
+         vg_maxf( world.water.height + 2.0f, player.camera_pos[1] );
+   }
+#endif
+
+   player.angles[0] = atan2f( delta[0], -delta[2] ); 
+   player.angles[1] = -asinf( delta[1] );
+}
+
+VG_STATIC void player_animate_camera_thirdperson(void)
+{
+   static v3f lerp_cam = { 0.0f, 0.0f, 0.0f };
+   v3f target;
+   
+   v3_muladds( player.phys.rb.co, player.phys.rb.up, 1.2f, target );
+
+   player_animate_follow_cam( target, 1.5f, 20.0f );
+}
+
 VG_STATIC void player_animate_camera(void)
 {
    struct player_phys *phys = &player.phys;