mradfo21
12-20-2010, 10:45 PM
hello everyone. i'm a lighting artist so my background isnt in computer programming - i hope you'll bare with me :)
I'm trying to come up with a way to efficicenty add points to models so they can have the same number of verticies and be used for blendshapes (this is just one part of a larger task)
i've come up with a way but it is dreadfully slow. right now i'm doing comparison's inside a while loop to determine the number of verticies - then performing a "polyPoke" on faces untill the vert count matches up. this takes FOREVER to run and this is just with two objects of similar topology - im potentially looking at objects with a million vert difference later on.
any suggestions for a quicker way? I've thought about writing a function that will generate different split polygon commands (only dividng one edge) - maybe that will be faster?
anyways, heres the code i wrote ( formatting is correct - pasting not a good idea..):
import pymel.core as pm
import random
def subdivideRandomFace(obj):
randFaceNum = str(random.randint(0,pm.polyEvaluate(obj, v = True)))
randFace = obj + ".f["+randFaceNum+"]"
pm.polyPoke(randFace, ch = 0)
return(randFace)
leadObj = pm.ls(sl = True)[0]
compareObj = pm.ls(sl = True)[1]
leadVertNum = pm.polyEvaluate(leadObj, v =True)
compareVertNum = pm.polyEvaluate(compareObj, v = True)
while leadVertNum != compareVertNum:
leadVertNum = pm.polyEvaluate(leadObj, v =True)
compareVertNum = pm.polyEvaluate(compareObj, v = True)
if leadVertNum == compareVertNum:
print "same number of verticies"
print "lead object vert = ", leadVertNum, " and compare object vert = ", compareVertNum
else:
print "different number of verticies"
print "lead object vert = ", leadVertNum, " and compare object vert = ", compareVertNum
subdivideRandomFace(leadObj)
I'm trying to come up with a way to efficicenty add points to models so they can have the same number of verticies and be used for blendshapes (this is just one part of a larger task)
i've come up with a way but it is dreadfully slow. right now i'm doing comparison's inside a while loop to determine the number of verticies - then performing a "polyPoke" on faces untill the vert count matches up. this takes FOREVER to run and this is just with two objects of similar topology - im potentially looking at objects with a million vert difference later on.
any suggestions for a quicker way? I've thought about writing a function that will generate different split polygon commands (only dividng one edge) - maybe that will be faster?
anyways, heres the code i wrote ( formatting is correct - pasting not a good idea..):
import pymel.core as pm
import random
def subdivideRandomFace(obj):
randFaceNum = str(random.randint(0,pm.polyEvaluate(obj, v = True)))
randFace = obj + ".f["+randFaceNum+"]"
pm.polyPoke(randFace, ch = 0)
return(randFace)
leadObj = pm.ls(sl = True)[0]
compareObj = pm.ls(sl = True)[1]
leadVertNum = pm.polyEvaluate(leadObj, v =True)
compareVertNum = pm.polyEvaluate(compareObj, v = True)
while leadVertNum != compareVertNum:
leadVertNum = pm.polyEvaluate(leadObj, v =True)
compareVertNum = pm.polyEvaluate(compareObj, v = True)
if leadVertNum == compareVertNum:
print "same number of verticies"
print "lead object vert = ", leadVertNum, " and compare object vert = ", compareVertNum
else:
print "different number of verticies"
print "lead object vert = ", leadVertNum, " and compare object vert = ", compareVertNum
subdivideRandomFace(leadObj)
