skin wieights at a UV position

23 views
Skip to first unread message

Todd Widup

unread,
Jun 17, 2021, 5:25:14 PMJun 17
to python_in...@googlegroups.com
hey all, any good way of getting skin weights at a UV position (not a vtx) in python?  

--
Todd Widup
Creature TD / Technical Artist
todd....@gmail.com

vince touache

unread,
Jun 17, 2021, 5:26:48 PMJun 17
to Python Programming for Autodesk Maya
I believe maya is using barycentric coordinates, that would be an easy way of doing what you need (although the "UVs" part is not mandatory)

Todd Widup

unread,
Jun 17, 2021, 5:43:25 PMJun 17
to python_in...@googlegroups.com
lol what I meant is how can you query the weight if given the UV position?  

--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9364d2d3-6100-4aac-b7a7-d81d01a78fd9n%40googlegroups.com.

vince touache

unread,
Jun 17, 2021, 5:46:26 PMJun 17
to Python Programming for Autodesk Maya
you can get the polygon (as in "the face") at a given u and v, and from the polygon, you query the vertices. Once there, you can get the skinweights and barycentric. Or am I missing something?

Todd Widup

unread,
Jun 17, 2021, 6:00:11 PMJun 17
to python_in...@googlegroups.com
that would work :)
wasnt thinking about getting faces


Todd Widup

unread,
Jun 17, 2021, 8:13:56 PMJun 17
to python_in...@googlegroups.com
ok so on this....I have my UV coord, there is no function for converting that to a face and the examples im finding ONLY cover using a map ID not a random UV position, additionally, the code example actually doesnt even work


import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
 
list = OpenMaya.MSelectionList()
sphereName = "pSphereShape1"
planeName = "pPlaneShape1"
 
list.add(sphereName)
list.add(planeName)
 
sphereObj = OpenMaya.MObject()
planeObj = OpenMaya.MObject()
 
list.getDependNode(0, sphereObj)
list.getDependNode(1, planeObj)
 
sphereMesh = OpenMaya.MFnMesh(sphereObj) # errors out here with # RuntimeError: (kInvalidParameter): Object is incompatible with this method #
planeMesh = OpenMaya.MFnMesh(planeObj)
 

vince touache

unread,
Jun 18, 2021, 12:32:25 PMJun 18
to Python Programming for Autodesk Maya
1. don't override python keywords (e.g. "list")
2. are you stuck to api1 or is that ok to use api2?
3. Provide dag path instead of mobjects to your function sets if you can, that'll let you work with world space

Then, you could start with something like this (api2):
fnSphere = MFnMesh(MGlobal.getSelectionListByName('pSphereShape1').getDagPath(0))
u, v = 0.52, 0.52
polyIds, positions = fnSphere.getPointsAtUV(u, v, tolerance=0.00001)
it = MItMeshPolygon(fnSphere.object())
it.setIndex(polyIds[0])
it.getVertices()

I'm sure there are faster ways to do it, by working with triangles and not poly all the way long, but can't retreive the command off top of my head. But this should give you a good starting point already

Todd Widup

unread,
Jun 18, 2021, 12:39:19 PMJun 18
to python_in...@googlegroups.com
thanks vince, and that code was from the example I was building from...and I had changed it to not be list in mine, but was running into the same error

Reply all
Reply to author
Forward
0 new messages