kattkieru
10-03-2008, 02:42 PM
Hi all,
I'm working on a proper blenshape mirroring tool (none of the ones I've found online work 100% of the time, and most either fail or crash Maya). At first I tried all in MEL. I did the following:
1) Get all point positions on base mesh.
2) Generate a match list by checking within tolerance for verts on the opposite side of the X axis. IE, I flip the sign on the X axis value and search through all the verts for a match. If a match is found I store the match like so:
vertMatchList[i] = j;
vertMatchList[j] = i;
so that I don't have to double up on those calculations. Center verts within a tolerance are skipped.
3) Get the blendshape vert positions.
4) Move each blendshape vert position to the position of it's oppositely-numbered vert based on the vertMatchList created from the mostly-symmetrical base shape.
Doing this in MEL made Maya crash, a lot, so I switched to Python and used MFnMesh and MPointArrays. Everything is working now except for one thing: setPoint/setPoints!
I've tried it two ways:
# smarter way
# m == maya.OpenMaya
mPointArray = m.MPointArray()
for i in range(0, bPointArray.length()):
mPointArray.append(bPointArray[vertMatchList[i]])
stat = blendFn.setPoints(mPointArray, m.MSpace.kObject)
if (stat != m.MStatus.kSuccess):
print "EPIC FAIL! (You lose.)"
# less-smart way
for i in range(0, bPointArray.length()):
if not vertMatchList[i] == i:
stat = blendFn.setPoint(i, bPointArray[vertMatchList[i]], m.MSpace.kObject)
if not stat == m.MStatus.kSuccess:
print "%i) Quasi-epic fail." % i
Neither function EVER returns a success, and the meshes remain as they are. The point arrays were grabbed in object space. bPointArray is the points from the original blendshape mesh. None of the shapes are connected and there's no history. Any hints as to where I'm going wrong? Thanks in advance.
I'm working on a proper blenshape mirroring tool (none of the ones I've found online work 100% of the time, and most either fail or crash Maya). At first I tried all in MEL. I did the following:
1) Get all point positions on base mesh.
2) Generate a match list by checking within tolerance for verts on the opposite side of the X axis. IE, I flip the sign on the X axis value and search through all the verts for a match. If a match is found I store the match like so:
vertMatchList[i] = j;
vertMatchList[j] = i;
so that I don't have to double up on those calculations. Center verts within a tolerance are skipped.
3) Get the blendshape vert positions.
4) Move each blendshape vert position to the position of it's oppositely-numbered vert based on the vertMatchList created from the mostly-symmetrical base shape.
Doing this in MEL made Maya crash, a lot, so I switched to Python and used MFnMesh and MPointArrays. Everything is working now except for one thing: setPoint/setPoints!
I've tried it two ways:
# smarter way
# m == maya.OpenMaya
mPointArray = m.MPointArray()
for i in range(0, bPointArray.length()):
mPointArray.append(bPointArray[vertMatchList[i]])
stat = blendFn.setPoints(mPointArray, m.MSpace.kObject)
if (stat != m.MStatus.kSuccess):
print "EPIC FAIL! (You lose.)"
# less-smart way
for i in range(0, bPointArray.length()):
if not vertMatchList[i] == i:
stat = blendFn.setPoint(i, bPointArray[vertMatchList[i]], m.MSpace.kObject)
if not stat == m.MStatus.kSuccess:
print "%i) Quasi-epic fail." % i
Neither function EVER returns a success, and the meshes remain as they are. The point arrays were grabbed in object space. bPointArray is the points from the original blendshape mesh. None of the shapes are connected and there's no history. Any hints as to where I'm going wrong? Thanks in advance.
