Discussion:
[Maya-Python] [UV] xGen exported mesh
Rémi Deletrain
2018-11-05 15:09:15 UTC
Permalink
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.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1da41c6b-d130-4a04-a726-482d50e7c95c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Boon
2018-11-06 00:40:15 UTC
Permalink
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
Post by Rémi Deletrain
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.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/31a6c369-1cc8-4343-9418-e751bdb7c34b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rémi Deletrain
2018-11-06 09:12:18 UTC
Permalink
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 !
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6cd1fdb7-d160-4aa8-8a2b-b88a5a673a79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...