the luxuries of a modern C compiler
[carveJwlIkooP6JGAAIwe30JlM.git] / blender_export.py
index cc51987624c7c05e1408d6747f0b5a91333b8db0..293b87cd89e81385131e586cd25a939446ff929f 100644 (file)
@@ -355,10 +355,16 @@ class ent_skateshop_boards(Structure):
                ("id_info",c_uint32),
                ("id_rack",c_uint32)]
 #}  
+class ent_skateshop_worlds(Structure):
+#{
+   _fields_ = [("id_display",c_uint32),
+               ("id_info",c_uint32)]
+#}
 class ent_skateshop_anon_union(Union):
 #{
    _fields_ = [("boards",ent_skateshop_boards),
-               ("character",ent_skateshop_characters)]
+               ("character",ent_skateshop_characters),
+               ("worlds",ent_skateshop_worlds)]
 #}
 class ent_skateshop(Structure):
 #{
@@ -697,6 +703,7 @@ def sr_compile_material( mat ):
          if mat.SR_data.skate_surface: flags |= 0x1
          if mat.SR_data.grow_grass: flags |= 0x4
          if mat.SR_data.grind_surface: flags |= 0x8
+         if mat.SR_data.preview_visibile: flags |= 0x40
       #}
       if mat.SR_data.shader == 'invisible': flags |= 0x10
       if mat.SR_data.shader == 'boundary': flags |= (0x10|0x20)
@@ -1694,6 +1701,11 @@ def sr_compile( collection ):
                charshop.id_display = sr_entity_id( obj_data.mark_display )
                charshop.id_info = sr_entity_id( obj_data.mark_info )
             #}
+            elif skateshop.type == 2:#{
+               worldshop = skateshop._anonymous_union.worlds
+               worldshop.id_display = sr_entity_id( obj_data.mark_display )
+               worldshop.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)
@@ -1910,6 +1922,7 @@ def sr_compile( collection ):
    path = F"{folder}{collection.name}.mdl"
    print( path )
 
+   os.makedirs(os.path.dirname(path),exist_ok=True)
    fp = open( path, "wb" )
    header = mdl_header()
    header.version = 101
@@ -2226,6 +2239,7 @@ class SR_MATERIAL_PANEL(bpy.types.Panel):
             row.prop( active_mat.SR_data, "skate_surface" )
             row.prop( active_mat.SR_data, "grind_surface" )
             row.prop( active_mat.SR_data, "grow_grass" )
+            row.prop( active_mat.SR_data, "preview_visibile" )
          #}
       #}
 
@@ -2818,7 +2832,8 @@ class SR_OBJECT_ENT_SKATESHOP(bpy.types.PropertyGroup):
 #{
    tipo: bpy.props.EnumProperty( name='Type',
                                  items=[('0','boards',''),
-                                        ('1','character','')] )
+                                        ('1','character',''),
+                                        ('2','world','')] )
    mark_rack: bpy.props.PointerProperty( \
            type=bpy.types.Object, name="Board Rack", \
            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_marker']))
@@ -3070,6 +3085,11 @@ class SR_MATERIAL_PROPERTIES(bpy.types.PropertyGroup):
          default=False,\
          description = "Spawn grass sprites on this surface?" \
    )
+   preview_visibile: bpy.props.BoolProperty( \
+         name="Preview visibile", \
+         default=True,\
+         description = "Show this material in preview models?" \
+   )
    blend_offset: bpy.props.FloatVectorProperty( \
          name="Blend Offset", \
          size=2, \
@@ -3942,6 +3962,15 @@ def cv_draw():
                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 == '2':#{
+               rack = None
+               cc1 = (1.0,0.0,0.0)
+               cc2 = (1.0,0.5,0.0)
+               display_cu = Vector((1.0,1.0,0.5))*0.5
+               display_co = Vector((0.0,0.0,0.5))*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 )