コード例 #1
0
    def applyToPose(self, pose):
        if self.base_bvh is None:
            self._load_pose_units()
        self._setting_pose = True

        if self._get_current_pose() is None:
            # No pose set, simply set this one
            pose_ = pose
            pose_.pose_backref = None
        else:
            # If the current pose was already modified by expression library, use the original one
            org_pose = self._get_current_unmodified_pose()
            if org_pose is None:
                org_pose = self._get_current_pose()
            pose_ = animation.mixPoses(org_pose, pose, self.face_bone_idxs)
            pose_.pose_backref = org_pose

        pose_.name = 'expr-lib-pose'
        self.human.addAnimation(pose_)
        self.human.setActiveAnimation('expr-lib-pose')

        self.human.setPosed(True)
        self.human.refreshPose()

        self._setting_pose = False
コード例 #2
0
    def applyToPose(self, pose):
        if self.base_bvh is None:
            self._load_pose_units()
        self._setting_pose = True

        if self._get_current_pose() is None:
            # No pose set, simply set this one
            pose_ = pose
            pose_.pose_backref = None
        else:
            # If the current pose was already modified by expression library, use the original one
            org_pose = self._get_current_unmodified_pose()
            if org_pose is None:
                org_pose = self._get_current_pose()
            pose_ = animation.mixPoses(org_pose, pose, self.face_bone_idxs)
            pose_.pose_backref = org_pose

        pose_.name = 'expr-lib-pose'
        self.human.addAnimation(pose_)
        self.human.setActiveAnimation('expr-lib-pose')

        self.human.setPosed(True)
        self.human.refreshPose()

        self._setting_pose = False
コード例 #3
0
    def setExpressionFromFile(self, mhposeFile):
        """Set the expression from a mhpose file"""

        if mhposeFile is None:
            # clear expression

            original_pose = self.getPoseAsAnimation()
            if original_pose and hasattr(original_pose, 'pose_backref'):
                original_pose = original_pose.pose_backref
    
            if original_pose is None:
                self.human.setActiveAnimation(None)
            else:
                if self.human.hasAnimation(original_pose.name):
                    self.human.setActiveAnimation(original_pose.name)
                else:
                    self.human.addAnimation(original_pose)
                    self.human.setActiveAnimation(orgiginal_pose.name)
    
            if self.human.hasAnimation('expr-lib-pose'):
                self.human.removeAnimation('expr-lib-pose')
        else:
            # Assign expression
            
            base_bvh = bvh.load(getpath.getSysDataPath('poseunits/face-poseunits.bvh'), allowTranslation="none")
            base_anim = base_bvh.createAnimationTrack(self.human.getBaseSkeleton(), name="Expression-Face-PoseUnits")

            poseunit_json = json.load(open(getpath.getSysDataPath('poseunits/face-poseunits.json'), 'r', encoding='utf-8'), object_pairs_hook=OrderedDict)
            poseunit_names = poseunit_json['framemapping']

            base_anim = animation.PoseUnit(base_anim.name, base_anim._data, poseunit_names)

            face_bone_idxs = sorted(list(set([bIdx for l in base_anim.getAffectedBones() for bIdx in l])))

            new_pose = animation.poseFromUnitPose('expr-lib-pose', mhposeFile, base_anim)

            current_pose = self.getPoseAsAnimation()

            if current_pose is None:
                current_pose = new_pose
                current_pose.pose_backref = None
            else:
                if hasattr(current_pose,'pose_backref') and not current_pose.pose_backref is None:
                    current_pose = current_pose.pose_backref
                org_pose = current_pose
                current_pose = animation.mixPoses(org_pose, new_pose, face_bone_idxs)

            current_pose.name = 'expr-lib-pose'
            self.human.addAnimation(current_pose)
            self.human.setActiveAnimation(current_pose.name)
            self.human.setPosed(True)
            self.human.refreshPose()
コード例 #4
0
    def applyToPose(self, pose):
        self._setting_pose = True

        if self._get_current_pose() is None:
            # No pose set, simply set this one
            pose_ = pose
            pose_.pose_mix_backref = None
        else:
            org_pose = self._get_current_unmodified_pose()
            pose_ = animation.mixPoses(org_pose, pose, self.affected_bone_idxs)
            pose_.pose_foot_backref = org_pose

        pose_.name = 'special-mix-pose'
        self.human.addAnimation(pose_)
        self.human.setActiveAnimation('special-mix-pose')

        self.human.setPosed(True)
        self.human.refreshPose()

        self._setting_pose = False
コード例 #5
0
    def applyToPose(self, pose):
        self._setting_pose = True

        if self._get_current_pose() is None:
            # No pose set, simply set this one
            pose_ = pose
            pose_.pose_foot_backref = None
        else:
            # If the current pose was already modified by foot pose library, use the original one
            org_pose = self._get_current_unmodified_pose()
            pose_ = animation.mixPoses(org_pose, pose, self.affected_bone_idxs)
            pose_.pose_foot_backref = org_pose

        pose_.name = 'special-foot-pose'
        self.human.addAnimation(pose_)
        self.human.setActiveAnimation('special-foot-pose')

        self.human.setPosed(True)
        self.human.refreshPose()

        self._setting_pose = False