collision models
authorhgn <hgodden00@gmail.com>
Thu, 14 Apr 2022 23:55:25 +0000 (00:55 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 14 Apr 2022 23:55:25 +0000 (00:55 +0100)
__init__.py

index 246fe95cd7463b608575d12e2b0abf76a5c47263..b926763e356bd89ccd114311f854a9ecad3791ae 100644 (file)
@@ -1233,8 +1233,13 @@ def cxr_export_modelsrc( mdl, origin, asset_dir, project_name, transform ):
 
    # Collect materials to be compiled, and temp rename for export
    mat_dict = {}
-
+   
+   vphys = None
    for obj in mdl.objects:
+      if obj.name == F"{mdl.name}_phy":
+         vphys = obj
+         continue
+
       obj.select_set(state=True)
       for ms in obj.material_slots:
          if ms.material != None:
@@ -1251,6 +1256,18 @@ def cxr_export_modelsrc( mdl, origin, asset_dir, project_name, transform ):
       bake_space_transform=False
    )
    
+   bpy.ops.object.select_all(action='DESELECT')
+   
+   if vphys != None:
+      vphys.select_set(state=True)
+      bpy.ops.export_scene.fbx( filepath=F'{asset_dir}/{uid}_phy.fbx',\
+         check_existing=False,
+         use_selection=True,
+         apply_unit_scale=False,
+         bake_space_transform=False
+      )
+      bpy.ops.object.select_all(action='DESELECT')
+
    # Fix material names back to original
    for mat in mat_dict:
       mat.name = mat_dict[mat]
@@ -1266,8 +1283,13 @@ def cxr_export_modelsrc( mdl, origin, asset_dir, project_name, transform ):
       o.write(F'$body _ "{uid}_ref.fbx"\n')
       o.write(F'$staticprop\n')
       o.write(F'$origin {origin[0]} {origin[1]} {origin[2]}\n')
+      
+      if vphys != None:
+         o.write(F'$collisionmodel "{uid}_phy.fbx"\n')
+         o.write("{\n")
+         o.write(" $concave\n")
+         o.write("}\n")
 
-      #TODO: vphys
       o.write(F'$cdmaterials {project_name}\n')
       o.write(F'$sequence idle {uid}_ref.fbx\n')