[UV] xGen exported mesh

25 views
Skip to first unread message

Rémi Deletrain

unread,
Nov 5, 2018, 10:09:15 AM11/5/18
to Python Programming for Autodesk Maya
Hello everyone,

I'm having fun with xGen and his exporter for UnrealEngine.
I am trying to create the uv mesh it generates. So I made a script that detects each mesh and calculates the position in the UV space.
Only I have a strange behavior in the UV editor. The indexes are good but the polygons are not correct after the first mesh.

Do you know why?

I enclose my script and scene test in this message.


xGen_test.ma
xGen_test.py

Michael Boon

unread,
Nov 5, 2018, 7:40:16 PM11/5/18
to Python Programming for Autodesk Maya
When you say "the first mesh", I think you mean the first shell? Your script only runs on one mesh, but appears to be trying to deal with the mesh one shell at a time.

Have you confirmed you script is correctly finding the shells? I can't tell, by reading it. If the polygons are correct for the first shell, but not correct after that, then I expect the problem is in the script that separates the face indices into shells.

Here is a different version. I think it should do the same thing yours is intended to do. It's written using API 2.0 so might require a few changes.
def mesh_to_shells(dp_node):
   
""" Returns a list of lists of face IDs. """
    mfn_mesh
= OpenMaya.MFnMesh(dp_node)
    mit_poly
= om.MItMeshPolygon(dp_node)
    shells
= []
    already_sorted
= set()
   
for id in range(mfn_mesh.numPolygons()):
       
if id in already_sorted:
           
continue
        this_shell
= [id]
       
# Starting with a single face, we keep adding connected face IDs to
       
# the end of the list, until we can't find any new ones.
        id_within_shell
= 0
       
while id_within_shell < len(this_shell):
            mit_poly
.setIndex(this_shell[id_within_shell])
            id_within_shell
+= 1
            connected_IDs
= set(mit_poly.getConnectedFaces())
            connected_IDs
-= set(this_shell)
            this_shell
.extend(connected_IDs)
        shells
.append(this_shell)
        already_sorted
|= set(this_shell)
   
return shells


Rémi Deletrain

unread,
Nov 6, 2018, 4:12:19 AM11/6/18
to Python Programming for Autodesk Maya
Thank you for your answer Michael,

Yes saying mesh I meant shell. xGen generates a lot of mesh that it combines.
I am sure to find the right index. The "mesh_check" function allows you to select all the indexes of a given shell index. The "Flatten hair" part makes it possible to overwrite each shell on the first two indexes (All pair index together and odd one too). once launching and that I select a vertex I have that the pairs or the impaires.

Your solution is more robust. My solutuion is only for this case and it's dangerous. Thank you !
Reply all
Reply to author
Forward
0 new messages