On Wednesday, December 14, 2016 at 12:57:36 PM UTC-8, [email protected]
wrote:
> hello,
>
> i got this concept working fine with python cmds. I am trying to see if i can
> get it working with api. So far with the thanks to Justin Israel, i got my
> code to this stage:
>
> http://pastebin.ubuntu.com/23630582/
>
> basically imagine there are 3 meshes:
>
> 1) a female neutral mesh named "target"
> 2) a male neutral mesh named "neutral"
> 3) the same male mesh but in a muscle man pose named "expression"
>
> all meshes have identical topology
>
> all i want to achieve is to first find the relative difference between the
> male neutral mesh verts and the male muscle man mesh verts. And then to apply
> this difference on top of the female neutral mesh.
>
> I got this working fine with cmds. So the i would find the difference values
> for each vert and store in a list. I would then apply this difference on top
> of each corresponding female mesh vert with the move commmand. It produced
> the same pose but a female version.
>
> However in my api code i am using the setPoints() method which i think is
> taking the difference but making the transforms absolute. So the female
> neutral mesh becomes identical to the male muscle man mesh, rather than it
> generating a female version of the muscle man pose.
>
> can anyone show me where im going wrong here. I know it can be done with a
> small tweak im sure.
>
> sorry for long post,
> Sam
I think this is more of what you want:
def getPoints(geo):
sel = om.MSelectionList()
dagNode = om.MDagPath()
sel.add(geo)
sel.getDagPath(0,dagNode)
dagNode.extendToShape()
fnMesh = om.MFnMesh(dagNode.node())
vts=om.MPointArray()
fnMesh.getPoints(vts, om.MSpace.kObject)
return dagNode, vts
def findDiff(vtsA, vtsB):
numVerts = vtsB.length()
diff = om.MVectorArray(numVerts)
for i in xrange(numVerts):
diff[i] = vtsB[i] - vtsA[i]
return diff
def setPoints(dagNode, deltas):
dagNode.extendToShape()
fnMesh = om.MFnMesh(dagNode.node())
pts = om.MPointArray()
fnMesh.getPoints(pts, om.MSpace.kObject)
for i in xrange(pts.length()):
pts[i] += deltas[i]
fnMesh.setPoints(pts, om.MSpace.kObject)
but it's not going to give you a great result, since those deltas are being
applied as world space, and not surface relative.
however, you could very easily just use the muscular male as a blendshape
target for the neutral male. delete the connection. Then just plug the outMesh
of the female neutral into the inMesh of the male neutral. delete the
connection. Then turn on the blendshape to 1. You will have the muscular
female shape you're looking for.
goodluck!
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/05fe5bec-5884-4785-9f96-f9b46751c31a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.