Exemplo n.º 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
Exemplo n.º 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(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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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