From: hgn Date: Tue, 16 May 2023 02:27:46 +0000 (+0100) Subject: mission is possible X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=e5d79dc0355e04baecce8908e29b8e7569d1e857;p=carveJwlIkooP6JGAAIwe30JlM.git mission is possible --- diff --git a/blender_export.py b/blender_export.py index f271237..3e6bb10 100644 --- a/blender_export.py +++ b/blender_export.py @@ -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 \ diff --git a/entity.h b/entity.h index bf6b2d5..a14314a 100644 --- 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 ) { diff --git a/maps_src/mp_mtzero.mdl b/maps_src/mp_mtzero.mdl index 25e9727..f2e5863 100644 Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ diff --git a/maps_src/mp_spawn.mdl b/maps_src/mp_spawn.mdl index 87f130e..1bd23ce 100644 Binary files a/maps_src/mp_spawn.mdl and b/maps_src/mp_spawn.mdl differ diff --git a/skaterift.c b/skaterift.c index 9409bf3..9c7da4f 100644 --- a/skaterift.c +++ b/skaterift.c @@ -296,7 +296,12 @@ VG_STATIC void render_scene(void) return; } - world_prerender( view_world ); + for( u32 i=0; irendering_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 ); diff --git a/world_render.h b/world_render.h index 790f9a1..ef5946e 100644 --- a/world_render.h +++ b/world_render.h @@ -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 );