mission is possible
authorhgn <hgodden00@gmail.com>
Tue, 16 May 2023 02:27:46 +0000 (03:27 +0100)
committerhgn <hgodden00@gmail.com>
Tue, 16 May 2023 02:27:46 +0000 (03:27 +0100)
blender_export.py
entity.h
maps_src/mp_mtzero.mdl
maps_src/mp_spawn.mdl
skaterift.c
world.h
world_gen.h
world_render.h

index f27123773e24397891e41edd2769e5297af79e84..3e6bb108853a4af2d38d0323e2c1812dfcf58397 100644 (file)
@@ -33,7 +33,8 @@ sr_entity_list = [
    ('ent_skateshop',    'Skate Shop',     '', 12 ),
    ('ent_camera',       'Camera',         '', 13 ),
    ('ent_swspreview', 'Workshop Preview', '', 14 ),
-   ('ent_menuitem',     'Menu Item',      '', 15 )
+   ('ent_menuitem',     'Menu Item',      '', 15 ),
+   ('ent_worldinfo',    'World Info',     '', 16 ),
 ]
 
 def get_entity_enum_id( alias ):
@@ -423,6 +424,14 @@ class ent_camera(Structure):
                ("fov",c_float)]
 #}
 
+class ent_worldinfo(Structure):
+#{
+   _fields_ = [("pstr_name",c_uint32),
+               ("pstr_author",c_uint32),    # unused
+               ("pstr_desc",c_uint32),      # unused
+               ("timezone",c_float)]
+#}
+
 def obj_ent_type( obj ):
 #{
    if obj.type == 'ARMATURE': return 'mdl_armature'
@@ -1695,6 +1704,15 @@ def sr_compile( collection ):
             workshop_preview.id_camera = sr_entity_id( obj_data.cam )
             sr_ent_push( workshop_preview )
          #}
+         elif ent_type == 'ent_worldinfo':#{
+            worldinfo = ent_worldinfo()
+            obj_data = obj.SR_data.ent_worldinfo[0]
+            worldinfo.pstr_name = sr_compile_string( obj_data.name )
+            worldinfo.pstr_author = sr_compile_string( obj_data.author )
+            worldinfo.pstr_desc = sr_compile_string( obj_data.desc )
+            worldinfo.timezone = obj_data.timezone
+            sr_ent_push( worldinfo )
+         #}
       #}
    #}
 
@@ -2919,6 +2937,14 @@ class SR_OBJECT_ENT_MENU_ITEM(bpy.types.PropertyGroup):
    #}
 #}
 
+class SR_OBJECT_ENT_WORLD_INFO(bpy.types.PropertyGroup):
+#{
+   name: bpy.props.StringProperty(name="Name")
+   desc: bpy.props.StringProperty(name="Description")
+   author: bpy.props.StringProperty(name="Author")
+   timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)")
+#}
+
 class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
 #{
    ent_gate: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_GATE)
@@ -2934,6 +2960,7 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
    ent_swspreview: \
          bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORKSHOP_PREVIEW)
    ent_menuitem: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MENU_ITEM)
+   ent_worldinfo: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORLD_INFO)
 
    ent_type: bpy.props.EnumProperty(
       name="Type",
@@ -4039,6 +4066,7 @@ classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
             SR_UL_FONT_VARIANT_LIST,SR_UL_FONT_GLYPH_LIST,\
             SR_OBJECT_ENT_FONT,SR_OBJECT_ENT_TRAFFIC,SR_OBJECT_ENT_SKATESHOP,\
             SR_OBJECT_ENT_WORKSHOP_PREVIEW,SR_OBJECT_ENT_MENU_ITEM,\
+            SR_OBJECT_ENT_WORLD_INFO,\
             \
             SR_OBJECT_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES, 
             SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \
index bf6b2d5b776655dc7242ffa4f7b83a86b63a1d8d..a14314a0ead9dea344529ae0ce668856a1f25565 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -24,6 +24,7 @@ typedef struct ent_glyph ent_glyph;
 typedef struct ent_skateshop ent_skateshop;
 typedef struct ent_camera ent_camera;
 typedef struct ent_swspreview ent_swspreview;
+typedef struct ent_worldinfo ent_worldinfo;
 
 enum entity_alias{
    k_ent_none        = 0,
@@ -41,7 +42,8 @@ enum entity_alias{
    k_ent_skateshop   = 12,
    k_ent_camera      = 13,
    k_ent_swspreview  = 14,
-   k_ent_menuitem    = 15
+   k_ent_menuitem    = 15,
+   k_ent_worldinfo   = 16
 };
 
 static u32 mdl_entity_id_type( u32 entity_id )
@@ -314,6 +316,11 @@ struct ent_menuitem{
    };
 };
 
+struct ent_worldinfo{
+   u32 pstr_name, pstr_author, pstr_desc;
+   f32 timezone;
+};
+
 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
                                        mdl_array_ptr *arr, const char *alias )
 {
index 25e97272bb7c00061d45def780402fdf0cc7b31c..f2e5863a92d0e3b6a59d1a40b99a195102565ee3 100644 (file)
Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ
index 87f130e9cd147f1af41487908762bb2862acdde5..1bd23ce18aa92a9d092d2a125da9fbdd66d09243 100644 (file)
Binary files a/maps_src/mp_spawn.mdl and b/maps_src/mp_spawn.mdl differ
index 9409bf33b8d5aac08b06b1d054ce2e104f590f38..9c7da4f2eaec4e4a3f3b57a5ced60f57090483f5 100644 (file)
@@ -296,7 +296,12 @@ VG_STATIC void render_scene(void)
       return;
    }
 
-   world_prerender( view_world );
+   for( u32 i=0; i<vg_list_size(world_global.worlds); i++ ){
+      if( world_global.worlds[i].status == k_world_status_loaded ){
+         world_prerender( &world_global.worlds[i] );
+      }
+   }
+
    render_world( view_world, &main_camera, 0 );
 
    render_water_texture( view_world, &main_camera, 0 );
diff --git a/world.h b/world.h
index 420523bc2a28cbcf08fccd609ada40cfc8baf87c..68c3f2b2ed4e9217fda06834e979f50f4cda5ca6 100644 (file)
--- a/world.h
+++ b/world.h
@@ -56,6 +56,7 @@ enum geo_type
 static const float k_light_cube_size = 8.0f;
 
 struct world_instance {
+
    /* Fixed items
     * -------------------------------------------------------
     */
@@ -79,6 +80,8 @@ struct world_instance {
    }
    water;
 
+   f64 time;
+
    /* STD140 */
    struct ub_world_lighting{
       v4f g_cube_min,
@@ -153,6 +156,7 @@ struct world_instance {
    * surfaces;
    u32 surface_count;
 
+   ent_worldinfo info;
    mdl_array_ptr ent_spawn,
                  ent_gate,
                  ent_light,
@@ -238,7 +242,6 @@ struct world_global{
    int switching_to_new_world;
 
    world_instance worlds[4];
-   u32            world_count;
    u32            active_world;
 
    /* text particles */
index c8c7fb797b419ca80da92801d127b3c7c3ff2dd9..2bada3aa5fcd79acb692054b0c9a239c38accddf 100644 (file)
@@ -637,6 +637,7 @@ VG_STATIC void world_init_blank( world_instance *world )
    world->rendering_gate = NULL;
 
    world->water.enabled = 0;
+   world->time = 0.0;
 
    /* default lighting conditions 
     * -------------------------------------------------------------*/
@@ -838,6 +839,25 @@ VG_STATIC void world_load( u32 index, const char *path )
    mdl_load_array( meta, &world->ent_skateshop, "ent_skateshop",  heap );
    mdl_load_array( meta, &world->ent_swspreview,"ent_swspreview", heap );
 
+   mdl_array_ptr infos;
+   mdl_load_array( meta, &infos, "ent_worldinfo", vg_mem.scratch );
+
+   if( mdl_arrcount(&infos) ){
+      world->info = *((ent_worldinfo *)mdl_arritm(&infos,0));
+   }
+   else{
+      world->info.pstr_author = 0;
+      world->info.pstr_desc = 0;
+      world->info.pstr_name = 0;
+      world->info.timezone = 0.0f;
+   }
+
+   time_t t;
+   struct tm *tm;
+   time( &t );
+   tm = gmtime( &t );
+   world->time = (float)tm->tm_min/20.0f + (world->info.timezone/24.0f);
+
    /* process resources from pack */
    world_process_resources( world );
 
index 790f9a1b8ffb6cf7e523077bb7030e86d2693f7f..ef5946e9941298076b71c9cb6bb1228d0252d83d 100644 (file)
@@ -415,17 +415,16 @@ VG_STATIC void render_world_gates( world_instance *world, camera *cam,
 
 VG_STATIC void world_prerender( world_instance *world )
 {
-   static double g_time = 0.0;
-   g_time += vg.time_delta * (1.0/(k_day_length*60.0));
+   world->time += vg.time_delta * (1.0/(k_day_length*60.0));
 
    struct ub_world_lighting *state = &world->ub_lighting;
 
-   state->g_time = g_time;
+   state->g_time = world->time;
    state->g_realtime = vg.time;
    state->g_debug_indices = k_debug_light_indices;
    state->g_light_preview = k_light_preview;
    state->g_debug_complexity = k_debug_light_complexity;
-   state->g_time_of_day = vg_fractf( g_time );
+   state->g_time_of_day = vg_fractf( world->time );
    state->g_day_phase   = cosf( state->g_time_of_day * VG_PIf * 2.0f );
    state->g_sunset_phase= cosf( state->g_time_of_day * VG_PIf * 4.0f + VG_PIf );
 
@@ -438,9 +437,7 @@ VG_STATIC void world_prerender( world_instance *world )
    state->g_sun_dir[2] = 0.2f;
    v3_normalize( state->g_sun_dir );
 
-
    world->probabilities[ k_probability_curve_constant ] = 1.0f;
-
    float dp = state->g_day_phase;
 
    world->probabilities[ k_probability_curve_wildlife_day ] =
@@ -448,7 +445,6 @@ VG_STATIC void world_prerender( world_instance *world )
    world->probabilities[ k_probability_curve_wildlife_night ] = 
       1.0f-powf(fabsf((state->g_time_of_day-0.5f)*5.0f),5.0f);
       
-
    glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
    glBufferSubData( GL_UNIFORM_BUFFER, 0, 
                     sizeof(struct ub_world_lighting), &world->ub_lighting );