def applyPose(self,savePath=None): if savePath: try: fileDescriptor = open(savePath,'w') except: print "Error in saving %s" %savePath self.resetTransf() self.character.restoreMesh() #restore the mesh without rotations self.loadTargets() if self.rotOrder == "xyz": rotSequence = [self.rotx,self.roty,self.rotz] if self.rotOrder == "xzy": rotSequence = [self.rotx,self.rotz,self.roty] if self.rotOrder == "zyx": rotSequence = [self.rotz,self.roty,self.rotx] if self.rotOrder == "zxy": rotSequence = [self.rotz,self.rotx,self.roty] if self.rotOrder == "yxz": rotSequence = [self.roty,self.rotx,self.rotz] if self.rotOrder == "yzx": rotSequence = [self.roty,self.rotz,self.rotx] traslPaths = self.trasl.keys() traslPaths.sort() scale = None for targetPath in traslPaths: if (scale == None): scale = algos3d.computeScale(self.oBoundingBox, targetPath, self.character.meshData) morphFactor = self.trasl[targetPath] algos3d.loadTranslationTarget(self.character, targetPath, morphFactor, None, 1, 0, scale) if savePath: fileDescriptor.write("%s %f\n" % (targetPath, morphFactor)) for rotation in rotSequence: rotPaths = rotation.keys() rotPaths.sort() for targetPath in rotPaths: morphFactor = rotation[targetPath] algos3d.loadRotationTarget(self.character.meshData, targetPath, morphFactor) if savePath: fileDescriptor.write("%s %f\n" % (targetPath, morphFactor)) self.character.meshData.calcNormals(facesToUpdate=[f for f in self.character.meshData.faces]) self.character.meshData.update() if savePath: fileDescriptor.close()
def rotateLimb(self, targetPath, morphFactor): targetPath1 = targetPath+".target" targetPath2 = targetPath+".rot" algos3d.loadTranslationTarget(self.meshData, targetPath1, morphFactor, None, 1, 0) algos3d.loadRotationTarget(self.meshData, targetPath2, morphFactor)