Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine mesh sockets #525

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions send2ue/core/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,36 @@ def export_file(properties, lod=0):
restore_rig_objects(context, properties)


def get_asset_sockets(asset_name, properties):
def get_asset_sockets(mesh_object_param, properties):
"""
Gets the socket under the given asset.

:param str asset_name: The name of the asset to export.
:param str mesh_object_param: The mesh_object to export.
:param object properties: The property group that contains variables that maintain the addon's correct state.
"""
socket_data = {}
mesh_object = bpy.data.objects.get(asset_name)
if mesh_object:
for child in mesh_object.children:
if child.type == 'EMPTY' and child.name.startswith(f'{PreFixToken.SOCKET.value}_'):
name = utilities.get_asset_name(child.name.replace(f'{PreFixToken.SOCKET.value}_', ''), properties)
socket_data[name] = {
'relative_location': utilities.convert_blender_to_unreal_location(child.matrix_local.translation),
'relative_rotation': [math.degrees(i) for i in child.matrix_local.to_euler()],
'relative_scale': child.matrix_local.to_scale()[:]
}
combined = False
mesh_name = mesh_object_param.name
if hasattr(bpy.context.scene.send2ue.extensions,"combine_meshes"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just got some time to look at this. So if I am understanding correctly, we want to recurse all children of the asset look for sockets, if it is to be combined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allo ! Sorry for the delay
Yes I remember I was working on something like that

Copy link

@Olninyo Olninyo Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just looking into this functionality again too, and even using default pipeline settings I'm getting the error:

  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\dependencies\rpc\factory.py", line 221, in run_function_remotely
    return remote_function(*args)
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\xmlrpc\client.py", line 1122, in __call__
    return self.__send(self.__name, args)
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\xmlrpc\client.py", line 1464, in __request
    response = self.__transport.request(
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\xmlrpc\client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\xmlrpc\client.py", line 1182, in single_request
    return self.parse_response(resp)
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\xmlrpc\client.py", line 1354, in parse_response
    return u.close()
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\dependencies\rpc\client.py", line 55, in close
    raise exception(exception_message)
RuntimeError: The D:/XXXXXXXXXX does not exist in the project!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\operators.py", line 71, in modal
    raise error
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\operators.py", line 61, in modal
    function(*args, **kwargs)
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\core\ingest.py", line 50, in create_static_mesh_sockets
    UnrealRemoteCalls.set_static_mesh_sockets(
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\dependencies\rpc\factory.py", line 248, in wrapper
    return rpc_factory.run_function_remotely(function, args)
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\dependencies\rpc\factory.py", line 226, in run_function_remotely
    raise exception.__class__(stack_trace).with_traceback(call_traceback)
  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\core\ingest.py", line 50, in create_static_mesh_sockets
    UnrealRemoteCalls.set_static_mesh_sockets(
RuntimeError: The D:/XXXXXXXXXX does not exist in the project!  File "C:\Users\ollys\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\send2ue\dependencies\unreal.py", line 1402```

which it appears may have been in issue in the past as well, but was resolved.

would love to have this socket functionality in some form, with combine meshes would be even better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was logged in my personal account I didn't see this ! I'm going to try and fix that are update this PR in the coming weeks hopefully

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weeks turned into months but I have abot of time now

if bpy.context.scene.send2ue.extensions.combine_meshes.combine_child_meshes:
combined = True
mesh_name = mesh_object_param.parent.name

def find_socket_in_chilren(o,iterate):
if o:
for child in o.children:
if child.type == 'EMPTY' and child.name.startswith(f'{PreFixToken.SOCKET.value}_'):
name = utilities.get_asset_name(child.name.replace(f'{PreFixToken.SOCKET.value}_', ''), properties)
socket_data[name] = {
'relative_location': utilities.convert_blender_to_unreal_location(child.matrix_local.translation),
'relative_rotation': [math.degrees(i) for i in child.matrix_local.to_euler()],
'relative_scale': child.matrix_local.to_scale()[:]
}
elif child.type == 'MESH' and iterate:
find_socket_in_chilren(child,iterate)

mesh_object = bpy.data.objects.get(mesh_name)
find_socket_in_chilren(mesh_object,combined)
return socket_data


Expand Down Expand Up @@ -598,7 +610,7 @@ def create_mesh_data(mesh_objects, rig_objects, properties):
'skeletal_mesh': bool(rig_objects),
'skeleton_asset_path': properties.unreal_skeleton_asset_path,
'lods': export_lods(asset_id, asset_name, properties),
'sockets': get_asset_sockets(mesh_object.name, properties),
'sockets': get_asset_sockets(mesh_object, properties),
'import_mesh': True
}
previous_asset_names.append(asset_name)
Expand Down
2 changes: 1 addition & 1 deletion send2ue/core/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def import_asset(asset_id, property_data):
asset_data = bpy.context.window_manager.send2ue.asset_data[asset_id]

# import the asset
UnrealRemoteCalls.import_asset(asset_data.get('file_path'), asset_data, property_data)
asset_data['asset_path'] = UnrealRemoteCalls.import_asset(asset_data.get('file_path'), asset_data, property_data)[0]

# import fcurves
if asset_data.get('fcurve_file_path'):
Expand Down