some audio things
[carveJwlIkooP6JGAAIwe30JlM.git] / blender_export.py
index b60b2e02fc8cf14550c3f2ace276c11545c48bec..3e4704ea466fa1e6d8d97eb3a4f44b6bb0dee6f2 100644 (file)
@@ -782,6 +782,11 @@ class classtype_audio(Structure):
       if obj.cv_data.bp1: flags |= 0x4
       if obj.cv_data.bp2: flags |= 0x8
 
+      if obj.cv_data.audio_format == 'stereo':
+         flags |= 0x200
+      if obj.cv_data.audio_format == 'remain compressed':
+         flags |= 0x400
+
       _.flags = flags
       _.volume = obj.cv_data.fltp
    #}
@@ -789,11 +794,14 @@ class classtype_audio(Structure):
    @staticmethod
    def editor_interface( layout, obj ):
    #{
-      layout.prop( obj.cv_data, "strp" )
+      layout.prop( obj.cv_data, "strp", text = "File (.ogg)" )
 
       layout.prop( obj.cv_data, "bp0", text = "Looping" )
       layout.prop( obj.cv_data, "bp1", text = "3D Audio" )
       layout.prop( obj.cv_data, "bp2", text = "Auto Start" )
+      layout.prop( obj.cv_data, "audio_format" )
+
+      layout.prop( obj.cv_data, "fltp", text = "Volume (0-1)" )
    #}
 
    @staticmethod
@@ -814,7 +822,8 @@ class classtype_world_light( Structure ):
    _pack_ = 1
    _fields_ = [("type",c_uint32),
                ("colour",c_float*4),
-               ("angle",c_float)]
+               ("angle",c_float),
+               ("range",c_float)]
 
    def encode_obj(_, node, node_def):
    #{
@@ -826,6 +835,9 @@ class classtype_world_light( Structure ):
       _.colour[1] = data.color[1]
       _.colour[2] = data.color[2]
       _.colour[3] = data.energy
+      _.range = data.cutoff_distance # this has to be manually set
+                                     # TODO: At some point, automate a min
+                                     #       threshold value
 
       if obj.data.type == 'POINT':
       #{
@@ -835,8 +847,11 @@ class classtype_world_light( Structure ):
       elif obj.data.type == 'SPOT':
       #{
          _.type = 1
-         _.angle = math.cos(data.spot_size*0.5)
+         _.angle = data.spot_size*0.5
       #}
+
+      if data.cv_data.bp0:
+         _.type += 2
    #}
 
    @staticmethod
@@ -1259,6 +1274,7 @@ def encoder_process_material( mat ):
    if mat.cv_data.surface_prop == 'concrete': dest.surface_prop = 0
    if mat.cv_data.surface_prop == 'wood': dest.surface_prop = 1
    if mat.cv_data.surface_prop == 'grass': dest.surface_prop = 2
+   if mat.cv_data.surface_prop == 'tiles': dest.surface_prop = 3
 
    if mat.cv_data.shader == 'standard': dest.shader = 0
    if mat.cv_data.shader == 'standard_cutout': dest.shader = 1
@@ -1340,7 +1356,7 @@ def encoder_build_scene_graph( collection ):
 
    for obj in collection.all_objects:
    #{
-      if obj.parent: continue
+      #if obj.parent: continue
 
       def _extend( p, n, d ):
       #{
@@ -1915,7 +1931,7 @@ def encoder_process_definition( node_def ):
    #{
       obj      = node_def['obj']
       obj_type = obj.type
-      obj_co   = obj.location
+      obj_co   = obj.matrix_world @ Vector((0,0,0))
 
       if obj_type == 'ARMATURE':
          obj_classtype = 'classtype_skeleton'
@@ -2642,6 +2658,31 @@ class CV_MESH_SETTINGS(bpy.types.PropertyGroup):
    v3: bpy.props.FloatVectorProperty(name="v3",size=3)
 #}
 
+class CV_LIGHT_SETTINGS(bpy.types.PropertyGroup):
+#{
+   bp0: bpy.props.BoolProperty( name="bp0" );
+#}
+
+class CV_LIGHT_PANEL(bpy.types.Panel):
+#{
+   bl_label="[Skate Rift]"
+   bl_idname="SCENE_PT_cv_light"
+   bl_space_type='PROPERTIES'
+   bl_region_type='WINDOW'
+   bl_context='data'
+
+   def draw(_,context):
+   #{
+      active_object = context.active_object
+      if active_object == None: return
+
+      if active_object.type != 'LIGHT': return
+
+      data = active_object.data.cv_data
+      _.layout.prop( data, "bp0", text="Only on during night" )
+   #}
+#}
+
 class CV_OBJ_SETTINGS(bpy.types.PropertyGroup):
 #{
    uid: bpy.props.IntProperty( name="" )
@@ -2682,6 +2723,14 @@ class CV_OBJ_SETTINGS(bpy.types.PropertyGroup):
       ('classtype_spawn_link',"classtype_spawn_link","",150),
       ('classtype_nonlocal_gate', "classtype_nonlocal_gate", "", 300)
       ])
+
+   audio_format: bpy.props.EnumProperty(
+      name="Loaded format",
+      items = [
+         ('mono', "mono", "", 0),
+         ('stereo', "stereo", "", 1),
+         ('remain compressed', "remain compressed", "", 2)
+      ])
 #}
 
 class CV_BONE_SETTINGS(bpy.types.PropertyGroup):
@@ -2709,7 +2758,7 @@ class CV_BONE_SETTINGS(bpy.types.PropertyGroup):
 
 class CV_BONE_PANEL(bpy.types.Panel):
 #{
-   bl_label="Bone Config"
+   bl_label="[Skate Rift]"
    bl_idname="SCENE_PT_cv_bone"
    bl_space_type='PROPERTIES'
    bl_region_type='WINDOW'
@@ -2766,7 +2815,8 @@ class CV_MATERIAL_SETTINGS(bpy.types.PropertyGroup):
       items = [
       ('concrete','concrete','',0),
       ('wood','wood','',1),
-      ('grass','grass','',2)
+      ('grass','grass','',2),
+      ('tiles','tiles','',3)
       ])
    
    collision: bpy.props.BoolProperty( \
@@ -3002,7 +3052,8 @@ class CV_INTERFACE(bpy.types.Panel):
 classes = [CV_OBJ_SETTINGS,CV_OBJ_PANEL,CV_COMPILE,CV_INTERFACE,\
            CV_MESH_SETTINGS, CV_SCENE_SETTINGS, CV_BONE_SETTINGS,\
            CV_BONE_PANEL, CV_COLLECTION_SETTINGS, CV_COMPILE_THIS,\
-           CV_MATERIAL_SETTINGS, CV_MATERIAL_PANEL ]
+           CV_MATERIAL_SETTINGS, CV_MATERIAL_PANEL, CV_LIGHT_SETTINGS,\
+           CV_LIGHT_PANEL]
 
 def register():
 #{
@@ -3019,6 +3070,7 @@ def register():
          bpy.props.PointerProperty(type=CV_COLLECTION_SETTINGS)
    bpy.types.Material.cv_data = \
          bpy.props.PointerProperty(type=CV_MATERIAL_SETTINGS)
+   bpy.types.Light.cv_data = bpy.props.PointerProperty(type=CV_LIGHT_SETTINGS)
 
    cv_view_draw_handler = bpy.types.SpaceView3D.draw_handler_add(\
       cv_draw,(),'WINDOW','POST_VIEW')