def getSubdivisionMesh(self, update=True): """ Create or update the Catmull-Clark subdivided (or smoothed) mesh for this mesh. This does not change the status of isSubdivided(), use setSubdivided() for that. If this mesh is doubled by a proxy, when isProxied() is true, a subdivision mesh for the proxy is used. Returns the subdivided mesh data. """ import catmull_clark_subdivision as cks if self.isProxied(): if not self.__proxySubdivisionMesh: self.__proxySubdivisionMesh = cks.createSubdivisionObject(self.__proxyMesh, None) if self.__seedMesh.object3d: self.attachMesh(self.__proxySubdivisionMesh) elif update: cks.updateSubdivisionObject(self.__proxySubdivisionMesh) return self.__proxySubdivisionMesh else: if not self.__subdivisionMesh: self.__subdivisionMesh = cks.createSubdivisionObject(self.__seedMesh, self.staticFaceMask) if self.__seedMesh.object3d: self.attachMesh(self.__subdivisionMesh) elif update: cks.updateSubdivisionObject(self.__subdivisionMesh) return self.__subdivisionMesh
def getSubdivisionMesh(self, update=True, progressCallback=None): """ Create or update the Catmull-Clark subdivided (or smoothed) mesh for this mesh. This does not change the status of isSubdivided(), use setSubdivided() for that. If this mesh is doubled by a proxy, when isProxied() is true, a subdivision mesh for the proxy is used. Returns the subdivided mesh data. """ if self.isProxied(): if not self.__proxySubdivisionMesh: self.__proxySubdivisionMesh = cks.createSubdivisionObject(self.__proxyMesh, progressCallback) if self.__seedMesh.object3d: self.attachMesh(self.__proxySubdivisionMesh) elif update: cks.updateSubdivisionObject(self.__proxySubdivisionMesh, progressCallback) return self.__proxySubdivisionMesh else: if not self.__subdivisionMesh: self.__subdivisionMesh = cks.createSubdivisionObject(self.__seedMesh, progressCallback) if self.__seedMesh.object3d: self.attachMesh(self.__subdivisionMesh) elif update: cks.updateSubdivisionObject(self.__subdivisionMesh, progressCallback) return self.__subdivisionMesh
def setupObjects(name, human, config=None, rawTargets=[], helpers=False, hidden=False, eyebrows=True, lashes=True, subdivide = False, progressCallback=None): from armature.armature import setupArmature def progress(prog): if progressCallback == None: pass else: progressCallback (prog) if not config: config = Config() config.setHuman(human) rmeshes = [] amt = setupArmature(name, human, config.rigOptions) richMesh = richmesh.getRichMesh(human.meshData, None, None, rawTargets, amt) richMesh.name = name if amt: richMesh.weights = amt.vertexWeights deleteGroups = [] deleteVerts = None # Don't load deleteVerts from proxies directly, we use the facemask set in the gui module3d _,deleteVerts = setupProxies('Clothes', None, human, rmeshes, richMesh, config, deleteGroups, deleteVerts) _,deleteVerts = setupProxies('Hair', None, human, rmeshes, richMesh, config, deleteGroups, deleteVerts) _,deleteVerts = setupProxies('Eyes', None, human, rmeshes, richMesh, config, deleteGroups, deleteVerts) foundProxy,deleteVerts = setupProxies('Proxy', name, human, rmeshes, richMesh, config, deleteGroups, deleteVerts) progress(0.06*(3-2*subdivide)) if not foundProxy: if helpers is None: # helpers override everything richMesh = filterMesh(richMesh, deleteGroups, deleteVerts, eyebrows, lashes, not hidden) rmeshes = [richMesh] + rmeshes if config.scale != 1.0: amt.rescale(config.scale) for rmesh in rmeshes: rmesh.rescale(config.scale) progbase = 0.12*(3-2*subdivide) progress(progbase) # Subdivide, if requested. rmeshnum = float(len(rmeshes)) i = 0.0 for rmesh in rmeshes: progress(progbase+(i/rmeshnum)*(1-progbase)) if subdivide: subMesh = cks.createSubdivisionObject( rmesh.object, lambda p: progress(progbase+((i+p)/rmeshnum)*(1-progbase))) rmesh.fromObject(subMesh, rmesh.weights, rawTargets) i += 1.0 progress(1) return rmeshes,amt
def setupObjects(name, human, config=None, rigfile=None, rawTargets=[], helpers=False, hidden=False, eyebrows=True, lashes=True, subdivide = False, progressCallback=None): global theStuff, theTextures, theTexFiles, theMaterials def progress(prog): if progressCallback == None: pass else: progressCallback (prog) if not config: config = Config() config.setHuman(human) obj = human.meshData theTextures = {} theTexFiles = {} theMaterials = {} stuffs = [] stuff = CStuff(name, obj = human) if rigfile: stuff.boneInfo = getArmatureFromRigFile(rigfile, obj, config.scale) log.message("Using rig file %s" % rigfile) meshInfo = mh2proxy.getMeshInfo(obj, None, config, None, rawTargets, None) if stuff.boneInfo: meshInfo.weights = stuff.boneInfo.weights theStuff = stuff deleteGroups = [] deleteVerts = None # Don't load deleteVerts from proxies directly, we use the facemask set in the gui module3d _,deleteVerts = setupProxies('Clothes', None, obj, stuffs, meshInfo, config, deleteGroups, deleteVerts) _,deleteVerts = setupProxies('Hair', None, obj, stuffs, meshInfo, config, deleteGroups, deleteVerts) foundProxy,deleteVerts = setupProxies('Proxy', name, obj, stuffs, meshInfo, config, deleteGroups, deleteVerts) progress(0.06*(3-2*subdivide)) if not foundProxy: if helpers: # helpers override everything if config.scale == 1.0: stuff.meshInfo = meshInfo else: stuff.meshInfo = meshInfo.fromProxy(config.scale*obj.coord, obj.texco, obj.fvert, obj.fuvs, meshInfo.weights, meshInfo.shapes) else: stuff.meshInfo = filterMesh(meshInfo, config.scale, deleteGroups, deleteVerts, eyebrows, lashes, not hidden) stuffs = [stuff] + stuffs progbase = 0.12*(3-2*subdivide) progress(progbase) # Apply textures, and subdivide, if requested. stuffnum = float(len(stuffs)) i = 0.0 for stuff in stuffs: progress(progbase+(i/stuffnum)*(1-progbase)) texture = stuff.object.mesh.texture stuff.texture = (os.path.dirname(texture), os.path.basename(texture)) if subdivide: subMesh = cks.createSubdivisionObject( stuff.meshInfo.object, lambda p: progress(progbase+((i+p)/stuffnum)*(1-progbase))) stuff.meshInfo.fromObject(subMesh, stuff.meshInfo.weights, rawTargets) i += 1.0 # Apply subtextures. stuffs[0].textureImage = mh.Image(os.path.join(stuffs[0].texture[0], stuffs[0].texture[1])) mhstx = mh.G.app.getCategory('Textures').getTaskByName('Texture').eyeTexture if mhstx: stuffs[0].textureImage = subtextures.combine(stuffs[0].textureImage, mhstx) progress(1) return stuffs