示例#1
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(ArmComponentGuide, self).getRigBuildData()

        # values
        bicepPosition = self.bicepCtrl.xfo.tr
        forearmPosition = self.forearmCtrl.xfo.tr
        wristPosition = self.wristCtrl.xfo.tr

        # Calculate Bicep Xfo
        rootToWrist = wristPosition.subtract(bicepPosition).unit()
        rootToElbow = forearmPosition.subtract(bicepPosition).unit()

        bone1Normal = rootToWrist.cross(rootToElbow).unit()
        bone1ZAxis = rootToElbow.cross(bone1Normal).unit()

        bicepXfo = Xfo()
        bicepXfo.setFromVectors(rootToElbow, bone1Normal, bone1ZAxis,
                                bicepPosition)

        # Calculate Forearm Xfo
        elbowToWrist = wristPosition.subtract(forearmPosition).unit()
        elbowToRoot = bicepPosition.subtract(forearmPosition).unit()
        bone2Normal = elbowToRoot.cross(elbowToWrist).unit()
        bone2ZAxis = elbowToWrist.cross(bone2Normal).unit()
        forearmXfo = Xfo()
        forearmXfo.setFromVectors(elbowToWrist, bone2Normal, bone2ZAxis,
                                  forearmPosition)

        handXfo = Xfo()
        handXfo.tr = self.handCtrl.xfo.tr
        handXfo.ori = self.handCtrl.xfo.ori

        bicepLen = bicepPosition.subtract(forearmPosition).length()
        forearmLen = forearmPosition.subtract(wristPosition).length()

        armEndXfo = Xfo()
        armEndXfo.tr = wristPosition
        armEndXfo.ori = forearmXfo.ori

        upVXfo = xfoFromDirAndUpV(bicepPosition, wristPosition,
                                  forearmPosition)
        upVXfo.tr = forearmPosition
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data['bicepXfo'] = bicepXfo
        data['forearmXfo'] = forearmXfo
        data['handXfo'] = handXfo
        data['armEndXfo'] = armEndXfo
        data['upVXfo'] = upVXfo
        data['forearmLen'] = forearmLen
        data['bicepLen'] = bicepLen

        return data
示例#2
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(StretchyLimbComponentGuide, self).getRigBuildData()

        # Values
        startPos = self.upperCtl.xfo.tr
        midPos = self.lowerCtl.xfo.tr
        endPos = self.endCtl.xfo.tr

        # Calculate Upper Xfo
        startToEnd = endPos.subtract(startPos).unit()
        startToMid = midPos.subtract(startPos).unit()

        bone1Normal = startToEnd.cross(startToMid).unit()
        bone1ZAxis = startToMid.cross(bone1Normal).unit()

        upperXfo = Xfo()
        upperXfo.setFromVectors(startToMid, bone1Normal, bone1ZAxis, startPos)

        # Calculate Lower Xfo
        midToEnd = endPos.subtract(midPos).unit()
        midToStart = startPos.subtract(midPos).unit()
        bone2Normal = midToStart.cross(midToEnd).unit()
        bone2ZAxis = midToEnd.cross(bone2Normal).unit()

        lowerXfo = Xfo()
        lowerXfo.setFromVectors(midToEnd, bone2Normal, bone2ZAxis, midPos)

        upperLen = startPos.subtract(midPos).length()
        lowerLen = endPos.subtract(midPos).length()

        handleXfo = Xfo()
        handleXfo.tr = endPos

        endXfo = Xfo()
        endXfo.tr = endPos
        # endXfo.ori = lowerXfo.ori

        upVXfo = xfoFromDirAndUpV(startPos, endPos, midPos)
        upVXfo.tr = midPos
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data['upperXfo'] = upperXfo
        data['lowerXfo'] = lowerXfo
        data['endXfo'] = endXfo
        data['handleXfo'] = handleXfo
        data['upVXfo'] = upVXfo
        data['upperLen'] = upperLen
        data['lowerLen'] = lowerLen

        return data
示例#3
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(ArmComponentGuide, self).getRigBuildData()

        # values
        bicepPosition = self.bicepCtrl.xfo.tr
        forearmPosition = self.forearmCtrl.xfo.tr
        wristPosition = self.wristCtrl.xfo.tr

        # Calculate Bicep Xfo
        rootToWrist = wristPosition.subtract(bicepPosition).unit()
        rootToElbow = forearmPosition.subtract(bicepPosition).unit()

        bone1Normal = rootToWrist.cross(rootToElbow).unit()
        bone1ZAxis = rootToElbow.cross(bone1Normal).unit()

        bicepXfo = Xfo()
        bicepXfo.setFromVectors(rootToElbow, bone1Normal, bone1ZAxis, bicepPosition)

        # Calculate Forearm Xfo
        elbowToWrist = wristPosition.subtract(forearmPosition).unit()
        elbowToRoot = bicepPosition.subtract(forearmPosition).unit()
        bone2Normal = elbowToRoot.cross(elbowToWrist).unit()
        bone2ZAxis = elbowToWrist.cross(bone2Normal).unit()
        forearmXfo = Xfo()
        forearmXfo.setFromVectors(elbowToWrist, bone2Normal, bone2ZAxis, forearmPosition)

        handXfo = Xfo()
        handXfo.tr = self.handCtrl.xfo.tr
        handXfo.ori = self.handCtrl.xfo.ori

        bicepLen = bicepPosition.subtract(forearmPosition).length()
        forearmLen = forearmPosition.subtract(wristPosition).length()

        armEndXfo = Xfo()
        armEndXfo.tr = wristPosition
        armEndXfo.ori = forearmXfo.ori

        upVXfo = xfoFromDirAndUpV(bicepPosition, wristPosition, forearmPosition)
        upVXfo.tr = forearmPosition
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data["bicepXfo"] = bicepXfo
        data["forearmXfo"] = forearmXfo
        data["handXfo"] = handXfo
        data["armEndXfo"] = armEndXfo
        data["upVXfo"] = upVXfo
        data["forearmLen"] = forearmLen
        data["bicepLen"] = bicepLen

        return data
示例#4
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(StretchyLimbComponentGuide, self).getRigBuildData()

        # Values
        startPos = self.upperCtl.xfo.tr
        midPos = self.lowerCtl.xfo.tr
        endPos = self.endCtl.xfo.tr

        # Calculate Upper Xfo
        startToEnd = endPos.subtract(startPos).unit()
        startToMid = midPos.subtract(startPos).unit()

        bone1Normal = startToEnd.cross(startToMid).unit()
        bone1ZAxis = startToMid.cross(bone1Normal).unit()

        upperXfo = Xfo()
        upperXfo.setFromVectors(startToMid, bone1Normal, bone1ZAxis, startPos)

        # Calculate Lower Xfo
        midToEnd = endPos.subtract(midPos).unit()
        midToStart = startPos.subtract(midPos).unit()
        bone2Normal = midToStart.cross(midToEnd).unit()
        bone2ZAxis = midToEnd.cross(bone2Normal).unit()

        lowerXfo = Xfo()
        lowerXfo.setFromVectors(midToEnd, bone2Normal, bone2ZAxis, midPos)

        upperLen = startPos.subtract(midPos).length()
        lowerLen = endPos.subtract(midPos).length()

        handleXfo = Xfo()
        handleXfo.tr = endPos

        endXfo = Xfo()
        endXfo.tr = endPos
        # endXfo.ori = lowerXfo.ori

        upVXfo = xfoFromDirAndUpV(startPos, endPos, midPos)
        upVXfo.tr = midPos
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data['upperXfo'] = upperXfo
        data['lowerXfo'] = lowerXfo
        data['endXfo'] = endXfo
        data['handleXfo'] = handleXfo
        data['upVXfo'] = upVXfo
        data['upperLen'] = upperLen
        data['lowerLen'] = lowerLen

        return data
示例#5
0
    def calculateUpVXfo(self, boneXfos, endXfo):
        """Calculates the transform for the UpV control.

        Args:
            boneXfos (list): Bone transforms.
            endXfo (Xfo): Transform for the end of the chain.

        Returns:
            Xfo: Up Vector transform.

        """

        # Calculate FW
        toFirst = boneXfos[1].tr.subtract(boneXfos[0].tr).unit()
        toTip = endXfo.tr.subtract(boneXfos[0].tr).unit()
        fw = toTip.cross(toFirst).unit()

        chainNormal = fw.cross(toTip).unit()
        chainZAxis = toTip.cross(chainNormal).unit()

        chainXfo = Xfo()
        chainXfo.setFromVectors(toTip.unit(), chainNormal, chainZAxis,
                                boneXfos[0].tr)

        rootToTip = endXfo.tr.subtract(boneXfos[0].tr).length()

        upVXfo = Xfo()
        upVXfo.tr = chainXfo.transformVector(
            Vec3(rootToTip / 2.0, rootToTip / 2.0, 0.0))

        return upVXfo
示例#6
0
    def calculateUpVXfo(self, boneXfos, endXfo):
        """Calculates the transform for the UpV control.

        Args:
            boneXfos (list): Bone transforms.
            endXfo (Xfo): Transform for the end of the chain.

        Returns:
            Xfo: Up Vector transform.

        """


        # Calculate FW
        toFirst = boneXfos[1].tr.subtract(boneXfos[0].tr).unit()
        toTip = endXfo.tr.subtract(boneXfos[0].tr).unit()
        fw = toTip.cross(toFirst).unit()

        chainNormal = fw.cross(toTip).unit()
        chainZAxis = toTip.cross(chainNormal).unit()

        chainXfo = Xfo()
        chainXfo.setFromVectors(toTip.unit(), chainNormal, chainZAxis, boneXfos[0].tr)

        rootToTip = endXfo.tr.subtract(boneXfos[0].tr).length()

        upVXfo = Xfo()
        upVXfo.tr = chainXfo.transformVector(Vec3(rootToTip / 2.0, rootToTip / 2.0, 0.0))

        return upVXfo
示例#7
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(LegComponentGuide, self).getRigBuildData()

        # Values
        femurPosition = self.femurCtrl.xfo.tr
        kneePosition = self.kneeCtrl.xfo.tr
        anklePosition = self.ankleCtrl.xfo.tr

        # Calculate Bicep Xfo
        rootToWrist = anklePosition.subtract(femurPosition).unit()
        rootToKnee = kneePosition.subtract(femurPosition).unit()

        bone1Normal = rootToWrist.cross(rootToKnee).unit()
        bone1ZAxis = rootToKnee.cross(bone1Normal).unit()

        femurXfo = Xfo()
        femurXfo.setFromVectors(rootToKnee, bone1Normal, bone1ZAxis,
                                femurPosition)

        # Calculate Forearm Xfo
        elbowToWrist = anklePosition.subtract(kneePosition).unit()
        elbowToRoot = femurPosition.subtract(kneePosition).unit()
        bone2Normal = elbowToRoot.cross(elbowToWrist).unit()
        bone2ZAxis = elbowToWrist.cross(bone2Normal).unit()

        kneeXfo = Xfo()
        kneeXfo.setFromVectors(elbowToWrist, bone2Normal, bone2ZAxis,
                               kneePosition)

        femurLen = femurPosition.subtract(kneePosition).length()
        shinLen = kneePosition.subtract(anklePosition).length()

        handleXfo = Xfo()
        handleXfo.tr = anklePosition

        upVXfo = xfoFromDirAndUpV(femurPosition, anklePosition, kneePosition)
        upVXfo.tr = kneePosition
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data['femurXfo'] = femurXfo
        data['kneeXfo'] = kneeXfo
        data['handleXfo'] = handleXfo
        data['upVXfo'] = upVXfo
        data['femurLen'] = femurLen
        data['shinLen'] = shinLen

        return data
示例#8
0
    def getRigBuildData(self):

        data = super(mjEyelidComponentGuide, self).getRigBuildData()

        eyeballPosition = self.eyeballCtrl.xfo.tr
        eyeballOriXfo = Xfo()
        eyeballOriXfo.tr = eyeballPosition
        eyeballOriOffset = Quat(Vec3(0.0, 0.894, 0.0), -0.448)
        if self.getLocation() == "R":
            eyeballOriXfo.ori.subtract(eyeballOriOffset)

        data['eyeballXfo'] = eyeballOriXfo

        eyelidUpVOffset = Vec3(0.0, 0.2, 0.0)
        eyelidUpVXfo = Xfo()
        eyelidUpVXfo.tr = eyeballPosition.add(eyelidUpVOffset)

        data['eyelidUpVXfo'] = eyelidUpVXfo

        data['lidMedialXfo'] = self.lidMedialCtrl.xfo
        data['lidLateralXfo'] = self.lidLateralCtrl.xfo

        data['lidUpXfo'] = self.lidUpCtrl.xfo
        data['lidUpMedialXfo'] = self.lidUpMedialCtrl.xfo
        data['lidUpLateralXfo'] = self.lidUpLateralCtrl.xfo

        data['lidLowXfo'] = self.lidLowCtrl.xfo
        data['lidLowMedialXfo'] = self.lidLowMedialCtrl.xfo
        data['lidLowLateralXfo'] = self.lidLowLateralCtrl.xfo

        data['numUpDeformers'] = self.numUpDeformersAttr.getValue()
        data['numLowDeformers'] = self.numLowDeformersAttr.getValue()

        data['lidUpMedialBlink'] = self.upMedialFactorAttr.getValue()
        data['lidUpLateralBlink'] = self.upLateralFactorAttr.getValue()

        data['lidLowMedialBlink'] = self.lowMedialFactorAttr.getValue()
        data['lidLowLateralBlink'] = self.lowLateralFactorAttr.getValue()

        return data
示例#9
0
    def evaluate(self):
        """invokes the constraint causing the output value to be computed.

        Return:
        Boolean, True if successful.

        """

        if self.getMaintainOffset() is False:
            newXfo = Xfo()
            newXfo.ori.set(Vec3(), 0.0)
            for constrainer in self.getConstrainers():
                newXfo.tr = newXfo.tr.add(constrainer.xfo.tr)
                newXfo.ori = newXfo.ori.add(constrainer.xfo.ori)

            newXfo.ori.setUnit()
            self.getConstrainee().xfo = newXfo

        return True
示例#10
0
    def evaluate(self):
        """invokes the constraint causing the output value to be computed.

        Returns:
            bool: True if successful.

        """

        if self.getMaintainOffset() is False:
            newXfo = Xfo();
            newXfo.ori.set(Vec3(), 0.0)
            for constrainer in self.getConstrainers():
                newXfo.tr = newXfo.tr.add(constrainer.xfo.tr)
                newXfo.ori = newXfo.ori.add(constrainer.xfo.ori)

            newXfo.ori.setUnit()
            self.getConstrainee().xfo = newXfo

        return True
示例#11
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(FKCollisionComponentGuide, self).getRigBuildData()

        numJoints = self.numJoints.getValue()

        # Calculate Xfos
        boneXfos = []
        boneLengths = []

        for i in xrange(numJoints):

            boneVec = self.jointCtrls[i + 1].xfo.tr.subtract(
                self.jointCtrls[i].xfo.tr)
            boneLengths.append(boneVec.length())

            xfo = Xfo()
            q = Quat()
            q.setFromDirectionAndUpvector(
                boneVec.unit(), self.jointCtrls[i].xfo.ori.getYaxis())
            qDir = Quat().setFromAxisAndAngle(Vec3(0, 1, 0),
                                              Math_degToRad(-90))
            xfo.ori = q * qDir
            xfo.tr = self.jointCtrls[i].xfo.tr

            boneXfos.append(xfo)

        data['jointXfos'] = [x.xfo for x in self.jointCtrls]
        data['boneXfos'] = boneXfos
        data['endXfo'] = self.jointCtrls[-1].xfo
        data['boneLengths'] = boneLengths

        return data
示例#12
0
    def getRigBuildData(self):
        """Returns the Guide data used by the Rig Component to define the layout of the final rig..

        Return:
        The JSON rig data object.

        """

        data = super(LegComponentGuide, self).getRigBuildData()

        # Values
        femurPosition = self.femurCtrl.xfo.tr
        kneePosition = self.kneeCtrl.xfo.tr
        anklePosition = self.ankleCtrl.xfo.tr
        toePosition = self.toeCtrl.xfo.tr
        toeTipPosition = self.toeTipCtrl.xfo.tr

        # Calculate Bicep Xfo
        rootToWrist = anklePosition.subtract(femurPosition).unit()
        rootToKnee = kneePosition.subtract(femurPosition).unit()

        bone1Normal = rootToWrist.cross(rootToKnee).unit()
        bone1ZAxis = rootToKnee.cross(bone1Normal).unit()

        femurXfo = Xfo()
        femurXfo.setFromVectors(rootToKnee, bone1Normal, bone1ZAxis, femurPosition)

        # Calculate Forearm Xfo
        elbowToWrist = anklePosition.subtract(kneePosition).unit()
        elbowToRoot = femurPosition.subtract(kneePosition).unit()
        bone2Normal = elbowToRoot.cross(elbowToWrist).unit()
        bone2ZAxis = elbowToWrist.cross(bone2Normal).unit()

        kneeXfo = Xfo()
        kneeXfo.setFromVectors(elbowToWrist, bone2Normal, bone2ZAxis, kneePosition)

        femurLen = femurPosition.subtract(kneePosition).length()
        shinLen = kneePosition.subtract(anklePosition).length()

        handleXfo = Xfo()
        handleXfo.tr = anklePosition

        ankleXfo = Xfo()
        ankleXfo.tr = anklePosition
        # ankleXfo.ori = kneeXfo.ori

        toeXfo = Xfo()
        toeXfo.tr = toePosition
        # toeXfo.ori = kneeXfo.ori

        upVXfo = xfoFromDirAndUpV(femurPosition, anklePosition, kneePosition)
        upVXfo.tr = kneePosition
        upVXfo.tr = upVXfo.transformVector(Vec3(0, 0, 5))

        data['femurXfo'] = femurXfo
        data['kneeXfo'] = kneeXfo
        data['handleXfo'] = handleXfo
        data['ankleXfo'] = ankleXfo
        data['toeXfo'] = toeXfo
        data['upVXfo'] = upVXfo
        data['femurLen'] = femurLen
        data['shinLen'] = shinLen

        return data