Skip to content

Commit

Permalink
Merge branch 'Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier150 committed Mar 12, 2021
2 parents 8b25a9e + fe8fcbf commit e456576
Show file tree
Hide file tree
Showing 14 changed files with 261 additions and 145 deletions.
17 changes: 9 additions & 8 deletions Release log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,21 @@ It is now possible to force the duration of an animation according to the scene

== Rev 0.2.8 ==

- New: Change: Better UI and Optimized
- New: Change: Better UI and Optimized.
- New: Auto-Rig Pro support (Needed for convert armature durring the export)
- New: You can now choose the preview collision color.
- New: You can set a light map res depending on the surface Area
- New: New button for update light map res depending on the surface Area
- New: You can now use ../ for up one directory in folder names
- New: You can now set Socket name in object property if needed
- New: You can set a light map res depending on the surface Area.
- New: New button for update light map res depending on the surface Area.
- New: You can now use ../ for up one directory in folder names.
- New: You can now set Socket name in object property if needed.
- New: You can now set skeleton name to use for import script (Proxy use)
- New: You can now set directly the desired export name for each objects.
- New: More option for action names.
- New: Camera Sensor Width and Height are now added in additional tracks.
- New: Cached animation to export in UI for better optimisation
- New: Skeleton search mode for import animation with specific skeleton
- New: Option for export only selected object and active action
- New: Cached animation to export in UI for better optimisation.
- New: Skeleton search mode for import animation with specific skeleton.
- New: Option for export only selected object and active action.
- New: Option for export collections with Subfolder.
- Change: New potential error: Check if the unit scale is equal to 0.01 (You can disable this potential error in addon_prefs)
- Change: Better check and potential errors info for Armature.
- Change: Some potential errors can have button to the documentation.
Expand Down
4 changes: 1 addition & 3 deletions blender-for-unrealengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@
'blender': (2, 80, 0),
'location': 'View3D > UI > Unreal Engine 4',
'warning': '',
"wiki_url": "https://github.com/xavier150/" \
"Blender-For-UnrealEngine-Addons" \
"/blob/master/docs/How%20export%20assets%20from%20Blender.md",
"wiki_url": "https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki",
'tracker_url': 'https://github.com/xavier150/Blender-For-UnrealEngine-Addons/issues',
'support': 'COMMUNITY',
'category': 'Import-Export'}
Expand Down
9 changes: 4 additions & 5 deletions blender-for-unrealengine/bfu_addon_pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ class BFU_OT_OpenDocumentationTargetPage(Operator):
def execute(self, context):
os.system(
"start \"\" " +
"https://github.com/xavier150/" +
"Blender-For-UnrealEngine-Addons/blob/master/docs/" +
"How%20export%20assets%20from%20Blender.md"+self.octicon
"https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/How-export-assets" +
"#"+self.octicon
)
return {'FINISHED'}

Expand Down Expand Up @@ -270,7 +269,7 @@ def PropWithDocButton(tagetlayout, name, docOcticon):
LabelWithDocButton(
rootBone,
"SKELETON & ROOT BONE",
"#skeleton--root-bone"
"skeleton--root-bone"
)
rootBone.prop(self, "removeSkeletonRootBone")
rootBoneName = rootBone.column()
Expand All @@ -296,7 +295,7 @@ def PropWithDocButton(tagetlayout, name, docOcticon):
data = boxColumn.box()
data.label(text='DATA')
data.prop(self, "ignoreNLAForAction")
PropWithDocButton(data, "correctExtremUVScale", "#uv")
PropWithDocButton(data, "correctExtremUVScale", "uv")
data.prop(self, "bakeArmatureAction")
data.prop(self, "exportWithCustomProps")
data.prop(self, "exportWithMetaData")
Expand Down
2 changes: 2 additions & 0 deletions blender-for-unrealengine/bfu_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def VerifiDirs(directory):

if not os.path.exists(directory):
os.makedirs(directory)
return True
return False


def ValidFilename(filename):
Expand Down
30 changes: 20 additions & 10 deletions blender-for-unrealengine/bfu_export_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@ def UpdateProgress(time=None):
if scene.static_collection_export:
for col in GetCollectionToExport(scene):
if col in targetcollection:
# StaticMesh collection
ExportSingleStaticMeshCollection(
scene,
GetCollectionExportDir(),
GetCollectionExportFileName(col),
col
)
# Save current start/end frame
UserStartFrame = scene.frame_start
UserEndFrame = scene.frame_end

ProcessCollectionExport(col)

# Resets previous start/end frame
scene.frame_start = UserStartFrame
scene.frame_end = UserEndFrame
UpdateProgress()

# Export assets
Expand Down Expand Up @@ -296,21 +298,29 @@ def ExportForUnrealEngine():
RemoveFolderTree(bpy.path.abspath(scene.export_camera_file_path))
RemoveFolderTree(bpy.path.abspath(scene.export_other_file_path))

obj_list = [] # Do a simple list of objects to export
action_list = [] # Do a simple list of objects to export
obj_list = [] # Do a simple list of Objects to export
action_list = [] # Do a simple list of Action to export
col_list = [] # Do a simple list of Collection to export
AssetToExport = GetFinalAssetToExport()
for Asset in AssetToExport:
if Asset.type == "Action" or Asset.type == "Pose":
if Asset.obj not in action_list:
action_list.append(Asset.action.name)
if Asset.obj not in obj_list:
obj_list.append(Asset.obj)

elif Asset.type == "Collection StaticMesh":
if Asset.obj not in col_list:
col_list.append(Asset.obj)

else:
if Asset.obj not in obj_list:
obj_list.append(Asset.obj)

ExportAllAssetByList(
targetobjects=obj_list,
targetActionName=action_list,
targetcollection=MyCurrentDataSave.collection_names,
targetcollection=col_list,
)

MyCurrentDataSave.ResetSelectByName()
Expand Down
3 changes: 1 addition & 2 deletions blender-for-unrealengine/bfu_export_single_static_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def ProcessStaticMeshExport(obj):
MyAsset = scene.UnrealExportedAssetsList.add()
MyAsset.StartAssetExport(obj)

ExportSingleStaticMesh(scene, dirpath, GetObjExportFileName(obj), obj)
ExportSingleStaticMesh(dirpath, GetObjExportFileName(obj), obj)
file = MyAsset.files.add()
file.name = GetObjExportFileName(obj)
file.path = dirpath
Expand All @@ -72,7 +72,6 @@ def ProcessStaticMeshExport(obj):


def ExportSingleStaticMesh(
originalScene,
dirpath,
filename,
obj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,39 @@
from . import bfu_check_potential_error


def ProcessCollectionExport(col):

addon_prefs = bpy.context.preferences.addons[__package__].preferences
dirpath = GetCollectionExportDir(bpy.data.collections[col])
absdirpath = bpy.path.abspath(dirpath)
scene = bpy.context.scene

MyAsset = scene.UnrealExportedAssetsList.add()
MyAsset.StartAssetExport(collection=col)

obj = ExportSingleStaticMeshCollection(dirpath, GetCollectionExportFileName(col), col)

MyAsset.SetObjData(obj)

file = MyAsset.files.add()
file.name = GetCollectionExportFileName(col)
file.path = dirpath
file.type = "FBX"

if (scene.text_AdditionalData and addon_prefs.useGeneratedScripts):

ExportSingleAdditionalParameterMesh(absdirpath, GetCollectionExportFileName(col, "_AdditionalTrack.json"), obj)
file = MyAsset.files.add()
file.name = GetCollectionExportFileName(col, "_AdditionalTrack.json")
file.path = dirpath
file.type = "AdditionalTrack"

CleanSingleStaticMeshCollection(obj)
MyAsset.EndAssetExport(True)
return MyAsset


def ExportSingleStaticMeshCollection(
originalScene,
dirpath,
filename,
collectionName
Expand All @@ -60,13 +91,19 @@ def ExportSingleStaticMeshCollection(
#COLLECTION
#####################################################
'''
collection = bpy.data.collections[collectionName]

# create collection and export it
obj = bpy.data.objects.new("EmptyCollectionForUnrealExport_Temp", None)
bpy.context.scene.collection.objects.link(obj)
obj.instance_type = 'COLLECTION'
obj.instance_collection = bpy.data.collections[collectionName]
ExportSingleStaticMesh(originalScene, dirpath, filename, obj)
obj.instance_collection = collection
ExportSingleStaticMesh(dirpath, filename, obj)
obj.exportFolderName = collection.exportFolderName
return obj


def CleanSingleStaticMeshCollection(obj):
# Remove the created collection
SelectSpecificObject(obj)
CleanDeleteObjects(bpy.context.selected_objects)
59 changes: 42 additions & 17 deletions blender-for-unrealengine/bfu_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ class BFU_PT_BlenderForUnrealObject(bpy.types.Panel):
subtype='FILE_NAME'
)

bpy.types.Collection.exportFolderName = StringProperty(
name="Sub folder name",
description=(
'The name of sub folder.' +
' You can now use ../ for up one directory.'
),

maxlen=64,
default="",
subtype='FILE_NAME'
)

bpy.types.Object.bfu_export_fbx_camera = BoolProperty(
name="Export camera fbx",
description=(
Expand Down Expand Up @@ -294,7 +306,7 @@ class BFU_PT_BlenderForUnrealObject(bpy.types.Panel):
name="",
description=(
"The full reference of the skeleton in Unreal. " +
"Skeleton not the skeletal mesh. (Use right clic on asset and copy reference.)"
"(Use right clic on asset and copy reference.)"
),
default="SkeletalMesh'/Game/ImportedFbx/SK_MySketonName_Skeleton.SK_MySketonName_Skeleton'"
)
Expand Down Expand Up @@ -762,15 +774,13 @@ class BFU_PT_BlenderForUnrealObject(bpy.types.Panel):

class BFU_OT_OpenDocumentationPage(Operator):
bl_label = "Documentation"
bl_idname = "object.open_documentation_page"
bl_idname = "object.bfu_open_documentation_page"
bl_description = "Clic for open documentation page on GitHub"

def execute(self, context):
os.system(
"start \"\" " +
"https://github.com/xavier150/" +
"Blender-For-UnrealEngine-Addons/blob/master/" +
"docs/How%20export%20assets%20from%20Blender.md"
"https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki"
)
return {'FINISHED'}

Expand Down Expand Up @@ -955,12 +965,14 @@ class BFU_OT_AddObjectGlobalPropertiesPreset(AddPresetBase, Operator):
# Common variable used for all preset values
preset_defines = [
'obj = bpy.context.object',
'col = bpy.context.collection',
'scene = bpy.context.scene'
]

# Properties to store in the preset
preset_values = [
'obj.exportFolderName',
'col.exportFolderName',
'obj.bfu_export_fbx_camera',
'obj.ExportAsAlembic',
'obj.ExportAsLod',
Expand Down Expand Up @@ -1018,6 +1030,7 @@ class BFU_OT_AddObjectGlobalPropertiesPreset(AddPresetBase, Operator):
preset_subdir = 'blender-for-unrealengine/global-properties-presets'

class BFU_UL_CollectionExportTarget(bpy.types.UIList):

def draw_item(
self,
context,
Expand All @@ -1041,7 +1054,7 @@ def draw_item(
"name",
text="",
emboss=False,
icon="GROUP")
icon="OUTLINER_COLLECTION")
layout.prop(item, "use", text="")
else:
dataText = (
Expand Down Expand Up @@ -1122,7 +1135,7 @@ def draw(self, contex):

credit_box = layout.box()
credit_box.label(text=ti('intro')+' Version: '+str(version))
credit_box.operator("object.open_documentation_page", icon="HELP")
credit_box.operator("object.bfu_open_documentation_page", icon="HELP")

row = layout.row(align=True)
row.menu(
Expand Down Expand Up @@ -1487,11 +1500,16 @@ def draw(self, contex):
"object.updatecollectionlist",
icon='RECOVER_LAST')

col_name = scene.CollectionExportList[scene.active_CollectionExportList].name
col = bpy.data.collections[col_name]
col_prop = layout
col_prop.prop(col, 'exportFolderName', icon='FILE_FOLDER')

collectionPropertyInfo = layout.row().box().split(factor=0.75)
collectionNum = len(GetCollectionToExport(scene))
collectionFeedback = (
str(collectionNum) +
" Collection(s) will be exported with this armature.")
" Collection(s) will be exported.")
collectionPropertyInfo.label(text=collectionFeedback, icon='INFO')
collectionPropertyInfo.operator("object.showscenecollection")
layout.label(text='Note: The collection are exported like StaticMesh.')
Expand Down Expand Up @@ -1789,19 +1807,29 @@ class BFU_OT_UnrealExportedAsset(bpy.types.PropertyGroup):

asset_name: StringProperty(default="None")
asset_type: StringProperty(default="None") # return from GetAssetType()
folder_name: StringProperty(default="None")
files: CollectionProperty(type=BFU_OT_FileExport)
object: PointerProperty(type=bpy.types.Object)
export_start_time: FloatProperty(default=0)
export_end_time: FloatProperty(default=0)
export_success: BoolProperty(default=False)

def StartAssetExport(self, obj, action=None):
def SetObjData(self, obj):
self.object = obj
self.asset_name = obj.name
if action:
self.asset_type = GetActionType(action)
else:
self.folder_name = obj.exportFolderName

def StartAssetExport(self, obj=None, action=None, collection=None):
if obj:
self.SetObjData(obj)

if obj:
self.asset_type = GetAssetType(obj)
if action:
self.asset_type = GetActionType(action) # Override
if collection:
self.asset_type = GetCollectionType(collection) # Override

self.export_start_time = time.perf_counter()

def EndAssetExport(self, success):
Expand Down Expand Up @@ -2096,11 +2124,8 @@ class BFU_OT_OpenPotentialErrorDocs(Operator):
def execute(self, context):
os.system(
"start \"\" " +
"https://github.com/xavier150/" +
"Blender-For-UnrealEngine-Addons/" +
"blob/master/docs/" +
"Potential%20Error%20with%20Blender%20export%20" +
"to%20Unreal.md#"+self.octicon)
"https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki/How-avoid-potential-errors" +
"#"+self.octicon)
return {'FINISHED'}

def execute(self, context):
Expand Down
Loading

0 comments on commit e456576

Please sign in to comment.