def applyAllTargets(self, progressCallback=None, update=True): """ This method applies all targets, in function of age and sex **Parameters:** None. progressCallback will automatically be set to G.app.progress if the progressCallback parameter is left to None. Set it to False to disable progress reporting. """ if progressCallback is None: progressCallback = G.app.progress if progressCallback: progressCallback(0.0) # First call progressCalback (which often processes events) before resetting mesh # so that mesh is not drawn in its reset state algos3d.resetObj(self.meshData) progressVal = 0.0 progressIncr = 0.5 / (len(self.targetsDetailStack) + 1) for (targetPath, morphFactor) in self.targetsDetailStack.iteritems(): algos3d.loadTranslationTarget(self.meshData, targetPath, morphFactor, None, 0, 0) progressVal += progressIncr if progressCallback: progressCallback(progressVal) # Update all verts self.getSeedMesh().update() self.updateProxyMesh() if self.isSubdivided(): self.updateSubdivisionMesh() if progressCallback: progressCallback(0.7) self.mesh.calcNormals() if progressCallback: progressCallback(0.8) if update: self.mesh.update() else: self.meshData.calcNormals(1, 1) if progressCallback: progressCallback(0.8) if update: self.meshData.update() if progressCallback: progressCallback(1.0) #self.traceStack(all=True) #self.traceBuffer(all=True, vertsToList=0) self.callEvent('onChanged', events3d.HumanEvent(self, 'targets'))
def applyAllTargets(self, progressCallback=None, update=True, forceWarpReset=False): """ This method applies all targets, in function of age and sex **Parameters:** None. """ self.muscleWeightModifier.setValue(self, 1.0) self.baseModifier.setValue(self, 1.0) algos3d.resetObj(self.meshData) self.syncShadowVerts() if progressCallback: progressCallback(0.0) progressVal = 0.0 progressIncr = 0.5 / (len(self.targetsDetailStack) + 1) self.resetAllWarpTargets(forceWarpReset) for (targetPath, morphFactor) in self.targetsDetailStack.iteritems(): algos3d.loadTranslationTarget(self.meshData, targetPath, morphFactor, None, 0, 0) progressVal += progressIncr if progressCallback: progressCallback(progressVal) # Update all verts self.getSeedMesh().update() self.updateProxyMesh() if self.isSubdivided(): self.updateSubdivisionMesh() if progressCallback: progressCallback(0.7) self.mesh.calcNormals() if progressCallback: progressCallback(0.8) if update: self.mesh.update() else: self.meshData.calcNormals(1, 1) if progressCallback: progressCallback(0.8) if update: self.meshData.update() if progressCallback: progressCallback(1.0) self.callEvent('onChanged', HumanEvent(self, 'targets'))
def _threadSafeApplyAllTargets(self): algos3d.resetObj(self.human.meshData) for (targetPath, morphFactor) in self.human.targetsDetailStack.iteritems(): algos3d.loadTranslationTarget(self.human.meshData, targetPath, morphFactor, None, 0, 0) self.human._updateOriginalMeshCoords(self.human.meshData.name, self.human.meshData.coord) self.human.updateProxyMesh() self.human.callEvent('onChanged', events3d.HumanEvent(self.human, 'targets')) self.human.refreshStaticMeshes() if self.human.isSubdivided(): self.human.updateSubdivisionMesh() self.human.mesh.calcNormals() self.human.mesh.update() else: self.human.meshData.calcNormals(1, 1) self.human.meshData.update() pass
def applyAllTargets(self, progressCallback=None, update=True): """ This method applies all targets, in function of age and sex **Parameters:** None. """ algos3d.resetObj(self.meshData) if progressCallback: progressCallback(0.0) progressVal = 0.0 progressIncr = 0.5 / (len(self.targetsDetailStack) + 1) for (targetPath, morphFactor) in list(self.targetsDetailStack.items()): algos3d.loadTranslationTarget(self.meshData, targetPath, morphFactor, None, 0, 0) progressVal += progressIncr if progressCallback: progressCallback(progressVal) # Update all verts self.getSeedMesh().update() self.updateProxyMesh() if self.isSubdivided(): self.updateSubdivisionMesh() if progressCallback: progressCallback(0.7) self.mesh.calcNormals() if progressCallback: progressCallback(0.8) if update: self.mesh.update() else: self.meshData.calcNormals(1, 1) if progressCallback: progressCallback(0.8) if update: self.meshData.update() if progressCallback: progressCallback(1.0) self.callEvent('onChanged', events3d.HumanEvent(self, 'targets'))
def applyAllTargets(self, progressCallback=None, update=True): """ This method applies all targets, in function of age and sex **Parameters:** None. """ algos3d.resetObj(self.meshData) if progressCallback: progressCallback(0.0) progressVal = 0.0 progressIncr = 0.5 / (len(self.targetsDetailStack) + 1) for (targetPath, morphFactor) in self.targetsDetailStack.iteritems(): algos3d.loadTranslationTarget(self.meshData, targetPath, morphFactor, None, 0, 0) progressVal += progressIncr if progressCallback: progressCallback(progressVal) # Update all verts self.getSeedMesh().update() self.updateProxyMesh() if self.isSubdivided(): self.updateSubdivisionMesh() if progressCallback: progressCallback(0.7) self.mesh.calcNormals() if progressCallback: progressCallback(0.8) if update: self.mesh.update() else: self.meshData.calcNormals(1, 1) if progressCallback: progressCallback(0.8) if update: self.meshData.update() if progressCallback: progressCallback(1.0) self.callEvent('onChanged', events3d.HumanEvent(self, 'targets'))
def applyAllTargets(self, update=True): """ This method applies all targets, in function of age and sex **Parameters:** None. """ progress = Progress() progress(0.0, 0.5) # First call progress callback (which often processes events) before resetting mesh # so that mesh is not drawn in its reset state algos3d.resetObj(self.meshData) # Reset mesh is in rest pose # Apply targets to seedmesh coordinates itprog = Progress(len(self.targetsDetailStack)) for (targetPath, morphFactor) in self.targetsDetailStack.iteritems(): algos3d.loadTranslationTarget(self.meshData, targetPath, morphFactor, None, 0, 0) itprog.step() # Make sure self.getRestposeCoordinates is up-to-date directly (required for proxy fitting) self._updateOriginalMeshCoords(self.meshData.name, self.meshData.coord) # Update all verts self.getSeedMesh().update() self.updateProxyMesh() #self.traceStack(all=True) #self.traceBuffer(all=True, vertsToList=0) # Update skeleton joint positions if self.getSkeleton(): log.debug("Updating skeleton joint positions") self.getSkeleton().updateJoints(self.meshData) self.resetBakedAnimations() # TODO decide whether we require calling this manually, or whether animatedMesh automatically tracks updates of skeleton and updates accordingly self.callEvent('onChanged', events3d.HumanEvent(self, 'targets')) # Restore pose, and shadow copy of vertex positions # (We do this after onChanged event so that proxies are already updated) self.refreshStaticMeshes() # TODO document: an external plugin that modifies the rest pose verts outside of an onHumanChang(ing/ed) event should explicitly call this method on the human # Update subdivision mesh if self.isSubdivided(): progress(0.5, 0.7) self.updateSubdivisionMesh() progress(0.7, 0.8) self.mesh.calcNormals() progress(0.8, 0.99) if update: self.mesh.update() else: progress(0.5, 0.8) if not self.isPosed(): # Update seedmesh normals (if not already done so by posing) self.meshData.calcNormals(1, 1) progress(0.8, 0.99) if update: self.meshData.update() progress(1.0)