('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 ):
("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'
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 )
+ #}
#}
#}
#}
#}
+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)
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",
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 \
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,
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 )
};
};
+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 )
{
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 );
static const float k_light_cube_size = 8.0f;
struct world_instance {
+
/* Fixed items
* -------------------------------------------------------
*/
}
water;
+ f64 time;
+
/* STD140 */
struct ub_world_lighting{
v4f g_cube_min,
* surfaces;
u32 surface_count;
+ ent_worldinfo info;
mdl_array_ptr ent_spawn,
ent_gate,
ent_light,
int switching_to_new_world;
world_instance worlds[4];
- u32 world_count;
u32 active_world;
/* text particles */
world->rendering_gate = NULL;
world->water.enabled = 0;
+ world->time = 0.0;
/* default lighting conditions
* -------------------------------------------------------------*/
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 );
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 );
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 ] =
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 );