X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=blender_export.py;h=3e6bb108853a4af2d38d0323e2c1812dfcf58397;hb=e5d79dc0355e04baecce8908e29b8e7569d1e857;hp=cb3b9907ea337adc4e3ff9ee6c1c5901d3e2ae90;hpb=e8a65239f85784e2e596d2622c2baddda9fb5fae;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/blender_export.py b/blender_export.py index cb3b990..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 ): @@ -340,13 +341,29 @@ class ent_traffic(Structure): ("index",c_uint32)] #} -class ent_skateshop(Structure): +# Skateshop +# --------------------------------------------------------------- +class ent_skateshop_characters(Structure): #{ - _fields_ = [("transform",mdl_transform), - ("id_display",c_uint32), + _fields_ = [("id_display",c_uint32), + ("id_info",c_uint32)] +#} +class ent_skateshop_boards(Structure): +#{ + _fields_ = [("id_display",c_uint32), ("id_info",c_uint32), - ("id_rack",c_uint32), - ("id_camera",c_uint32)] + ("id_rack",c_uint32)] +#} +class ent_skateshop_anon_union(Union): +#{ + _fields_ = [("boards",ent_skateshop_boards), + ("character",ent_skateshop_characters)] +#} +class ent_skateshop(Structure): +#{ + _fields_ = [("transform",mdl_transform), ("type",c_uint32), + ("id_camera",c_uint32), + ("_anonymous_union",ent_skateshop_anon_union)] #} class ent_swspreview(Structure): @@ -356,6 +373,8 @@ class ent_swspreview(Structure): ("id_display1",c_uint32)] #} +# Menu +# ----------------------------------------------------------------- class ent_menuitem_slider(Structure): #{ _fields_ = [("id_min",c_uint32), @@ -363,25 +382,22 @@ class ent_menuitem_slider(Structure): ("id_handle",c_uint32), ("pstr_data",c_uint32)] #} - class ent_menuitem_button(Structure): #{ _fields_ = [("pstr",c_uint32)] #} - class ent_menuitem_checkmark(Structure): #{ _fields_ = [("id_check",c_uint32), - ("pstr_data",c_uint32)] + ("pstr_data",c_uint32), + ("offset",c_float*3)] #} - class ent_menuitem_page(Structure): #{ _fields_ = [("pstr_name",c_uint32), ("id_entrypoint",c_uint32), ("id_viewpoint",c_uint32)] #} - class ent_menuitem_anon_union(Union): #{ _fields_ = [("slider",ent_menuitem_slider), @@ -389,14 +405,15 @@ class ent_menuitem_anon_union(Union): ("checkmark",ent_menuitem_checkmark), ("page",ent_menuitem_page)] #} - class ent_menuitem(Structure): #{ _fields_ = [("type",c_uint32), ("groups",c_uint32), - ("id_links",c_uint32*4), + ("id_links",c_uint32*4), + ("factive",c_float), ("fvisible",c_float), #-- TODO: Refactor this into a simple mesh structure ("transform",mdl_transform), ("submesh_start",c_uint32),("submesh_count",c_uint32), + ("_u64",c_uint64), #-- end ("_anonymous_union", ent_menuitem_anon_union)] #} @@ -407,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' @@ -1149,7 +1174,7 @@ def sr_compile_fonts( collection ): def sr_compile_menus( collection ): #{ - print( "[SR] Compiling menus" ) + print( "[SR1] Compiling menus" ) groups = [] for obj in collection.all_objects:#{ @@ -1182,12 +1207,17 @@ def sr_compile_menus( collection ): item_checkmark = item._anonymous_union.checkmark item_checkmark.pstr_data = sr_compile_string( obj_data.string ) item_checkmark.id_check = sr_entity_id( obj_data.checkmark ) + delta = obj_data.checkmark.location - obj.location + item_checkmark.offset[0] = delta[0] + item_checkmark.offset[1] = delta[2] + item_checkmark.offset[2] = -delta[1] #} elif item.type == 4:#{ item_slider = item._anonymous_union.slider item_slider.id_min = sr_entity_id( obj_data.slider_minloc ) item_slider.id_max = sr_entity_id( obj_data.slider_maxloc ) item_slider.id_handle = sr_entity_id( obj_data.slider_handle ) + item_slider.pstr_data = sr_compile_string( obj_data.string ) #} elif item.type == 5:#{ item_page = item._anonymous_union.page @@ -1650,9 +1680,18 @@ def sr_compile( collection ): elif ent_type == 'ent_skateshop':#{ skateshop = ent_skateshop() obj_data = obj.SR_data.ent_skateshop[0] - skateshop.id_display = sr_entity_id( obj_data.mark_display ) - skateshop.id_info = sr_entity_id( obj_data.mark_info ) - skateshop.id_rack = sr_entity_id( obj_data.mark_rack ) + skateshop.type = int(obj_data.tipo) + if skateshop.type == 0:#{ + boardshop = skateshop._anonymous_union.boards + boardshop.id_display = sr_entity_id( obj_data.mark_display ) + boardshop.id_info = sr_entity_id( obj_data.mark_info ) + boardshop.id_rack = sr_entity_id( obj_data.mark_rack ) + #} + elif skateshop.type == 1:#{ + charshop = skateshop._anonymous_union.character + charshop.id_display = sr_entity_id( obj_data.mark_display ) + charshop.id_info = sr_entity_id( obj_data.mark_info ) + #} skateshop.id_camera = sr_entity_id( obj_data.cam ) compile_obj_transform( obj, skateshop.transform ) sr_ent_push(skateshop) @@ -1665,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 ) + #} #} #} @@ -2766,6 +2814,9 @@ class SR_OBJECT_ENT_TRAFFIC(bpy.types.PropertyGroup): class SR_OBJECT_ENT_SKATESHOP(bpy.types.PropertyGroup): #{ + tipo: bpy.props.EnumProperty( name='Type', + items=[('0','boards',''), + ('1','character','')] ) mark_rack: bpy.props.PointerProperty( \ type=bpy.types.Object, name="Board Rack", \ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_marker'])) @@ -2886,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) @@ -2901,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", @@ -3853,21 +3913,33 @@ def cv_draw(): #} #} elif ent_type == 'ent_skateshop':#{ - cc = (0.0,0.9,0.6) - cc1 = (0.4,0.9,0.2) - cc2 = (0.9,0.6,0.1) - data = obj.SR_data.ent_skateshop[0] display = data.mark_display info = data.mark_info - rack = data.mark_rack - rack_cu = Vector((3.15,2.0,0.1))*0.5 - rack_co = Vector((0.0,0.0,0.0)) - display_cu = Vector((0.3,1.2,0.1))*0.5 - display_co = Vector((0.0,0.0,0.1))*0.5 - info_cu = Vector((1.2,0.01,0.3))*0.5 - info_co = Vector((0.0,0.0,0.0))*0.5 + if data.tipo == '0':#{ + cc = (0.0,0.9,0.6) + cc1 = (0.4,0.9,0.2) + cc2 = (0.9,0.6,0.1) + + rack = data.mark_rack + + rack_cu = Vector((3.15,2.0,0.1))*0.5 + rack_co = Vector((0.0,0.0,0.0)) + display_cu = Vector((0.3,1.2,0.1))*0.5 + display_co = Vector((0.0,0.0,0.1))*0.5 + info_cu = Vector((1.2,0.01,0.3))*0.5 + info_co = Vector((0.0,0.0,0.0))*0.5 + #} + elif data.tipo == '1':#{ + rack = None + cc1 = (1.0,0.0,0.0) + cc2 = (1.0,0.5,0.0) + display_cu = Vector((0.4,0.4,2.0))*0.5 + display_co = Vector((0.0,0.0,1.0))*0.5 + info_cu = Vector((1.2,0.01,0.3))*0.5 + info_co = Vector((0.0,0.0,0.0))*0.5 + #} if rack: cv_draw_ucube( rack.matrix_world, cc, rack_cu, rack_co ) @@ -3994,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 \