Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Maya to Unreal: Static and Skeletal Meshes #2978

Merged
merged 34 commits into from
Apr 5, 2022

Conversation

antirotor
Copy link
Member

@antirotor antirotor commented Mar 30, 2022

Feature

This adds support for publishing Skeletal meshes for Unreal. Just select geo and joint root and publish.

Setup

First make sure you have maya2unreal template set:
image

And set the IntegrateAssetNew to use it in Template name profiles:
project_settings/global/publish/IntegrateAssetNew/template_name_profiles

image

Have skeletalMesh and staticMesh in the families list of Hero integrator if you like:
project_settings/global/publish/IntegrateHeroVersion/families

image

Next make sure you have correct Subset name profiles set:
project_settings/global/tools/creator/subset_name_profiles

image

You can configure hits about joint group here:
project_settings/maya/create/CreateUnrealSkeletalMesh

image

Testing

Say you have asset like this:

image

If you select Gun and run Unreal Skeletal Mesh creator, it will create instance like this:

image

jnt_org is joints root that is auto-picked using hints pre-configured in creator settings (see above). Top node (Gun in this case) must be name of the asset.

Publishing this will create fbx following unreal naming conventions - SK_Gun_v001.fbx with correct hierarchy. This has support for variants - different kinds of model using the same rig. You can create another Skeletal Mesh instance, just add _Scope to the variant name and it will create skeletalMesh_SK_Gun_Scope adding additional (selected) geometry along the joint group. This allows for multiple fbx file with the same hierarchy to be published and then easily switched inside the Unreal (most useful with the Hero versions).

Fix

Fixing bugs in unreal static mesh extraction.

There were few bugs. One was that extraction didn't considered scenarios with only one mesh. There was also flawed logic behind cleaning of nodes that were created during extraction and also the family name was shortened just to staticMesh.

Testing

Run the following code to create test scene and publish. You might need to disable Unreal Axis validator.
Expected result should be fbx file with two meshes in root, one called S_{asset} and UCX_{asset}.

Code to create test scene:

import avalon.api
from maya import cmds
from openpype.lib import get_creator_by_name


asset = avalon.api.Session["AVALON_ASSET"]                                   
root = cmds.createNode("transform", name="mesh_GRP")
geo_root = cmds.createNode("transform", name="geometry_GRP")
coll_root = cmds.createNode("transform", name="collision_GRP")
box = cmds.polyCube(sx=5, sy=5, sz=5, h=5, w=5, d=5)
cmds.polyTriangulate(box, ch=True);
cmds.parent(box, geo_root)
dup = cmds.duplicate(box, name="UCX_{}_1".format(asset), ic=True)
cmds.parent(dup, coll_root)
cmds.parent(geo_root, root)
cmds.parent(coll_root, root)

cmds.select(root, r=1, noExpand=True)
creator = get_creator_by_name("CreateUnrealStaticMesh")
asset = avalon.api.Session["AVALON_ASSET"]
container = avalon.api.create(creator, 
                              name=asset, 
                              asset=asset,
                              options={"useSelection": True})

⏫ This PR supersede #2764

@ynbot
Copy link
Contributor

ynbot commented Mar 30, 2022

Task linked: OP-2795 Maya to Unreal - Skeletal Mesh

@antirotor antirotor self-assigned this Mar 31, 2022
@antirotor antirotor added host: UE host: Maya type: feature Larger, user affecting changes and completely new things labels Mar 31, 2022
@mkolar mkolar marked this pull request as ready for review April 1, 2022 12:24
@m-u-r-p-h-y
Copy link
Member

it is failing on static mesh name collision

b'Processing Unreal Static Mesh Name'
// Error: pyblish.ValidateUnrealStaticMeshName : Collision object name doesn't match static mesh name
// Error: pyblish.ValidateUnrealStaticMeshName : UCX_ball != UCX_ball[]*
// Error: pyblish.plugin : Traceback (most recent call last):
//   File "D:\REPO\OpenPype\.venv\lib\site-packages\pyblish\plugin.py", line 522, in __explicit_process
//     runner(*args)
//   File "D:\REPO\OpenPype\openpype\hosts\maya\plugins\publish\validate_unreal_staticmesh_naming.py", line 143, in process
// RuntimeError: Model naming is invalid. See log.
// Traceback (most recent call last):
//   File "D:\REPO\OpenPype\.venv\lib\site-packages\pyblish\plugin.py", line 522, in __explicit_process
//     runner(*args)
//   File "<string>", line 143, in process
// RuntimeError: Model naming is invalid. See log.
b'Processing Maya Units'

Copy link
Member

@m-u-r-p-h-y m-u-r-p-h-y left a comment

Choose a reason for hiding this comment

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

the previous error was caused by testing on old code in the wrong branch.

my bad

now it publishes the fbx with no error.

thx

it works as expected

@antirotor antirotor merged commit 1d3a2c2 into develop Apr 5, 2022
@antirotor antirotor deleted the feature/OP-2795_maya-to-unreal-skeletal-meshes branch April 5, 2022 14:24
@mkolar mkolar changed the title Maya to Unreal > Static and Skeletal Meshes Maya to Unreal: Static and Skeletal Meshes Apr 7, 2022
@mkolar mkolar added this to the 3.9.3 milestone Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Maya host: UE type: feature Larger, user affecting changes and completely new things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants