import pymel.core as pm
ignore_below = 0.0001
meshes = pm.selected()
if len(meshes) > 0:
for mesh in meshes:
#use a quickie MEL command to get the skincluster
skin = pm.mel.eval('findRelatedSkinCluster %s' % mesh)
#get the max allowed influenced for the current skinCluster
max_influences = pm.PyNode(skin).getMaximumInfluences()
#empty list to hold a pair for transform value
transform_value = 
#get the total number of vertices in the selected mesh
total_verts = pm.polyEvaluate(vertex=True)
for i in xrange(0, total_verts):
transform_value = 
vertex = "%s.vtx[%s]" % (mesh, i)
trans = "%s %s" % (skin, vertex)
influences = pm.skinPercent(skin, vertex, ignoreBelow = ignore_below, query = True, transform = None)
values = pm.skinPercent(skin, vertex, ignoreBelow = ignore_below, query = True, value = True)
# if there are more entries in the transform values list than we have allowed influences
# we know we're going to have to delete some
if len(transform_value) > max_influences:
#sort the transform value list from small to big, based on the second entry of the pair (value)
transform_value.sort(key = lambda list: list)
#add a transform value pair to our list
for j in xrange(0, len(influences)):
tv = [influences[j], values[j]]
#figure out how many extra influences there are
extra_influences = len(transform_value) - max_influences
print "Found %s influences too many on %s" % (extra_influences, vertex)
#loop through all these extra influences
for k in xrange(0, extra_influences):
joint_name = str(transform_value[k])
value = transform_value[k]
#and set their influence to 0
print "Removing: %s, value: %s" % (joint_name, value)
pm.skinPercent(skin, vertex, transformValue = [joint_name, 0], normalize = True)
I adapted a script that was written in MEL to remove extra influences on particular vertices on a skinned mesh. Mostly because it didn’t always work on my machine and I didn’t want to try and figure out why… I don’t like having to edit MEL code and avoid it where I can 🙂
When you set up your skinCluster and very carefully tell Maya to not go over your maximum allowed influences per vert, Maya doesn’t always listen. Most likely floating point rounding errors creep in when painting skin weights and normalizing the skinCluster. Most times you don’t know really care about these extra influences because their values are usually extremely small ( < 0.001). However, if for whatever reason you need to get rid of these extremely small values and don't want to prune weights, you can use something like this to remove only the smallest influences depending on how many influences are allowed for your skinCluster.
The game that I’ve been part of for the last 18 months has finally officially launched world wide in the Google Play Store and on the Apple App Store. I’m incredibly proud of all the work that has gone into making this game a reality. I think we really pushed the limit of what real time strategy and world building games look and play like on mobile devices. Building on the amazing work people did before I joined the studio, we took the animation and technology to a new level.
Be sure to download it on your mobile device and have fun with it!
Quickie update on the course. Just finishing up week 3 now where we put in a very simple rig. Just a couple of joints for the eyes, nose jaw and ears. Learned an interesting fact about the difference between a parent constraint and both a orient + point constraint. Apparently it’s harder for Maya to calculate parent constraints than individual orient and point constraints according to Wade. Doing a parent constraint means Maya will always calculate both translate and rotate values, even if you just use one. That’s not the case with individual constraints obviously.
I don’t think I ever ran into an issue with my rig slowing down because of parent constraints, but it’s always better to be save than sorry.
Rigging class update: got some pointers on the topology. It was definitely good enough to work with, but it was pointed out that she could do with a couple more edges around the brow area. She also had a bit of a smile, which isn’t ideal when you’re going for a neutral pose. So I added some loops, moved the vertical edges around a bit as well in the brow area so everything is more evenly spaced. I reshaped her eyebrows to follow the curves of the face better and I gave them same amount of subdivisions in the same places as on the face.
Other than they I remodeled her eyelashes to make them less prominent and added smaller ones on the lower eye lid as well. Got rid of the cornrow hair and put something in temporarily for the time being. I totally suck at modeling or sculpting hair by the way 🙂 I also gave her some glasses because I figured it would be a fun accessory for her to play around with.
I still need a name for her. My wife thinks she looks like a Kate or Katherine. Does she?
Moving onto week 2 of the Facial Rigging class: topology. Fortunately for me, I’ve always had pretty good models handed to me for rigging and the topology was most times more than good enough for the task at hand. Or, the model was so low poly there wasn’t really any “topology” to speak of.
The very low poly model of our girl here also had a bunch of spirals and none of the actual loops you would need for rigging or animating. So I took the cutting tools to her and cut in some loops that will be needed later on. I wish I had access to Topogun. Maya’s quad draw tool works just fine, but from the videos it seemed that Topogun just looked easier to work with. You get a lot of geometry clipping through your guide mesh in Maya which makes life a shit ton harder than it really should be. The overall functionality is fine, but getting everything to line up can be a pain in the ass. So I actually continued to switch between my entire scene and isolate select of the mesh I was working on. The cool thing is that your geometry will still respect the Live Mesh you set up, even though it’s not visible in the viewport. Just move the verts around and you can trust that they’re on the guide mesh, pretty nice.
Anyhoo, here’s our little missy at this point in time. I’m waiting for feedback from Wade and the rest of the class and then I’ll move on.