From fbc944825676b78c8873f0e26bf1cc7fac049830 Mon Sep 17 00:00:00 2001 From: Viktor Kim Christiansen Date: Sat, 21 May 2022 20:53:13 +0200 Subject: [PATCH] Support UE 5+ Blender 3+ (#3) --- functions/sut_make_mesh.py | 10 +++++----- operator/sut_op.py | 8 +++++--- panel/sut_panel.py | 6 +++--- panel/sut_properties.py | 8 ++++---- readme.md | 26 ++++++++++---------------- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/functions/sut_make_mesh.py b/functions/sut_make_mesh.py index 862206a..baca92d 100644 --- a/functions/sut_make_mesh.py +++ b/functions/sut_make_mesh.py @@ -11,11 +11,11 @@ def make_single_mesh(selected_collection, context): # For scene / own global variables sut_tool = context.scene.sut_tool - # Go into object mode (maybe actually check stuff instead of this) - try: - bpy.ops.object.mode_set(mode="OBJECT") - except: - pass + # Avoid "Operator bpy.ops.object.mode_set.poll() Context missing active object" + context.view_layer.objects.active = selected_collection.all_objects[0] + + # Go into object mode + bpy.ops.object.mode_set(mode='OBJECT') # Deselect everything bpy.ops.object.select_all(action='DESELECT') diff --git a/operator/sut_op.py b/operator/sut_op.py index b6ba4d7..d100cb1 100644 --- a/operator/sut_op.py +++ b/operator/sut_op.py @@ -36,11 +36,13 @@ def execute(self, context): # Every collection gets merged into it's own unique mesh (or all collections is a single big mesh) greybox_collection = bpy.data.collections[sut_tool.greybox_col_name] - if sut_tool.every_col_is_own_mesh is True: + greybox_col_has_child_col = len(greybox_collection.children) > 0 # Avoid bug + we don't support deeply nested collections + if sut_tool.every_col_is_own_mesh is True and greybox_col_has_child_col is True: # Get final collection, loop over every child collection and run make_single_mesh for col in greybox_collection.children: - make_single_mesh(col, context) - else: + if len(col.all_objects) > 0: + make_single_mesh(col, context) + elif len(greybox_collection.all_objects) > 0: make_single_mesh(greybox_collection, context) # For every single object in the final collection, set the texel density diff --git a/panel/sut_panel.py b/panel/sut_panel.py index 8822111..336b54d 100644 --- a/panel/sut_panel.py +++ b/panel/sut_panel.py @@ -4,12 +4,12 @@ # Add to this list after adding a property to SutProperties UI_PROPERTIES = [ - "sut_island_margin", - "sut_angle_limit", + # "sut_island_margin", # Disabling to cleanup UI + # "sut_angle_limit", # Disabling to cleanup UI "sut_texture_size", "sut_texel_density", "greybox_col_name", - "final_col_name", + # "final_col_name", # Seems to be hardcoded now, so disabled this from the UI "auto_smooth_angle", "auto_smooth_enable", "every_col_is_own_mesh", diff --git a/panel/sut_properties.py b/panel/sut_properties.py index d2d154b..258aa99 100644 --- a/panel/sut_properties.py +++ b/panel/sut_properties.py @@ -18,7 +18,7 @@ class SutProperties(PropertyGroup): max=5, step=0.01, precision=3, - default=0.005 + default=0.02 ) sut_angle_limit: FloatProperty( @@ -61,7 +61,7 @@ class SutProperties(PropertyGroup): every_col_is_own_mesh: BoolProperty( name="Seperate Child Collection Meshes", description="Check if you want every collection to be their own seperate merged mesh\n(Origin will still be world origin)", - default = False + default = True ) sut_send_to_unreal: BoolProperty( @@ -78,8 +78,8 @@ class SutProperties(PropertyGroup): final_col_name: StringProperty( name="Final Coll. Name", - description="Final collection for unreal engine, default is 'Mesh' from the UE Tools addon", - default = "Mesh" + description="Final collection for unreal engine.", + default = "Export" # Seems to be hardcoded now, so disabled this from the UI ) auto_smooth_angle: StringProperty( diff --git a/readme.md b/readme.md index b238af9..68901db 100644 --- a/readme.md +++ b/readme.md @@ -15,24 +15,18 @@ Depends on the following addons: 2. [Send To Unreal Github](https://github.com/EpicGames/BlenderTools) (You need to follow this: https://www.unrealengine.com/en-US/blog/download-our-new-blender-addons) # Setup -1. Follow the "Send to Unreal" steps (which includes enabling remote execution in unreal & python scripting) - * I recommend going to options and setting "Mesh Folder(Unreal)" to: /Game/Meshes/Dev (or anything you want) - * Go to the export settings tab, and select "Use object origin" -2. Create Greybox colleciton defaulting to "Collection" (or change it). -3. Do the greyboxing / level designing you need to do. Everything gets merged into a single mesh (unless you check Split collection result). -4. Tick "Send to Unreal" and press SUT -5. In Unreal go top left -> Edit -> Project Settings -> Search for "Default Shape Complexity" and select "Use Complex Collision as Simple". - * When you are done greyboxing this should be turned back OFF -6. In Unreal drag the Meshes/Dev/SM_COLLECTION into your scene, and click the yellow little arrow in the transform panel, to reset it to 0,0,0 coordinates. -7. Put on some proper dev texture (cube material or w.e) - +1. Follow the "Send to Unreal" steps: + * In unreal: + - Pugins -> "Enable Python Editor Script Plugin" + - Project Settings -> "Enable Remote Execution" + - "Default Shape Complexity" and select "Use Complex Collision as Simple". + * In Blender (Pipeline -> Export -> Seting Dialog): + - Set "Mesh Folder(Unreal)" to: /Game/Meshes/Dev (or anything you want) + - Export -> FXB Export Settings -> Smoothing: Face +2. In Unreal drag the Meshes/Dev/SM_COLLECTION into your scene, and click the yellow little arrow in the transform panel, to reset it to 0,0,0 coordinates. +3. Put on some proper dev texture, you can use 1 color per grouped collection. Done now you can: Go into Blender -> Change something -> Press SUT -> Instant Changes in Unreal Engine - ![SUT](assets/addon.png) - -# Future Features -1. Landscape Synchronization (Rough) (Landscape in unreal -> synchronize to blender and greybox back and forth) -2. Instance Dupliactes in blender to world position in unreal (Make your scene in blender with a modular kit)