예제 #1
0
def buildArm(mode='guide'):

    Profiler.getInstance().push("arm_build")

    guideContainer = Container('armGuide')

    armGuide = ArmComponentGuide("arm", parent=guideContainer)
    armGuide.loadData({
        "name":
        "Arm",
        "location":
        "L",
        "bicepXfo":
        Xfo(Vec3(2.27, 15.295, -0.753)),
        "forearmXfo":
        Xfo(Vec3(5.039, 13.56, -0.859)),
        "wristXfo":
        Xfo(Vec3(7.1886, 12.2819, 0.4906)),
        "handXfo":
        Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
            ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
        "bicepFKCtrlSize":
        1.75,
        "forearmFKCtrlSize":
        1.5
    })

    if mode == 'guide':
        builder = plugins.getBuilder()
        builder.build(guideContainer)

    elif mode == 'rig':
        synchronizer = plugins.getSynchronizer()
        synchronizer.setTarget(guideContainer)
        synchronizer.sync()

        armGuideData = armGuide.getRigBuildData()

        rigContainer = Container('armRig')
        arm = ArmComponent(parent=rigContainer)
        arm.loadData(armGuideData)

        builder = plugins.getBuilder()
        builder.build(rigContainer)
    else:
        LogMessage('Invalid mode set')

    Profiler.getInstance().pop()

    if __name__ == "__main__":
        print Profiler.getInstance().generateReport()
    else:
        if mode == 'guide':
            logHierarchy(armGuide)
        elif mode == 'rig':
            logHierarchy(arm)
예제 #2
0
    def __init__(self, name='twist', parent=None):

        Profiler.getInstance().push('Construct Spine Guide Component:' + name)
        super(TwistComponentGuide, self).__init__(name, parent)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup('GuideSettings', parent=self)
        self.numDeformersAttr = IntegerAttribute('numDeformers',
                                                 value=1,
                                                 minValue=0,
                                                 maxValue=20,
                                                 parent=guideSettingsAttrGrp)
        self.blendBiasAttr = ScalarAttribute('blendBias',
                                             value=0.0,
                                             minValue=0,
                                             maxValue=1.0,
                                             parent=guideSettingsAttrGrp)

        # Guide Controls
        triangleCtrl = Control('triangle', shape='triangle')
        triangleCtrl.rotatePoints(90, 0, 0)
        triangleCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
        triangleCtrl.scalePoints(Vec3(1.0, 0.5, 1.0))
        triangleCtrl.translatePoints(Vec3(0.0, 1.25, 0.0))
        triangleCtrl.rotatePoints(0, 90, 0)

        self.originCtrl = Control('origin',
                                  parent=self.ctrlCmpGrp,
                                  shape='circle')
        self.originCtrl.rotatePoints(90, 0, 0)
        self.originCtrl.rotatePoints(0, 90, 0)
        self.originCtrl.appendCurveData(triangleCtrl.getCurveData())
        self.insertCtrl = Control('insert',
                                  parent=self.ctrlCmpGrp,
                                  shape='circle')
        self.insertCtrl.rotatePoints(90, 0, 0)
        self.insertCtrl.rotatePoints(0, 90, 0)
        self.insertCtrl.appendCurveData(triangleCtrl.getCurveData())

        self.default_data = {
            'name': name,
            'location': 'M',
            'blendBias': 0.5,
            'originXfo': Xfo(Vec3(0.0, 0.0, 0.0)),
            'insertXfo': Xfo(Vec3(5.0, 0.0, 0.0)),
            'numDeformers': 5
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
예제 #3
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        if kObject.isOfAnyType(('Rig', 'Container', 'Layer', 'HierarchyGroup',
                                'ComponentInput', 'ComponentOutput')):
            logger.debug("SyncXfo: Skipping '" + kObject.getName() + "'!")
            return False

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            logger.warning("SyncXfo: 3D Object '" + kObject.getName() +
                           "' was not found in the mapping!")
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            logger.warning("SyncXfo: No DCC Item for :" + kObject.getPath())
            return False

        dccPos = dccItem.GetWorldPosition()
        dccQuat = dccItem.GetWorldRotation()
        dccScl = dccItem.GetWorldScale()

        pos = Vec3(x=dccPos.X, y=dccPos.Y, z=dccPos.Z)
        quat = Quat(v=Vec3(dccQuat.X, dccQuat.Y, dccQuat.Z), w=dccQuat.W)

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(x=dccScl.X, y=dccScl.Y, z=dccScl.Z)
        else:
            scl = Vec3(1.0, 1.0, 1.0)

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)
        rotateUpXfo = Xfo()
        rotateUpXfo.ori = Quat().setFromAxisAndAngle(Vec3(1, 0, 0),
                                                     Math_degToRad(-90))
        newXfo = rotateUpXfo * newXfo

        kObject.xfo = newXfo

        return True
예제 #4
0
    def __init__(self, name='mainSrt', parent=None):

        Profiler.getInstance().push("Construct MainSrt Guide Component:" + name)
        super(MainSrtComponentGuide, self).__init__(name, parent)

        # =========
        # Attributes
        # =========
        # Add Component Params to IK control
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.mainSrtSizeInputAttr = ScalarAttribute('mainSrtSize', value=5.0, minValue=1.0, maxValue=50.0, parent=guideSettingsAttrGrp)

        # =========
        # Controls
        # =========

        # Guide Controls
        self.mainSrtCtrl = Control('mainSrt', parent=self.ctrlCmpGrp, shape="circle")

        data = {
                "location": 'M',
                "mainSrtSize": self.mainSrtSizeInputAttr.getValue(),
                "mainSrtXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0))
               }

        self.loadData(data)

        Profiler.getInstance().pop()
예제 #5
0
    def insertCtrlSpace(self, name=None):
        """Adds a CtrlSpace object above this object

        Args:
            name (string): optional name for this CtrlSpace, default is same as
                this object

        Returns:
            object: New CtrlSpace object

        """

        if name is None:
            name = self.getName()

        newCtrlSpace = CtrlSpace(name, parent=self.getParent())
        if self.getParent() is not None:
            self.getParent().removeChild(self)

        if self.getMetaDataItem("altLocation") is not None:
            newCtrlSpace.setMetaDataItem("altLocation", self.getMetaDataItem("altLocation"))

        self.setParent(newCtrlSpace)
        newCtrlSpace.addChild(self)

        newCtrlSpace.xfo = Xfo(self.xfo)

        # To ensure that names of control spaces don't clash with controls and
        # if they do, set's the control space's name back to what it was intended
        if self.getName() == name:
            newCtrlSpace.setName(name)

        return newCtrlSpace
예제 #6
0
    def loadData(self, data):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(TwistComponentGuide, self).loadData(data)

        self.blendBiasAttr.setValue(data.get('blendBias', 0.0))
        self.originCtrl.xfo = data.get('originXfo', Xfo())
        self.insertCtrl.xfo = data.get('insertXfo', Xfo())
        self.numDeformersAttr.setValue(data.get('numDeformers', 5))

        return True
예제 #7
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct SpineClavRig:" + name)
        super(SpineClavRig, self).__init__(name)

        # Add Components to Layers
        spineComponent = SpineComponentRig("spine", self)
        spineComponent.loadData(
            data={
                'cogPosition': Vec3(0.0, 11.1351, -0.1382),
                'spine01Position': Vec3(0.0, 11.1351, -0.1382),
                'spine02Position': Vec3(0.0, 11.8013, -0.1995),
                'spine03Position': Vec3(0.0, 12.4496, -0.3649),
                'spine04Position': Vec3(0.0, 13.1051, -0.4821),
                'numDeformers': 4
            })

        clavicleLeftComponentGuide = ClavicleComponentGuide("clavicleGuide")
        clavicleLeftComponentGuide.loadData({
            "location":
            "L",
            "clavicleXfo":
            Xfo(Vec3(0.1322, 15.403, -0.5723)),
            "clavicleUpVXfo":
            Xfo(Vec3(0.0, 1.0, 0.0)),
            "clavicleEndXfo":
            Xfo(Vec3(2.27, 15.295, -0.753))
        })

        clavicleLeftComponent = ClavicleComponentRig("clavicle", self)
        clavicleLeftComponent.loadData(
            data=clavicleLeftComponentGuide.getRigBuildData())

        # Clavicle to Spine
        vertebraeOutputs = spineComponent.getOutputByName('spineVertebrae')
        clavicleLeftSpineEndInput = clavicleLeftComponent.getInputByName(
            'spineEnd')
        clavicleLeftSpineEndInput.setConnection(vertebraeOutputs, index=2)

        Profiler.getInstance().pop()
예제 #8
0
        def rt2Py(rtVal, rtType):

            if "[" in rtType:
                return []
            if rtType == "Xfo":
                return Xfo(rtVal)
            if rtType == "Mat44":
                return Mat44(rtVal)
            if rtType == "Vec2":
                return Vec2(rtVal)
            if rtType == "Vec3":
                return Vec3(rtVal)
            else:
                return rtVal.getSimpleType()
예제 #9
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(TwistComponentGuide, self).getRigBuildData()

        data['blendBias'] = self.blendBiasAttr.getValue()

        data['originXfo'] = self.originCtrl.xfo
        data['insertXfo'] = self.insertCtrl.xfo

        originUpVXfo = Xfo(Vec3(0.0, 1.0, 0.0))
        insertUpVXfo = Xfo(Vec3(0.0, 1.0, 0.0))

        data['originUpVXfo'] = self.originCtrl.xfo * originUpVXfo
        data['insertUpVXfo'] = self.insertCtrl.xfo * insertUpVXfo

        data['numDeformers'] = self.numDeformersAttr.getValue()

        return data
예제 #10
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            ogger.warning("SyncXfo: 3D Object '" + kObject.getName() +
                          "' was not found in the mapping!")
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            logger.warning("SyncXfo: Syncing. No DCC Item for :" +
                           kObject.getPath())
            return False

        dccPos = dccItem.getTranslation(space='world')
        dccQuat = dccItem.getRotation(space='world', quaternion=True).get()
        dccScl = dccItem.getScale()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[0], dccQuat[1], dccQuat[2]), w=dccQuat[3])

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])
        else:
            scl = Vec3(1.0, 1.0, 1.0)

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
예제 #11
0
    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(SimpleControlComponentRig, self).loadData(data)

        ctrlSize = data.get('ctrlSize', 1.0)
        ctrlXfo = data.get('ctrlXfo', Xfo())

        # ================
        # Resize Controls
        # ================
        self.mainCtrl.setShape('square')
        self.mainCtrl.rotatePoints(90, 0, 0)
        self.mainCtrl.scalePoints(Vec3(ctrlSize, ctrlSize, ctrlSize))

        # =======================
        # Set Control Transforms
        # =======================
        self.mainCtrlSpace.xfo = ctrlXfo
        self.mainCtrl.xfo = ctrlXfo

        # ============
        # Set IO Xfos
        # ============
        self.mainInputTgt.xfo = ctrlXfo
        self.mainDef.xfo = ctrlXfo
        self.outputTgt.xfo = ctrlXfo

        # ====================
        # Evaluate Constraints
        # ====================
        self.mainInputConstraint.evaluate()
        self.mainOutputConstraint.evaluate()
        self.mainDefConstraint.evaluate()
예제 #12
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            log("Warning! 3D Object '" + kObject.getName() + "' was not found in the mapping!", 8)
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            log("Warning Syncing. No DCC Item for :" + kObject.getPath(), 8)
            return False

        dccXfo = dccItem.Kinematics.Global.GetTransform2(None)
        dccPos = dccXfo.Translation.Get2()
        dccQuat = dccXfo.Rotation.Quaternion.Get2()
        dccScl = dccXfo.Scaling.Get2()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[1], dccQuat[2], dccQuat[3]), w=dccQuat[0])

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(1.0, 1.0, 1.0)
        else:
            scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
예제 #13
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(NeckComponentGuide, self).getRigBuildData()

        neckEndXfo = Xfo(tr=self.neckEndCtrl.xfo.tr,
                         ori=self.neckMidCtrlShape.xfo.ori)

        data['neckXfo'] = self.neckCtrlShape.xfo
        data['neckCrvData'] = self.neckCtrlShape.getCurveData()
        data['neckMidXfo'] = self.neckMidCtrlShape.xfo
        data['neckMidCrvData'] = self.neckMidCtrlShape.getCurveData()
        data['neckEndXfo'] = neckEndXfo

        return data
예제 #14
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            bool: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            print "Warning! 3D Object '" + kObject.getName(
            ) + "' was not found in the mapping!"
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            print "Warning Syncing. No DCC Item for :" + kObject.getPath()
            return

        dccPos = dccItem.getTranslation(space='world')
        dccQuat = dccItem.getRotation(space='world', quaternion=True).get()
        dccScl = dccItem.getScale()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[0], dccQuat[1], dccQuat[2]), w=dccQuat[3])
        scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
예제 #15
0
    def __init__(self, name='SimpleControl', parent=None):

        Profiler.getInstance().push(
            "Construct Simple Control Guide Component:" + name)
        super(SimpleControlComponentGuide, self).__init__(name, parent)

        # =========
        # Attributes
        # =========
        # Add Component Params to IK control
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.ctrlSizeInputAttr = ScalarAttribute('ctrlSize',
                                                 value=5.0,
                                                 minValue=1.0,
                                                 maxValue=50.0,
                                                 parent=guideSettingsAttrGrp)
        self.ctrlSizeInputAttr.setValueChangeCallback(self.resizeMainCtrl)

        # =========
        # Controls
        # =========

        # Guide Controls
        self.mainCtrl = Control('main', parent=self.ctrlCmpGrp, shape='square')
        self.mainCtrl.rotatePoints(90, 0, 0)

        data = {
            "location": 'M',
            "ctrlSize": self.ctrlSizeInputAttr.getValue(),
            "ctrlXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0))
        }

        self.loadData(data)

        Profiler.getInstance().pop()
예제 #16
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BobGuide:" + name)
        super(BobGuide, self).__init__(name)

        # Add Components to Layers
        spineComponent = SpineComponentGuide('spine', self)
        neckComponentGuide = NeckComponentGuide('neck', self)
        headComponent = HeadComponentGuide("head", self)

        clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle", self)
        clavicleLeftComponentGuide.loadData({
            "location": "L",
            "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
            "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
            "clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
        })

        armLeftComponentGuide = ArmComponentGuide("arm", self)
        armLeftComponentGuide.loadData({
            "location": "L",
            "bicepXfo": Xfo(Vec3(2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5})

        clavicleRightComponentGuide = ClavicleComponentGuide("clavicle", self)
        clavicleRightComponentGuide.loadData({
            "location": "R",
            "clavicleXfo": Xfo(Vec3(-0.1322, 15.403, -0.5723)),
            "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
            "clavicleEndXfo": Xfo(Vec3(-2.27, 15.295, -0.753))
        })

        armRightComponentGuide = ArmComponentGuide("arm", self)
        armRightComponentGuide.loadData({
            "location": "R",
            "bicepXfo": Xfo(Vec3(-2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(-5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(-7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        legLeftComponentGuide = LegComponentGuide("leg", self)
        legLeftComponentGuide.loadData({
            "location": "L",
            "femurXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
            "kneeXfo": Xfo(Vec3(1.4488, 5.4418, -0.5348)),
            "ankleXfo": Xfo(Vec3(1.841, 1.1516, -1.237)),
            "toeXfo": Xfo(Vec3(1.85, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(1.85, 0.4, 1.5))
        })

        legRightComponentGuide = LegComponentGuide("leg", self)
        legRightComponentGuide.loadData({
            "location": "R",
            "femurXfo": Xfo(Vec3(-0.9811, 9.769, -0.4572)),
            "kneeXfo": Xfo(Vec3(-1.4488, 5.4418, -0.5348)),
            "ankleXfo": Xfo(Vec3(-1.841, 1.1516, -1.237)),
            "toeXfo": Xfo(Vec3(-1.85, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(-1.85, 0.4, 1.5))
        })

        Profiler.getInstance().pop()
예제 #17
0
from kraken import plugins
from kraken.core.maths import Xfo, Vec3
from kraken_components.biped.leg_component import LegComponentGuide, LegComponentRig

from kraken.core.profiler import Profiler
from kraken.helpers.utility_methods import logHierarchy

Profiler.getInstance().push("leg_build")

legGuide = LegComponentGuide("leg")
legGuide.loadData({
    "name": "Leg",
    "location": "L",
    "createIKHandle": False,
    "femurXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
    "kneeXfo": Xfo(Vec3(1.408, 5.4371, -0.5043)),
    "ankleXfo": Xfo(Vec3(1.75, 1.15, -1.25))
})

# Save the arm guid data for persistence.
saveData = legGuide.saveData()

legGuideData = legGuide.getRigBuildData()

leg = LegComponentRig()
leg.loadData(legGuideData)

builder = plugins.getBuilder()
builder.build(leg)

Profiler.getInstance().pop()
예제 #18
0
     "class": "kraken_components.biped.neck_component.NeckComponentGuide",
     "neckPosition": Vec3(0.0, 16.5572, -0.6915),
     "neckEndPosition": Vec3(0.0, 17.4756, -0.421)
 }, {
     "class": "kraken_components.biped.head_component.HeadComponentGuide",
     "headPosition": Vec3(0.0, 17.4756, -0.421),
     "headEndPosition": Vec3(0.0, 19.5, -0.421),
     "eyeLeftPosition": Vec3(0.3497, 18.0878, 0.6088),
     "eyeRightPosition": Vec3(-0.3497, 18.0878, 0.6088),
     "jawPosition": Vec3(0.0, 17.613, -0.2731)
 }, {
     "class":
     "kraken_components.biped.clavicle_component.ClavicleComponentGuide",
     "name": "Clavicle",
     "location": "L",
     "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
     "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
     "clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
 }, {
     "class":
     "kraken_components.biped.clavicle_component.ClavicleComponentGuide",
     "name": "Clavicle",
     "location": "R",
     "clavicleXfo": Xfo(Vec3(-0.1322, 15.403, -0.5723)),
     "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
     "clavicleEndXfo": Xfo(Vec3(-2.27, 15.295, -0.753))
 }, {
     "class":
     "kraken_components.biped.arm_component.ArmComponentGuide",
     "name":
     "Arm",
예제 #19
0
    def __init__(self, name='neck', parent=None, *args, **kwargs):

        Profiler.getInstance().push('Construct Neck Component:' + name)
        super(NeckComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # =========

        # Guide Controls
        self.neckCtrl = Control('neck', parent=self.ctrlCmpGrp, shape='sphere')
        self.neckCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckMidCtrl = Control('neckMid',
                                   parent=self.ctrlCmpGrp,
                                   shape='sphere')
        self.neckMidCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckEndCtrl = Control('neckEnd',
                                   parent=self.ctrlCmpGrp,
                                   shape='sphere')
        self.neckEndCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.neckCtrlShape = Control('neck',
                                     parent=self.ctrlCmpGrp,
                                     shape='pin')
        self.neckCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckCtrlShape.setColor('orange')
        self.neckMidCtrlShape = Control('neckMid',
                                        parent=self.ctrlCmpGrp,
                                        shape='pin')
        self.neckMidCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckMidCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckMidCtrlShape.setColor('orange')

        # Guide Operator
        self.neckGuideKLOp = KLOperator(name + 'GuideKLOp', 'NeckGuideSolver',
                                        'Kraken')
        self.addOperator(self.neckGuideKLOp)

        # Add Att Inputs
        self.neckGuideKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.neckGuideKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Source Inputs
        self.neckGuideKLOp.setInput(
            'sources', [self.neckCtrl, self.neckMidCtrl, self.neckEndCtrl])

        # Add Target Outputs
        self.neckGuideKLOp.setOutput(
            'targets', [self.neckCtrlShape, self.neckMidCtrlShape])

        # Calculate default values
        neckVec = Vec3(0.0, 16.00, -0.75)
        neckMidVec = Vec3(0.0, 16.50, -0.50)
        neckEndVec = Vec3(0.0, 17.00, -0.25)
        upVector = Vec3(0.0, 0.0, -1.0)

        neckOri = Quat()
        neckOri.setFromDirectionAndUpvector(
            (neckMidVec - neckVec).unit(),
            ((neckVec + upVector) - neckVec).unit())

        neckMidOri = Quat()
        neckMidOri.setFromDirectionAndUpvector(
            (neckEndVec - neckMidVec).unit(),
            ((neckMidVec + upVector) - neckMidVec).unit())

        self.default_data = {
            "name": name,
            "location": "M",
            "neckXfo": Xfo(tr=neckVec, ori=neckOri),
            "neckMidXfo": Xfo(tr=neckMidVec, ori=neckMidOri),
            "neckEndXfo": Xfo(tr=neckEndVec, ori=neckMidOri),
            "neckCrvData": self.neckCtrlShape.getCurveData(),
            "neckMidCrvData": self.neckMidCtrlShape.getCurveData()
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
예제 #20
0
from kraken import plugins
from kraken.core.maths import Xfo, Vec3, Quat

from kraken_examples.mainSrt_component import MainSrtComponentGuide, MainSrtComponentRig

from kraken.core.profiler import Profiler
from kraken.helpers.utility_methods import logHierarchy


Profiler.getInstance().push("mainSrt_build")

mainSrtGuide = MainSrtComponentGuide("mainSrt")
mainSrtGuide.loadData({
                      "name": "mainSrt",
                      "location": "M",
                      "mainSrtXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0)),
                      "mainSrtSize": 3.0
                     })

# Save the main srt guide data for persistence.
saveData = mainSrtGuide.saveData()

mainSrtGuideData = mainSrtGuide.getRigBuildData()

mainSrt = MainSrtComponentRig()
mainSrt.loadData(mainSrtGuideData)

builder = plugins.getBuilder()
builder.build(mainSrt)

Profiler.getInstance().pop()
예제 #21
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BipedGuideRig:" + name)
        super(BipedGuideRig, self).__init__(name)

        # ===========
        # Components
        # ===========
        mainSrtComponentGuide = MainSrtComponentGuide('mainSrt', parent=self)
        spineComponentGuide = SpineComponentGuide('spine', parent=self)
        neckComponentGuide = NeckComponentGuide('neck', parent=self)
        headComponentGuide = HeadComponentGuide('head', parent=self)

        clavicleLeftComponentGuide = ClavicleComponentGuide('clavicle', parent=self)
        clavicleRightComponentGuide = ClavicleComponentGuide('clavicle', parent=self)
        clavicleRightComponentGuide.loadData({
            "name": 'clavicle',
            "location": 'R',
            "clavicleXfo": Xfo(Vec3(-0.15, 15.5, -0.5)),
            "clavicleUpVXfo": Xfo(Vec3(-0.15, 16.5, -0.5)),
            "clavicleEndXfo": Xfo(Vec3(-2.25, 15.5, -0.75))
        })


        armLeftComponentGuide = ArmComponentGuide('arm', parent=self)
        armRightComponentGuide = ArmComponentGuide('arm', parent=self)
        armRightComponentGuide.loadData({
            "name": 'arm',
            "location": 'R',
            "bicepXfo": Xfo(Vec3(-2.275, 15.3, -0.75)),
            "forearmXfo": Xfo(Vec3(-5.0, 13.5, -0.75)),
            "wristXfo": Xfo(Vec3(-7.2, 12.25, 0.5)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        handLeftComponentGuide = HandComponentGuide('hand', parent=self)
        handRightComponentGuide = HandComponentGuide('hand', parent=self)

        handRightOri = Quat()
        handRightOri.setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(180))

        handRightComponentGuide.loadData({
            "name": 'hand',
            "location": 'R',
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906), ori=handRightOri),
            "digitNames": "thumb,index,middle,ring,pinky",
            "numJoints": 4,
            "fingersGuideXfos": {
                "pinky": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri)
                ],
                "index": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri)
                ],
                "ring": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri)
                ],
                "thumb": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri)
                ],
                "middle": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri)
                ]
            }
        })

        legLeftComponentGuide = LegComponentGuide('leg', parent=self)
        legRightComponentGuide = LegComponentGuide('leg', parent=self)
        legRightComponentGuide.loadData({
            "name": 'leg',
            "location": 'R',
            "createIKHandle": False,
            "femurXfo": Xfo(Vec3(-1.0, 9.75, -0.5)),
            "kneeXfo": Xfo(Vec3(-1.5, 5.5, -0.5)),
            "ankleXfo": Xfo(Vec3(-1.75, 1.15, -1.25))
        })

        footLeftComponentGuide = FootComponentGuide('foot', parent=self)
        footRightComponentGuide = FootComponentGuide('foot', parent=self)
        footRightComponentGuide.loadData({
            "name": 'foot',
            "location": 'R',
            'ankleXfo': Xfo(Vec3(-1.75, 1.15, -1.25)),
            'toeXfo': Xfo(Vec3(-1.75, 0.4, 0.25)),
            'toeTipXfo': Xfo(Vec3(-1.75, 0.4, 1.5)),
            'backPivotXfo': Xfo(Vec3(-1.75, 0.0, -2.5)),
            'frontPivotXfo': Xfo(Vec3(-1.75, 0.0, 2.0)),
            'outerPivotXfo': Xfo(Vec3(-2.5, 0.0, -1.25)),
            'innerPivotXfo': Xfo(Vec3(-1.0, 0.0, -1.25))
        })

        # ============
        # Connections
        # ============

        # =======
        # Outputs
        # =======
        mainSrtRigScaleOutput = mainSrtComponentGuide.getOutputByName('rigScale')
        mainSrtOffsetOutput = mainSrtComponentGuide.getOutputByName('offset')
        spineEndOutput = spineComponentGuide.getOutputByName('spineEnd')
        neckEndOutput = neckComponentGuide.getOutputByName('neckEnd')
        clavicleLeftEndOutput = clavicleLeftComponentGuide.getOutputByName('clavicleEnd')
        clavicleRightEndOutput = clavicleRightComponentGuide.getOutputByName('clavicleEnd')
        spinePelvisOutput = spineComponentGuide.getOutputByName('pelvis')

        # Arm Left
        armLeftWristOutput = armLeftComponentGuide.getOutputByName('wrist')

        # Arm Right
        armRightWristOutput = armRightComponentGuide.getOutputByName('wrist')

        # Leg Left
        legLeftIkHandleOutput = legLeftComponentGuide.getOutputByName('ikHandle')
        legLeftLegEndOutput = legLeftComponentGuide.getOutputByName('legEnd')
        legLeftLegEndFKOutput = legLeftComponentGuide.getOutputByName('legEndFK')

        # Leg Right
        legRightIkHandleOutput = legRightComponentGuide.getOutputByName('ikHandle')
        legRightLegEndOutput = legRightComponentGuide.getOutputByName('legEnd')
        legRightLegEndFKOutput = legRightComponentGuide.getOutputByName('legEndFK')

        # Foot Left
        footLeftIkTargetOutput = footLeftComponentGuide.getOutputByName('ikTarget')

        # Foot Right
        footRightIkTargetOutput = footRightComponentGuide.getOutputByName('ikTarget')

        # =========================
        # Inputs & Set Connections
        # =========================
        # Spine
        spineGlobalSrtInput = spineComponentGuide.getInputByName('globalSRT')
        spineGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        spineRigScaleInput = spineComponentGuide.getInputByName('rigScale')
        spineRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Neck
        neckGlobalSrtInput = neckComponentGuide.getInputByName('globalSRT')
        neckGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        neckSpineEndInput = neckComponentGuide.getInputByName('neckBase')
        neckSpineEndInput.setConnection(spineEndOutput)

        # Head
        headGlobalSrtInput = headComponentGuide.getInputByName('globalSRT')
        headGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        headBaseInput = headComponentGuide.getInputByName('neckRef')
        headBaseInput.setConnection(neckEndOutput)

        headBaseInput = headComponentGuide.getInputByName('worldRef')
        headBaseInput.setConnection(mainSrtOffsetOutput)

        # Clavicle Left
        clavicleLeftGlobalSrtInput = clavicleLeftComponentGuide.getInputByName('globalSRT')
        clavicleLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        clavicleLeftSpineEndInput = clavicleLeftComponentGuide.getInputByName('spineEnd')
        clavicleLeftSpineEndInput.setConnection(spineEndOutput)

        # Clavicle Right
        clavicleRightGlobalSrtInput = clavicleRightComponentGuide.getInputByName('globalSRT')
        clavicleRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        clavicleRightSpineEndInput = clavicleRightComponentGuide.getInputByName('spineEnd')
        clavicleRightSpineEndInput.setConnection(spineEndOutput)

        # Arm Left
        armLeftGlobalSrtInput = armLeftComponentGuide.getInputByName('globalSRT')
        armLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        armLeftRigScaleInput = armLeftComponentGuide.getInputByName('rigScale')
        armLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armLeftClavicleEndInput = armLeftComponentGuide.getInputByName('root')
        armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput)

        # Arm Right
        armRightGlobalSrtInput = armRightComponentGuide.getInputByName('globalSRT')
        armRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        armRightRigScaleInput = armRightComponentGuide.getInputByName('rigScale')
        armRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armRightClavicleEndInput = armRightComponentGuide.getInputByName('root')
        armRightClavicleEndInput.setConnection(clavicleRightEndOutput)

        # Hand Left
        handLeftGlobalSrtInput = handLeftComponentGuide.getInputByName('globalSRT')
        handLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        handLeftArmEndInput = handLeftComponentGuide.getInputByName('armEnd')
        handLeftArmEndInput.setConnection(armLeftWristOutput)

        # Hand Right
        handRightGlobalSrtInput = handRightComponentGuide.getInputByName('globalSRT')
        handRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        handRightArmEndInput = handRightComponentGuide.getInputByName('armEnd')
        handRightArmEndInput.setConnection(armRightWristOutput)

        # Leg Left
        legLeftGlobalSrtInput = legLeftComponentGuide.getInputByName('globalSRT')
        legLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        legLeftRigScaleInput = legLeftComponentGuide.getInputByName('rigScale')
        legLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legLeftPelvisInput = legLeftComponentGuide.getInputByName('pelvisInput')
        legLeftPelvisInput.setConnection(spinePelvisOutput)

        legLeftPelvisInput = legLeftComponentGuide.getInputByName('ikTarget')
        legLeftPelvisInput.setConnection(footLeftIkTargetOutput)

        # Leg Right
        legRightGlobalSrtInput = legRightComponentGuide.getInputByName('globalSRT')
        legRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        legRightRigScaleInput = legRightComponentGuide.getInputByName('rigScale')
        legRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legRightPelvisInput = legRightComponentGuide.getInputByName('pelvisInput')
        legRightPelvisInput.setConnection(spinePelvisOutput)

        legRightPelvisInput = legRightComponentGuide.getInputByName('ikTarget')
        legRightPelvisInput.setConnection(footRightIkTargetOutput)

        # Foot Left
        footLeftGlobalSrtInput = footLeftComponentGuide.getInputByName('globalSRT')
        footLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        footLeftIkHandleInput = footLeftComponentGuide.getInputByName('ikHandle')
        footLeftIkHandleInput.setConnection(legLeftIkHandleOutput)

        footLeftLegEndInput = footLeftComponentGuide.getInputByName('legEnd')
        footLeftLegEndInput.setConnection(legLeftLegEndOutput)

        footLeftLegEndFKInput = footLeftComponentGuide.getInputByName('legEndFK')
        footLeftLegEndFKInput.setConnection(legLeftLegEndFKOutput)


        # Foot Right
        footRightGlobalSrtInput = footRightComponentGuide.getInputByName('globalSRT')
        footRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        footRightIkHandleInput = footRightComponentGuide.getInputByName('ikHandle')
        footRightIkHandleInput.setConnection(legRightIkHandleOutput)

        footRightLegEndInput = footRightComponentGuide.getInputByName('legEnd')
        footRightLegEndInput.setConnection(legRightLegEndOutput)

        footRightLegEndFKInput = footRightComponentGuide.getInputByName('legEndFK')
        footRightLegEndFKInput.setConnection(legRightLegEndFKOutput)

        Profiler.getInstance().pop()
예제 #22
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BobRig:" + name)
        super(BobRig, self).__init__(name)

        # Add Components
        mainSrtComponent = MainSrtComponentRig("mainSrt", self)

        spineComponent = SpineComponentRig("spine", self)
        spineComponent.loadData(data={
            'cogPosition': Vec3(0.0, 11.1351, -0.1382),
            'spine01Position': Vec3(0.0, 11.1351, -0.1382),
            'spine02Position': Vec3(0.0, 11.8013, -0.1995),
            'spine03Position': Vec3(0.0, 12.4496, -0.3649),
            'spine04Position': Vec3(0.0, 13.1051, -0.4821),
            'numDeformers': 4
        })

        neckComponentGuide = NeckComponentGuide(data={
            "location": "M",
            "neckPosition": Vec3(0.0, 16.5572, -0.6915),
            "neckEndPosition": Vec3(0.0, 17.4756, -0.421)
        })

        neckComponent = NeckComponentRig("neck", self)
        neckComponent.loadData(data=neckComponentGuide.getRigBuildData())

        headComponent = HeadComponentRig("head", self)
        headComponent.loadData(data={
            "headPosition": Vec3(0.0, 17.4756, -0.421),
            "headEndPosition": Vec3(0.0, 19.5, -0.421),
            "eyeLeftPosition": Vec3(0.3497, 18.0878, 0.6088),
            "eyeRightPosition": Vec3(-0.3497, 18.0878, 0.6088),
            "jawPosition": Vec3(0.0, 17.613, -0.2731)
        })

        clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle", data={
            "location": "L",
            "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
            "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
            "clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
        })

        clavicleLeftComponent = ClavicleComponentRig("clavicle", self)
        clavicleLeftComponent.loadData(data=clavicleLeftComponentGuide.getRigBuildData())

        clavicleRightComponentGuide = ClavicleComponentGuide("clavicle", data={
            "location": "R",
            "clavicleXfo": Xfo(Vec3(-0.1322, 15.403, -0.5723)),
            "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
            "clavicleEndXfo": Xfo(Vec3(-2.27, 15.295, -0.753))
        })

        clavicleRightComponent = ClavicleComponentRig("clavicle", self)
        clavicleRightComponent.loadData(data=clavicleRightComponentGuide.getRigBuildData())

        armLeftComponentGuide = ArmComponentGuide("arm")
        armLeftComponentGuide.loadData({
            "location":"L",
            "bicepXfo": Xfo(Vec3(2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        armLeftComponent = ArmComponentRig("arm", self)
        armLeftComponent.loadData(data=armLeftComponentGuide.getRigBuildData())

        armRightComponentGuide = ArmComponentGuide("arm")
        armRightComponentGuide.loadData({
            "location":"R",
            "bicepXfo": Xfo(Vec3(-2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(-5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(-7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        armRightComponent = ArmComponentRig("arm", self)
        armRightComponent.loadData(data=armRightComponentGuide.getRigBuildData() )

        legLeftComponentGuide = LegComponentGuide("leg")
        legLeftComponentGuide.loadData({
            "name":"Leg",
            "location": "L",
            "femurXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
            "kneeXfo": Xfo(Vec3(1.4488, 5.4418, -0.5348)),
            "ankleXfo": Xfo(Vec3(1.841, 1.1516, -1.237)),
            "toeXfo": Xfo(Vec3(1.85, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(1.85, 0.4, 1.5))
        })

        legLeftComponent = LegComponentRig("leg", self)
        legLeftComponent.loadData(data=legLeftComponentGuide.getRigBuildData())

        legRightComponentGuide = LegComponentGuide("leg")
        legRightComponentGuide.loadData({
            "name":"Leg",
            "location": "R",
            "femurXfo": Xfo(Vec3(-0.9811, 9.769, -0.4572)),
            "kneeXfo": Xfo(Vec3(-1.4488, 5.4418, -0.5348)),
            "ankleXfo": Xfo(Vec3(-1.85, 1.1516, -1.237)),
            "toeXfo": Xfo(Vec3(-1.85, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(-1.85, 0.4, 1.5))
        })

        legRightComponent = LegComponentRig("leg", self)
        legRightComponent.loadData(data=legRightComponentGuide.getRigBuildData() )

        # ============
        # Connections
        # ============
        # Spine to Main SRT
        mainSrtRigScaleOutput = mainSrtComponent.getOutputByName('rigScale')
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        spineInput = spineComponent.getInputByName('mainSrt')
        spineInput.setConnection(mainSrtOffsetOutput)

        spineRigScaleInput = spineComponent.getInputByName('rigScale')
        spineRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Neck to Spine
        spineEndOutput = spineComponent.getOutputByName('spineEnd')
        neckSpineEndInput = neckComponent.getInputByName('neckBase')
        neckSpineEndInput.setConnection(spineEndOutput)

        # Head to Neck
        neckEndOutput = neckComponent.getOutputByName('neckEnd')
        headBaseInput = headComponent.getInputByName('headBase')
        headBaseInput.setConnection(neckEndOutput)

        # Clavicle to Spine
        spineEndOutput = spineComponent.getOutputByName('spineEnd')
        clavicleLeftSpineEndInput = clavicleLeftComponent.getInputByName('spineEnd')
        clavicleLeftSpineEndInput.setConnection(spineEndOutput)
        clavicleRightSpineEndInput = clavicleRightComponent.getInputByName('spineEnd')
        clavicleRightSpineEndInput.setConnection(spineEndOutput)

        # Arm to Global SRT
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        armLeftGlobalSRTInput = armLeftComponent.getInputByName('globalSRT')
        armLeftGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        armLeftRigScaleInput = armLeftComponent.getInputByName('rigScale')
        armLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armRightGlobalSRTInput = armRightComponent.getInputByName('globalSRT')
        armRightGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        armRightRigScaleInput = armRightComponent.getInputByName('rigScale')
        armRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Arm To Clavicle Connections
        clavicleLeftEndOutput = clavicleLeftComponent.getOutputByName('clavicleEnd')
        armLeftClavicleEndInput = armLeftComponent.getInputByName('clavicleEnd')
        armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput)
        clavicleRightEndOutput = clavicleRightComponent.getOutputByName('clavicleEnd')
        armRightClavicleEndInput = armRightComponent.getInputByName('clavicleEnd')
        armRightClavicleEndInput.setConnection(clavicleRightEndOutput)

        # Leg to Global SRT
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        legLeftGlobalSRTInput = legLeftComponent.getInputByName('globalSRT')
        legLeftGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        legLeftRigScaleInput = legLeftComponent.getInputByName('rigScale')
        legLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legRightGlobalSRTInput = legRightComponent.getInputByName('globalSRT')
        legRightGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        legRightRigScaleInput = legRightComponent.getInputByName('rigScale')
        legRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Leg To Pelvis Connections
        spinePelvisOutput = spineComponent.getOutputByName('pelvis')
        legLeftPelvisInput = legLeftComponent.getInputByName('pelvisInput')
        legLeftPelvisInput.setConnection(spinePelvisOutput)
        legRightPelvisInput = legRightComponent.getInputByName('pelvisInput')
        legRightPelvisInput.setConnection(spinePelvisOutput)

        Profiler.getInstance().pop()
예제 #23
0
from kraken import plugins
from kraken.core.maths import Xfo, Vec3, Quat

from kraken_examples.arm_component import ArmComponentGuide, ArmComponentRig

from kraken.helpers.utility_methods import logHierarchy

leftArmGuide = ArmComponentGuide('arm')
leftArmGuide.loadData({
    'name':
    'Arm',
    'location':
    'L',
    'bicepXfo':
    Xfo(Vec3(2.27, 15.295, -0.753)),
    'forearmXfo':
    Xfo(Vec3(5.039, 13.56, -0.859)),
    'wristXfo':
    Xfo(Vec3(7.1886, 12.2819, 0.4906)),
    'handXfo':
    Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
        ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
    'bicepFKCtrlSize':
    1.75,
    'forearmFKCtrlSize':
    1.5
})

# Save the arm guid data for persistence.
rightArmGuide = ArmComponentGuide('arm')
예제 #24
0
siRot = XSIMath.CreateRotation()
siRot.SetFromMatrix3(siMat33)

siXfo.SetRotation(siRot)

siNull = si.ActiveProject3.ActiveScene.Root.AddNull("myNull")
siNull.Kinematics.Global.PutTransform2(None, siXfo)


# =====================
# Build through kraken
# =====================
builder = plugins.getBuilder()

config = builder.getConfig()
config.setExplicitNaming(True)

myXfo = Xfo()

myMat33 = Mat33()
myMat33.setColumns(Vec3(0.7071, 0.0, 0.7071), Vec3(0.5, 0.7071, -0.5), Vec3(-0.5, 0.7071, 0.50))

myQuat = Quat()
newQuat = myQuat.setFromMat33(myMat33)
myXfo.ori = newQuat

myLoc = Locator("myLocator")
myLoc.xfo = myXfo

builder.build(myLoc)
예제 #25
0
from kraken import plugins
from kraken.core.maths import Xfo, Vec3, Quat
from kraken.core.profiler import Profiler
from kraken_examples.clavicle_component import ClavicleComponentGuide, ClavicleComponentRig
from kraken.helpers.utility_methods import logHierarchy
import json


Profiler.getInstance().push("clavicle_build")

clavicleGuide = ClavicleComponentGuide("clavicle")
clavicleGuide.loadData({
        "name": "Clavicle",
        "location": "L",
        "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
        "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
        "clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
    })

# Save the clavicle guid data for persistence.
saveData = clavicleGuide.saveData()

clavicleGuideData = clavicleGuide.getRigBuildData()

clavicle = ClavicleComponentRig()
clavicle.loadData(clavicleGuideData)

builder = plugins.getBuilder()
builder.build(clavicle)
예제 #26
0
import json

from kraken import plugins
from kraken.core.maths import Xfo, Vec3, Quat
from kraken_examples.leg_component import LegComponentGuide, LegComponentRig

from kraken.core.profiler import Profiler
from kraken.helpers.utility_methods import logHierarchy

Profiler.getInstance().push("leg_build")

legGuide = LegComponentGuide("leg")
legGuide.loadData({
    "name": "Leg",
    "location": "L",
    "femurXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
    "kneeXfo": Xfo(Vec3(1.4488, 5.4418, -0.5348)),
    "ankleXfo": Xfo(Vec3(1.85, 1.1516, -1.237)),
    "toeXfo": Xfo(Vec3(1.85, 0.4, 0.25)),
    "toeTipXfo": Xfo(Vec3(1.85, 0.4, 1.5))
})

# Save the arm guid data for persistence.
saveData = legGuide.saveData()

legGuideData = legGuide.getRigBuildData()

leg = LegComponentRig()
leg.loadData(legGuideData)

builder = plugins.getBuilder()