def getReferences(self): """ Building source and target characters from scratch. The source character is the sum of reference characters. The target character is the sum of all non-warp targets. Cannot use human.getSeedMesh() which returns sum of all targets. """ srcCharCoord = self.human.meshData.orig_coord.copy() trgCharCoord = srcCharCoord.copy() srcTargetCoord = np.zeros(srcCharCoord.shape, dtype=np.float32) keypoints = self.getKeypoints() trgPoints = np.zeros(6, float) srcPoints = np.zeros(6, float) # Traverse targets on stack for charpath,value in self.human.targetsDetailStack.items(): if 'expression' in charpath: # TODO remove this stupid hack continue # The original target try: trgChar = algos3d.getTarget(self.human.meshData, charpath) except KeyError: continue # Warp target? - ignore if isinstance(trgChar, WarpTarget): continue # TODO This is very wasteful, because we only need trgCharCoord and # srcCharCoord at the six keypoints srcVerts = np.s_[...] dstVerts = trgChar.verts[srcVerts] trgCharCoord[dstVerts] += value * trgChar.data[srcVerts] # TODO replace with getting whole stack del charpath del value # The reference target (from reference variables) factors = self.getFactors(1.0) # Calculate the fully applied warp target (weight = 1.0) factors = self.toReferenceFactors(factors) refTargets = self.referenceTargets tWeights = humanmodifier.getTargetWeights(refTargets, factors, ignoreNotfound = True) for tpath, tweight in tWeights.items(): srcChar = algos3d.getTarget(self.human.meshData, tpath) dstVerts = srcChar.verts[srcVerts] srcCharCoord[dstVerts] += tweight * srcChar.data[srcVerts] # The warp target warpTargets = self.targets tWeights = humanmodifier.getTargetWeights(warpTargets, factors, ignoreNotfound = True) for tpath, tweight in tWeights.items(): srcTrg = readTarget(tpath) addTargetVerts(srcTargetCoord, tweight, srcTrg) # Aggregate the keypoints differences trgPoints = trgCharCoord[keypoints] srcPoints = srcCharCoord[keypoints] return srcTargetCoord, srcPoints, trgPoints
def getReferences(self): """ Building source and target characters from scratch. The source character is the sum of reference characters. The target character is the sum of all non-warp targets. Cannot use human.getSeedMesh() which returns sum of all targets. """ srcCharCoord = self.human.meshData.orig_coord.copy() trgCharCoord = srcCharCoord.copy() srcTargetCoord = np.zeros(srcCharCoord.shape, dtype=np.float32) keypoints = self.getKeypoints() trgPoints = np.zeros(6, float) srcPoints = np.zeros(6, float) # Traverse targets on stack for charpath, value in self.human.targetsDetailStack.items(): if 'expression' in charpath: # TODO remove this stupid hack continue # The original target try: trgChar = algos3d.getTarget(self.human.meshData, charpath) except KeyError: continue # Warp target? - ignore if isinstance(trgChar, WarpTarget): continue # TODO This is very wasteful, because we only need trgCharCoord and # srcCharCoord at the six keypoints srcVerts = np.s_[...] dstVerts = trgChar.verts[srcVerts] trgCharCoord[dstVerts] += value * trgChar.data[ srcVerts] # TODO replace with getting whole stack del charpath del value # The reference target (from reference variables) factors = self.getFactors( 1.0) # Calculate the fully applied warp target (weight = 1.0) factors = self.toReferenceFactors(factors) refTargets = self.referenceTargets tWeights = humanmodifier.getTargetWeights(refTargets, factors, ignoreNotfound=True) for tpath, tweight in tWeights.items(): srcChar = algos3d.getTarget(self.human.meshData, tpath) dstVerts = srcChar.verts[srcVerts] srcCharCoord[dstVerts] += tweight * srcChar.data[srcVerts] # The warp target warpTargets = self.targets tWeights = humanmodifier.getTargetWeights(warpTargets, factors, ignoreNotfound=True) for tpath, tweight in tWeights.items(): srcTrg = readTarget(tpath) addTargetVerts(srcTargetCoord, tweight, srcTrg) # Aggregate the keypoints differences trgPoints = trgCharCoord[keypoints] srcPoints = srcCharCoord[keypoints] return srcTargetCoord, srcPoints, trgPoints