Ejemplo n.º 1
0
class FabriceHeadRig(FabriceHead):
    """Fabrice Head Component Rig"""
    def __init__(self, name='head', parent=None):

        Profiler.getInstance().push("Construct Head Rig Component:" + name)
        super(FabriceHeadRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Head Aim
        self.headAimCtrlSpace = CtrlSpace('headAim', parent=self.ctrlCmpGrp)
        self.headAimCtrl = Control('headAim',
                                   parent=self.headAimCtrlSpace,
                                   shape="sphere")
        self.headAimCtrl.scalePoints(Vec3(0.35, 0.35, 0.35))
        self.headAimCtrl.lockScale(x=True, y=True, z=True)

        self.headAimUpV = Locator('headAimUpV', parent=self.headAimCtrl)
        self.headAimUpV.setShapeVisibility(False)

        # Head
        self.headAim = Locator('headAim', parent=self.ctrlCmpGrp)
        self.headAim.setShapeVisibility(False)

        self.headCtrlSpace = CtrlSpace('head', parent=self.ctrlCmpGrp)
        self.headCtrl = Control('head',
                                parent=self.headCtrlSpace,
                                shape="circle")
        self.headCtrl.lockTranslation(x=True, y=True, z=True)
        self.headCtrl.lockScale(x=True, y=True, z=True)

        # Jaw
        self.jawCtrlSpace = CtrlSpace('jawCtrlSpace', parent=self.headCtrl)
        self.jawCtrl = Control('jaw', parent=self.jawCtrlSpace, shape="cube")
        self.jawCtrl.lockTranslation(x=True, y=True, z=True)
        self.jawCtrl.lockScale(x=True, y=True, z=True)
        self.jawCtrl.setColor("orange")

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        headDef = Joint('head', parent=defCmpGrp)
        headDef.setComponent(self)

        jawDef = Joint('jaw', parent=defCmpGrp)
        jawDef.setComponent(self)

        # ==============
        # Constrain I/O
        # ==============
        self.headToAimConstraint = PoseConstraint('_'.join(
            [self.headCtrlSpace.getName(), 'To',
             self.headAim.getName()]))
        self.headToAimConstraint.setMaintainOffset(True)
        self.headToAimConstraint.addConstrainer(self.headAim)
        self.headCtrlSpace.addConstraint(self.headToAimConstraint)

        # Constraint inputs
        self.headAimInputConstraint = PoseConstraint('_'.join([
            self.headAimCtrlSpace.getName(), 'To',
            self.headBaseInputTgt.getName()
        ]))
        self.headAimInputConstraint.setMaintainOffset(True)
        self.headAimInputConstraint.addConstrainer(self.headBaseInputTgt)
        self.headAimCtrlSpace.addConstraint(self.headAimInputConstraint)

        # # Constraint outputs
        self.headOutputConstraint = PoseConstraint('_'.join(
            [self.headOutputTgt.getName(), 'To',
             self.headCtrl.getName()]))
        self.headOutputConstraint.addConstrainer(self.headCtrl)
        self.headOutputTgt.addConstraint(self.headOutputConstraint)

        self.jawOutputConstraint = PoseConstraint('_'.join(
            [self.jawOutputTgt.getName(), 'To',
             self.jawCtrl.getName()]))
        self.jawOutputConstraint.addConstrainer(self.jawCtrl)
        self.jawOutputTgt.addConstraint(self.jawOutputConstraint)

        # ==============
        # Add Operators
        # ==============

        # Add Aim Canvas Op
        # =================
        self.headAimCanvasOp = CanvasOperator(
            'headAimCanvasOp', 'Kraken.Solvers.DirectionConstraintSolver')
        self.addOperator(self.headAimCanvasOp)

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

        # Add Xfo Inputs
        self.headAimCanvasOp.setInput('position', self.headBaseInputTgt)
        self.headAimCanvasOp.setInput('upVector', self.headAimUpV)
        self.headAimCanvasOp.setInput('atVector', self.headAimCtrl)

        # Add Xfo Outputs
        self.headAimCanvasOp.setOutput('constrainee', self.headAim)

        # Add Deformer KL Op
        # ==================
        self.deformersToOutputsKLOp = KLOperator('headDeformerKLOp',
                                                 'MultiPoseConstraintSolver',
                                                 'Kraken')
        self.addOperator(self.deformersToOutputsKLOp)

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

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setInput(
            'constrainers', [self.headOutputTgt, self.jawOutputTgt])

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees',
                                              [headDef, jawDef])

        Profiler.getInstance().pop()

    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(FabriceHeadRig, self).loadData(data)

        headXfo = data['headXfo']
        headCtrlCrvData = data['headCtrlCrvData']
        jawPosition = data['jawPosition']
        jawCtrlCrvData = data['jawCtrlCrvData']

        self.headAimCtrlSpace.xfo.ori = headXfo.ori
        self.headAimCtrlSpace.xfo.tr = headXfo.tr.add(Vec3(0, 0, 4))
        self.headAimCtrl.xfo = self.headAimCtrlSpace.xfo

        self.headAimUpV.xfo.ori = self.headAimCtrl.xfo.ori
        self.headAimUpV.xfo.tr = self.headAimCtrl.xfo.tr.add(Vec3(0, 3, 0))

        self.headAim.xfo = headXfo
        self.headCtrlSpace.xfo = headXfo
        self.headCtrl.xfo = headXfo
        self.headCtrl.setCurveData(headCtrlCrvData)

        self.jawCtrlSpace.xfo.tr = jawPosition
        self.jawCtrl.xfo.tr = jawPosition
        self.jawCtrl.setCurveData(jawCtrlCrvData)

        # ============
        # Set IO Xfos
        # ============
        self.headBaseInputTgt.xfo = headXfo
        self.headOutputTgt.xfo = headXfo
        self.jawOutputTgt.xfo.tr = jawPosition

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the constraint op so that all the joint transforms are updated.
        self.headAimCanvasOp.evaluate()
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.headToAimConstraint.evaluate()
        self.headAimInputConstraint.evaluate()
        self.headOutputConstraint.evaluate()
        self.jawOutputConstraint.evaluate()
Ejemplo n.º 2
0
class mjEyelidComponentRig(mjEyelidComponent):
    """Eyelid Component Rig"""
    def __init__(self, name='mjEyelid', parent=None):
        Profiler.getInstance().push("Construct Eyelid Rig Component:" + name)
        super(mjEyelidComponentRig, self).__init__(name, parent)

        # =========
        # Controls // Get the Guide Xfos data and create the final controllers, offset them if needed.
        # =========

        # Inputs
        self.eyelidCtrlSpace = CtrlSpace('eyelid', parent=self.ctrlCmpGrp)

        self.eyeballLocator = Locator('eyeball', parent=self.ctrlCmpGrp)
        self.eyeballLocator.setShapeVisibility(False)

        self.eyelidUpVLocator = Locator('eyelid_Upv',
                                        parent=self.eyelidCtrlSpace)
        self.eyelidUpVLocator.setShapeVisibility(False)

        # Lid Sides
        self.lidMedialLocator = Locator('lid_Medial',
                                        parent=self.eyelidCtrlSpace)
        self.lidMedialLocator.setShapeVisibility(False)

        self.lidLateralLocator = Locator('lid_Lateral',
                                         parent=self.eyelidCtrlSpace)
        self.lidLateralLocator.setShapeVisibility(False)

        # Lid Upper
        self.lidUpCtrlSpace = CtrlSpace('lid_Up', parent=self.eyelidCtrlSpace)
        self.lidUpCtrl = Control('lid_Up',
                                 parent=self.lidUpCtrlSpace,
                                 shape="cube")
        self.lidUpCtrl.scalePoints(Vec3(0.05, 0.05, 0.05))
        self.lidUpCtrl.lockTranslation(x=True, y=False, z=True)
        self.lidUpCtrl.setColor("yellow")

        self.lipUpMedialLocator = Locator('lid_Up_Medial',
                                          parent=self.eyelidCtrlSpace)
        self.lipUpMedialLocator.setShapeVisibility(False)
        self.lipUpLateralLocator = Locator('lid_Up_Lateral',
                                           parent=self.eyelidCtrlSpace)
        self.lipUpLateralLocator.setShapeVisibility(False)

        # Lid Lower
        self.lidLowCtrlSpace = CtrlSpace('lid_Low',
                                         parent=self.eyelidCtrlSpace)
        self.lidLowCtrl = Control('lid_Low',
                                  parent=self.lidLowCtrlSpace,
                                  shape="cube")
        self.lidLowCtrl.scalePoints(Vec3(0.05, 0.05, 0.05))
        self.lidLowCtrl.lockTranslation(x=True, y=False, z=True)
        self.lidLowCtrl.setColor("yellow")

        self.lidLowMedialLocator = Locator('lid_Low_Medial',
                                           parent=self.eyelidCtrlSpace)
        self.lidLowMedialLocator.setShapeVisibility(False)
        self.lidLowLateralLocator = Locator('lid_Low_Lateral',
                                            parent=self.eyelidCtrlSpace)
        self.lidLowLateralLocator.setShapeVisibility(False)

        # Lid Attributes
        lidUp_AttrGrp = AttributeGroup("Eyelid_Settings",
                                       parent=self.lidUpCtrl)
        lidLow_AttrGrp = AttributeGroup("Eyelid_Settings",
                                        parent=self.lidLowCtrl)

        self.lidUp_OffsetInputAttr = BoolAttribute('Eyeball_Offset',
                                                   value=True,
                                                   parent=lidUp_AttrGrp)
        self.lidUp_FollowFactorInputAttr = ScalarAttribute(
            'Eyeball_Follow_Factor', value=1.0, parent=lidUp_AttrGrp)
        self.lidUp_DebugInputAttr = BoolAttribute('DrawDebug',
                                                  value=False,
                                                  parent=lidUp_AttrGrp)
        self.lidUp_MedialBlinkInputAttr = ScalarAttribute(
            'Medial_Blink_Factor', value=0.25, parent=lidUp_AttrGrp)
        self.lidUp_LateralBlinkInputAttr = ScalarAttribute(
            'Lateral_Blink_Factor', value=0.65, parent=lidUp_AttrGrp)
        self.lidUp_DefCountInputAttr = IntegerAttribute('numDeformers',
                                                        value=10,
                                                        parent=lidUp_AttrGrp)

        self.lidLow_OffsetInputAttr = BoolAttribute('Eyeball_Offset',
                                                    value=True,
                                                    parent=lidLow_AttrGrp)
        self.lidLow_FollowFactorInputAttr = ScalarAttribute(
            'Eyeball_Follow_Factor', value=0.8, parent=lidLow_AttrGrp)
        self.lidLow_DebugInputAttr = BoolAttribute('DrawDebug',
                                                   value=False,
                                                   parent=lidLow_AttrGrp)
        self.lidLow_MedialBlinkInputAttr = ScalarAttribute(
            'Medial_Blink_Factor', value=0.25, parent=lidLow_AttrGrp)
        self.lidLow_LateralBlinkInputAttr = ScalarAttribute(
            'Lateral_Blink_Factor', value=0.65, parent=lidLow_AttrGrp)
        self.lidLow_DefCountInputAttr = IntegerAttribute('numDeformers',
                                                         value=10,
                                                         parent=lidLow_AttrGrp)

        self.lidUp_DebugInputAttr.connect(self.drawDebugInputAttr)
        self.lidLow_DebugInputAttr.connect(self.drawDebugInputAttr)
        self.lidUp_DefCountInputAttr.connect(self.numUpDeformersInputAttr)
        self.lidLow_DefCountInputAttr.connect(self.numLowDeformersInputAttr)

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(),
                                        self,
                                        parent=deformersLayer)

        # Lid Sides
        lidMedialDef = Joint('lid_Medial', parent=self.defCmpGrp)
        lidMedialDef.setComponent(self)

        lidLateralDef = Joint('lid_Lateral', parent=self.defCmpGrp)
        lidLateralDef.setComponent(self)

        # Lid Up
        self.eyelidUpDef = []
        self.eyelidUpOutputs = []
        self.setNumUpDeformers(1)

        # Lid Low
        self.eyelidLowDef = []
        self.eyelidLowOutputs = []
        self.setNumLowDeformers(1)

        # =====================
        # Create Component I/O
        # =====================
        # Setup component Xfo I/O's
        self.eyelidUpOutput.setTarget(self.eyelidUpOutputs)
        self.eyelidLowOutput.setTarget(self.eyelidLowOutputs)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.headInputConstraint = PoseConstraint('_'.join([
            self.eyelidCtrlSpace.getName(), 'To',
            self.headInputTgt.getName()
        ]))
        self.headInputConstraint.addConstrainer(self.headInputTgt)
        self.eyelidCtrlSpace.addConstraint(self.headInputConstraint)

        self.eyeballInputConstraint = PoseConstraint('_'.join([
            self.eyeballLocator.getName(), 'To',
            self.eyeballInputTgt.getName()
        ]))
        self.eyeballInputConstraint.setMaintainOffset(True)
        self.eyeballInputConstraint.addConstrainer(self.eyeballInputTgt)
        self.eyeballLocator.addConstraint(self.eyeballInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add MultiPoseConstraint Joints Splice Op
        self.outputsToDeformersKLOp = KLOperator('Canvas_Eyelid_Side_Op',
                                                 'MultiPoseConstraintSolver',
                                                 'Kraken')
        self.addOperator(self.outputsToDeformersKLOp)
        # Add Att Inputs
        self.outputsToDeformersKLOp.setInput('drawDebug',
                                             self.drawDebugInputAttr)
        self.outputsToDeformersKLOp.setInput('rigScale',
                                             self.rigScaleInputAttr)
        # Add Xfo Inputs
        self.outputsToDeformersKLOp.setInput('constrainers', [
            self.lidMedialLocator,
            self.lidLateralLocator,
        ])
        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [
            lidMedialDef,
            lidLateralDef,
        ])

        # Add Lid Up Canvas Op
        self.lidUpCanvasOp = CanvasOperator(
            'Canvas_Eyelid_Up_Op', 'MJCG.Solvers.mjEyelidConstraintSolver')
        self.addOperator(self.lidUpCanvasOp)

        # Add Attributes Inputs
        self.lidUpCanvasOp.setInput('drawDebug', self.lidUp_DebugInputAttr)
        self.lidUpCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.lidUpCanvasOp.setInput('Eyeball_Offset',
                                    self.lidUp_OffsetInputAttr)
        self.lidUpCanvasOp.setInput('Eyeball_Follow_Factor',
                                    self.lidUp_FollowFactorInputAttr)
        self.lidUpCanvasOp.setInput('Medial_Blink_Factor',
                                    self.lidUp_MedialBlinkInputAttr)
        self.lidUpCanvasOp.setInput('Lateral_Blink_Factor',
                                    self.lidUp_LateralBlinkInputAttr)
        self.lidUpCanvasOp.setInput('Deformer_Count',
                                    self.lidUp_DefCountInputAttr)

        # Add Xfo Inputs
        self.lidUpCanvasOp.setInput('Eye_Center', self.eyeballLocator)
        self.lidUpCanvasOp.setInput('Lid_Global', self.eyelidCtrlSpace)
        self.lidUpCanvasOp.setInput('Lid_UpV', self.eyelidUpVLocator)
        self.lidUpCanvasOp.setInput('Lid_Medial', self.lidMedialLocator)
        self.lidUpCanvasOp.setInput('Lid_MedialCen', self.lipUpMedialLocator)
        self.lidUpCanvasOp.setInput('Lid_Center_Ref', self.lidUpCtrlSpace)
        self.lidUpCanvasOp.setInput('Lid_Center_Ctrl', self.lidUpCtrl)
        self.lidUpCanvasOp.setInput('Lid_LateralCen', self.lipUpLateralLocator)
        self.lidUpCanvasOp.setInput('Lid_Lateral', self.lidLateralLocator)
        #Add Xfo Outputs
        self.lidUpCanvasOp.setOutput('result', self.eyelidUpDef)

        # Add Lid Low Canvas Op
        self.lidLowCanvasOp = CanvasOperator(
            'Canvas_Eyelid_Low_Op', 'MJCG.Solvers.mjEyelidConstraintSolver')
        self.addOperator(self.lidLowCanvasOp)

        # Add Attributes Inputs
        self.lidLowCanvasOp.setInput('drawDebug', self.lidLow_DebugInputAttr)
        self.lidLowCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.lidLowCanvasOp.setInput('Eyeball_Offset',
                                     self.lidLow_OffsetInputAttr)
        self.lidLowCanvasOp.setInput('Eyeball_Follow_Factor',
                                     self.lidLow_FollowFactorInputAttr)
        self.lidLowCanvasOp.setInput('Medial_Blink_Factor',
                                     self.lidLow_MedialBlinkInputAttr)
        self.lidLowCanvasOp.setInput('Lateral_Blink_Factor',
                                     self.lidLow_LateralBlinkInputAttr)
        self.lidLowCanvasOp.setInput('Deformer_Count',
                                     self.lidLow_DefCountInputAttr)

        # Add Xfo Inputs
        self.lidLowCanvasOp.setInput('Eye_Center', self.eyeballLocator)
        self.lidLowCanvasOp.setInput('Lid_Global', self.eyelidCtrlSpace)
        self.lidLowCanvasOp.setInput('Lid_UpV', self.eyelidUpVLocator)
        self.lidLowCanvasOp.setInput('Lid_Medial', self.lidMedialLocator)
        self.lidLowCanvasOp.setInput('Lid_MedialCen', self.lidLowMedialLocator)
        self.lidLowCanvasOp.setInput('Lid_Center_Ref', self.lidLowCtrlSpace)
        self.lidLowCanvasOp.setInput('Lid_Center_Ctrl', self.lidLowCtrl)
        self.lidLowCanvasOp.setInput('Lid_LateralCen',
                                     self.lidLowLateralLocator)
        self.lidLowCanvasOp.setInput('Lid_Lateral', self.lidLateralLocator)

        #Add Xfo Outputs
        self.lidLowCanvasOp.setOutput('result', self.eyelidLowDef)

        Profiler.getInstance().pop()

    def setNumUpDeformers(self, numUpDeformers):

        # Add Up Deformers and Outputs
        for i in xrange(len(self.eyelidUpOutputs), numUpDeformers):
            name = 'Lid_Up_' + str(i + 1).zfill(2)
            lidUpOutputs = ComponentOutput(name, parent=self.outputHrcGrp)
            self.eyelidUpOutputs.append(lidUpOutputs)

        for i in xrange(len(self.eyelidUpDef), numUpDeformers):
            name = 'Lid_Up_' + str(i + 1).zfill(2)
            lidUpDef = Joint(name, parent=self.defCmpGrp)
            lidUpDef.setComponent(self)
            self.eyelidUpDef.append(lidUpDef)

        return True

    def setNumLowDeformers(self, numLowDeformers):

        # Add Low Deformers and Outputs
        for i in xrange(len(self.eyelidLowOutputs), numLowDeformers):
            name = 'Lid_Low_' + str(i + 1).zfill(2)
            lidLowOutputs = ComponentOutput(name, parent=self.outputHrcGrp)
            self.eyelidLowOutputs.append(lidLowOutputs)

        for i in xrange(len(self.eyelidLowDef), numLowDeformers):
            name = 'Lid_Low_' + str(i + 1).zfill(2)
            lidLowDef = Joint(name, parent=self.defCmpGrp)
            lidLowDef.setComponent(self)
            self.eyelidLowDef.append(lidLowDef)

        return True

    def loadData(self, data=None):

        super(mjEyelidComponentRig, self).loadData(data)

        # Set CtrlSpace Xfos
        self.eyelidCtrlSpace.xfo = data['eyeballXfo']
        self.eyeballLocator.xfo = data['eyeballXfo']

        self.eyelidUpVLocator.xfo = data['eyelidUpVXfo']

        self.lidMedialLocator.xfo = data['lidMedialXfo']
        self.lidLateralLocator.xfo = data['lidLateralXfo']

        self.lidUpCtrlSpace.xfo = data['lidUpXfo']
        self.lidUpCtrl.xfo = data['lidUpXfo']
        self.lipUpMedialLocator.xfo = data['lidUpMedialXfo']
        self.lipUpLateralLocator.xfo = data['lidUpLateralXfo']

        self.lidLowCtrlSpace.xfo = data['lidLowXfo']
        self.lidLowCtrl.xfo = data['lidLowXfo']
        self.lidLowMedialLocator.xfo = data['lidLowMedialXfo']
        self.lidLowLateralLocator.xfo = data['lidLowLateralXfo']

        # Update number of deformers and outputs
        self.setNumUpDeformers(data['numUpDeformers'])
        self.setNumLowDeformers(data['numLowDeformers'])

        # Set Attributes
        self.upMedialFactorInputAttr.setValue(data['lidUpMedialBlink'])
        self.upLateralFactorInputAttr.setValue(data['lidUpLateralBlink'])
        self.numUpDeformersInputAttr.setValue(data['numUpDeformers'])

        self.lowMedialFactorInputAttr.setValue(data['lidLowMedialBlink'])
        self.lowLateralFactorInputAttr.setValue(data['lidLowLateralBlink'])
        self.numLowDeformersInputAttr.setValue(data['numLowDeformers'])

        self.lidUp_MedialBlinkInputAttr.setValue(data['lidUpMedialBlink'])
        self.lidUp_LateralBlinkInputAttr.setValue(data['lidUpLateralBlink'])
        self.lidLow_MedialBlinkInputAttr.setValue(data['lidLowMedialBlink'])
        self.lidLow_LateralBlinkInputAttr.setValue(data['lidLowLateralBlink'])

        # Set I/O Xfos
        self.headInputTgt.xfo = data['eyeballXfo']
        self.eyeballInputTgt.xfo = data['eyeballXfo']

        self.eyelidUpOutputTgt = self.eyelidUpDef
        self.eyelidLowOutputTgt = self.eyelidLowDef

        # Evaluate Constraints
        self.headInputConstraint.evaluate()
        self.eyeballInputConstraint.evaluate()

        # Evaluate Operators
        self.lidUpCanvasOp.evaluate()
        self.lidLowCanvasOp.evaluate()
        self.outputsToDeformersKLOp.evaluate()
Ejemplo n.º 3
0
class mjEyelidComponentGuide(mjEyelidComponent):
    """Eyelid Component Guide"""
    def __init__(self, name='mjEyelid', parent=None):

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

        # =========
        # Attributes // Create Attributes Controls.
        # =========
        guideUpSettingsAttrGrp = AttributeGroup("Eyelid Up", parent=self)
        guideLowSettingsAttrGrp = AttributeGroup("Eyelid Low", parent=self)

        self.numUpDeformersAttr = IntegerAttribute(
            'Num Deformers',
            value=10,
            minValue=1,
            maxValue=50,
            parent=guideUpSettingsAttrGrp)
        self.upMedialFactorAttr = ScalarAttribute(
            'Medial Blink Factor',
            value=0.25,
            minValue=0,
            maxValue=1,
            parent=guideUpSettingsAttrGrp)
        self.upLateralFactorAttr = ScalarAttribute(
            'Lateral Blink Factor',
            value=0.65,
            minValue=0,
            maxValue=1,
            parent=guideUpSettingsAttrGrp)

        self.numLowDeformersAttr = IntegerAttribute(
            'Num Deformers',
            value=10,
            minValue=1,
            maxValue=50,
            parent=guideLowSettingsAttrGrp)
        self.lowMedialFactorAttr = ScalarAttribute(
            'Medial Blink Factor',
            value=0.25,
            minValue=0,
            maxValue=1,
            parent=guideLowSettingsAttrGrp)
        self.lowLateralFactorAttr = ScalarAttribute(
            'Lateral Blink Factor',
            value=0.65,
            minValue=0,
            maxValue=1,
            parent=guideLowSettingsAttrGrp)

        self.numUpDeformersAttr.setValueChangeCallback(
            self.updateNumUpDeformers)
        self.numLowDeformersAttr.setValueChangeCallback(
            self.updateNumLowDeformers)

        # =========
        # Controls // Create the Guide Controls, Name them, give them a shape, a color and scale it.
        # =========
        self.eyeballCtrl = Control('eyeball',
                                   parent=self.ctrlCmpGrp,
                                   shape="sphere")
        self.eyeballCtrl.scalePoints(Vec3(0.35, 0.35, 0.35))
        self.eyeballCtrl.setColor("red")

        self.lidMedialCtrl = Control('lidMedial',
                                     parent=self.eyeballCtrl,
                                     shape="sphere")
        self.lidMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidMedialCtrl.setColor("peach")

        self.lidLateralCtrl = Control('lidLateral',
                                      parent=self.eyeballCtrl,
                                      shape="sphere")
        self.lidLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLateralCtrl.setColor("peach")

        self.lidUpCtrl = Control('lidUp',
                                 parent=self.eyeballCtrl,
                                 shape="sphere")
        self.lidUpCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpCtrl.setColor("peach")

        self.lidUpMedialCtrl = Control('lidUpMedial',
                                       parent=self.eyeballCtrl,
                                       shape="sphere")
        self.lidUpMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpMedialCtrl.setColor("peach")

        self.lidUpLateralCtrl = Control('lidUpLateral',
                                        parent=self.eyeballCtrl,
                                        shape="sphere")
        self.lidUpLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpLateralCtrl.setColor("peach")

        self.lidLowCtrl = Control('lidLow',
                                  parent=self.eyeballCtrl,
                                  shape="sphere")
        self.lidLowCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowCtrl.setColor("peach")

        self.lidLowMedialCtrl = Control('lidLowMedial',
                                        parent=self.eyeballCtrl,
                                        shape="sphere")
        self.lidLowMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowMedialCtrl.setColor("peach")

        self.lidLowLateralCtrl = Control('lidLowLateral',
                                         parent=self.eyeballCtrl,
                                         shape="sphere")
        self.lidLowLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowLateralCtrl.setColor("peach")

        # ===============
        # Add Debug Splice Ops
        # ===============
        # Add Lid Up Canvas Op
        self.debugLidUpCanvasOp = CanvasOperator(
            'Debug_Canvas_Eyelid_Up_Op', 'MJCG.Solvers.mjEyelidDebugSolver')
        self.addOperator(self.debugLidUpCanvasOp)

        # Add Attributes Inputs
        self.debugLidUpCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.debugLidUpCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.debugLidUpCanvasOp.setInput('Deformer_Count',
                                         self.numUpDeformersInputAttr)

        # Add Xfo Inputs
        self.debugLidUpCanvasOp.setInput('Eye_Center', self.eyeballCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Medial', self.lidMedialCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_MedialCen', self.lidUpMedialCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Center_Ref', self.lidUpCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Center_Ctrl', self.lidUpCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_LateralCen',
                                         self.lidUpLateralCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Lateral', self.lidLateralCtrl)

        # Add Xfo Outputs
        self.debugLidUpCanvasOp.setOutput('result',
                                          self.eyelidUpOutput.getTarget())

        # Add Lid Low Canvas Op
        self.debugLidLowCanvasOp = CanvasOperator(
            'Debug_Canvas_Eyelid_Low_Op', 'MJCG.Solvers.mjEyelidDebugSolver')
        self.addOperator(self.debugLidLowCanvasOp)

        # Add Attributes Inputs
        self.debugLidLowCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.debugLidLowCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.debugLidLowCanvasOp.setInput('Deformer_Count',
                                          self.numLowDeformersInputAttr)

        # Add Xfo Inputs
        self.debugLidLowCanvasOp.setInput('Eye_Center', self.eyeballCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Medial', self.lidMedialCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_MedialCen',
                                          self.lidLowMedialCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Center_Ref', self.lidLowCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Center_Ctrl', self.lidLowCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_LateralCen',
                                          self.lidLowLateralCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Lateral', self.lidLateralCtrl)

        # Add Xfo Outputs
        self.debugLidLowCanvasOp.setOutput('result',
                                           self.eyelidLowOutput.getTarget())

        # =========
        # Position Data // Get the Guide Controls Position data, else set them at their initial position.
        # =========
        self.default_data = {
            "name": name,
            "location": "L",
            "eyeballXfo": Xfo(Vec3(0.322, 15.500, 0.390)),
            "lidMedialXfo": Xfo(Vec3(0.168, 15.445, 0.520)),
            "lidLateralXfo": Xfo(Vec3(0.465, 15.47, 0.465)),
            "lidUpXfo": Xfo(Vec3(0.322, 15.585, 0.605)),
            "lidUpMedialXfo": Xfo(Vec3(0.203, 15.515, 0.525)),
            "lidUpLateralXfo": Xfo(Vec3(0.432, 15.55, 0.538)),
            "lidLowXfo": Xfo(Vec3(0.322, 15.434, 0.6)),
            "lidLowMedialXfo": Xfo(Vec3(0.24, 15.45, 0.513)),
            "lidLowLateralXfo": Xfo(Vec3(0.413, 15.44, 0.525)),
            "lidUpMedialBlink": self.upMedialFactorAttr.getValue(),
            "lidUpLateralBlink": self.upLateralFactorAttr.getValue(),
            "lidLowMedialBlink": self.lowMedialFactorAttr.getValue(),
            "lidLowLateralBlink": self.lowLateralFactorAttr.getValue(),
            "numUpDeformers": self.numUpDeformersAttr.getValue(),
            "numLowDeformers": self.numLowDeformersAttr.getValue(),
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()

# ==========
# Callbacks
# ==========

    def updateNumUpDeformers(self, countUp):

        if countUp == 0:
            raise IndexError("'count' must be > 0")

        #Lip Up
        lidUpOutputs = self.eyelidUpOutput.getTarget()
        if countUp > len(lidUpOutputs):
            for i in xrange(len(lidUpOutputs), countUp):
                debugUpCtrl = Control('Lid_Up_' + str(i + 1).zfill(2),
                                      parent=self.outputHrcGrp,
                                      shape="sphere")
                debugUpCtrl.rotatePoints(90, -90, 180)
                debugUpCtrl.scalePoints(Vec3(0.01, 0.01, 0.01))
                debugUpCtrl.setColor("yellowLight")
                lidUpOutputs.append(debugUpCtrl)

        elif countUp < len(lidUpOutputs):
            numExtraUpCtrls = len(lidUpOutputs) - countUp
            for i in xrange(numExtraUpCtrls):
                extraUpCtrl = lidUpOutputs.pop()
                self.outputHrcGrp.removeChild(extraUpCtrl)

        return True

    def updateNumLowDeformers(self, countLow):

        if countLow == 0:
            raise IndexError("'count' must be > 0")

        #Lip Low
        lidLowOutputs = self.eyelidLowOutput.getTarget()
        if countLow > len(lidLowOutputs):
            for i in xrange(len(lidLowOutputs), countLow):
                debugLowCtrl = Control('Lid_Low_' + str(i + 1).zfill(2),
                                       parent=self.outputHrcGrp,
                                       shape="sphere")
                debugLowCtrl.rotatePoints(90, -90, 180)
                debugLowCtrl.scalePoints(Vec3(0.01, 0.01, 0.01))
                debugLowCtrl.setColor("yellowLight")
                lidLowOutputs.append(debugLowCtrl)

        elif countLow < len(lidLowOutputs):
            numExtraLowCtrls = len(lidLowOutputs) - countLow
            for i in xrange(numExtraLowCtrls):
                extraLowCtrl = lidLowOutputs.pop()
                self.outputHrcGrp.removeChild(extraLowCtrl)

        return True

    # =============
    # Data Methods
    # =============
    def saveData(self):

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

        data['eyeballXfo'] = self.eyeballCtrl.xfo

        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

    def loadData(self, data):

        super(mjEyelidComponentGuide, self).loadData(data)

        self.eyeballCtrl.xfo = data['eyeballXfo']

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

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

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

        self.numUpDeformersAttr.setValue(data["numUpDeformers"])
        self.numLowDeformersAttr.setValue(data["numLowDeformers"])

        self.numUpDeformersInputAttr.setValue(data["numUpDeformers"])
        self.numLowDeformersInputAttr.setValue(data["numLowDeformers"])

        self.upMedialFactorInputAttr.setValue(data['lidUpMedialBlink'])
        self.upLateralFactorInputAttr.setValue(data['lidUpLateralBlink'])

        self.lowMedialFactorInputAttr.setValue(data['lidLowMedialBlink'])
        self.lowLateralFactorInputAttr.setValue(data['lidLowLateralBlink'])

        self.debugLidUpCanvasOp.evaluate()
        self.debugLidLowCanvasOp.evaluate()

        return True

    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

    # ==============
    # Class Methods
    # ==============
    @classmethod
    def getComponentType(cls):

        return 'Guide'

    @classmethod
    def getRigComponentClass(cls):

        return mjEyelidComponentRig
Ejemplo n.º 4
0
    def addFinger(self, name):

        digitSizeAttributes = []
        fingerGuideCtrls = []

        firstDigitCtrl = Control(name + "01", parent=self.handCtrl, shape='sphere')
        firstDigitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))

        firstDigitShapeCtrl = Control(name + "Shp01", parent=self.guideCtrlHrcGrp, shape='square')
        firstDigitShapeCtrl.setColor('yellow')
        firstDigitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
        firstDigitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
        fingerGuideCtrls.append(firstDigitShapeCtrl)
        firstDigitCtrl.shapeCtrl = firstDigitShapeCtrl

        firstDigitVisAttr = firstDigitShapeCtrl.getVisibilityAttr()
        firstDigitVisAttr.connect(self.ctrlShapeToggle)

        triangleCtrl = Control('tempCtrl', parent=None, shape='triangle')
        triangleCtrl.rotatePoints(90.0, 0.0, 0.0)
        triangleCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        triangleCtrl.translatePoints(Vec3(0.0, 0.0875, 0.0))

        firstDigitCtrl.appendCurveData(triangleCtrl.getCurveData())
        firstDigitCtrl.lockScale(True, True, True)

        digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=firstDigitCtrl)
        digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
        digitSizeAttributes.append(digitSizeAttr)

        # Set Finger
        self.fingers[name] = []
        self.fingers[name].append(firstDigitCtrl)

        parent = firstDigitCtrl
        numJoints = self.numJointsAttr.getValue()
        if name == "thumb":
            numJoints = 3
        for i in xrange(2, numJoints + 2):
            digitCtrl = Control(name + str(i).zfill(2), parent=parent, shape='sphere')

            if i != numJoints + 1:
                digitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))
                digitCtrl.appendCurveData(triangleCtrl.getCurveData())

                digitShapeCtrl = Control(name + 'Shp' + str(i).zfill(2), parent=self.guideCtrlHrcGrp, shape='circle')
                digitShapeCtrl.setColor('yellow')
                digitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
                digitShapeCtrl.getVisibilityAttr().connect(self.ctrlShapeToggle)

                digitCtrl.shapeCtrl = digitShapeCtrl

                if i == 2:
                    digitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
                else:
                    digitShapeCtrl.rotatePoints(0.0, 0.0, 90.0)

                fingerGuideCtrls.append(digitShapeCtrl)

                # Add size attr to all but last guide control
                digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=digitCtrl)
                digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
                digitSizeAttributes.append(digitSizeAttr)
            else:
                digitCtrl.scalePoints(Vec3(0.0875, 0.0875, 0.0875))

            digitCtrl.lockScale(True, True, True)

            self.fingers[name].append(digitCtrl)

            parent = digitCtrl

        # ===========================
        # Create Canvas Operators
        # ===========================
        # Add Finger Guide Canvas Op
        fingerGuideCanvasOp = CanvasOperator(name + 'FingerGuide', 'Kraken.Solvers.Biped.BipedFingerGuideSolver')
        self.addOperator(fingerGuideCanvasOp)

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

        # Add Xfo Inputs
        fingerGuideCanvasOp.setInput('controls', self.fingers[name])
        fingerGuideCanvasOp.setInput('planeSizes', digitSizeAttributes)

        # Add Xfo Outputs
        fingerGuideCanvasOp.setOutput('result', fingerGuideCtrls)
        fingerGuideCanvasOp.setOutput('forceEval', firstDigitCtrl.getVisibilityAttr())

        return firstDigitCtrl
Ejemplo n.º 5
0
class MultiSpringComponentRig(MultiSpringComponent):
    """Multi Spring Rig"""
    def __init__(self, name='MultiSpring', parent=None):

        Profiler.getInstance().push("Construct Multi Spring Rig Component:" +
                                    name)
        super(MultiSpringComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Spring Ctrls
        self.mainSpringCtrl = Control('springSettings',
                                      parent=self.ctrlCmpGrp,
                                      shape='pin')

        self.springCtrlSpaces = []
        self.springCtrls = []
        self.setNumControls(1)

        # Add Component Params to FK control
        springSettingsAttrGrp = AttributeGroup("DisplayInfo_SpringSettings",
                                               parent=self.mainSpringCtrl)
        self.springDrawDebugInputAttr = BoolAttribute(
            'drawDebug', value=False, parent=springSettingsAttrGrp)
        self.springtargetOffsetXInputAttr = ScalarAttribute(
            'targetOffset_X',
            value=3.0,
            minValue=0.0,
            maxValue=10.0,
            parent=springSettingsAttrGrp)
        self.springtargetOffsetYInputAttr = ScalarAttribute(
            'targetOffset_Y',
            value=0.0,
            minValue=0.0,
            maxValue=10.0,
            parent=springSettingsAttrGrp)
        self.springtargetOffsetZInputAttr = ScalarAttribute(
            'targetOffset_Z',
            value=0.0,
            minValue=0.0,
            maxValue=10.0,
            parent=springSettingsAttrGrp)
        self.springFrameInputAttr = IntegerAttribute(
            'frame', value=1, parent=springSettingsAttrGrp)
        self.springResetFrameInputAttr = IntegerAttribute(
            'reset_frame', value=1, parent=springSettingsAttrGrp)
        self.springMassInputAttr = ScalarAttribute(
            'mass',
            value=0.5,
            minValue=0.0,
            maxValue=20.0,
            parent=springSettingsAttrGrp)
        self.springSpringStrengthInputAttr = ScalarAttribute(
            'springStrength',
            value=6.0,
            minValue=0.0,
            maxValue=20.0,
            parent=springSettingsAttrGrp)
        self.springDampingInputAttr = ScalarAttribute(
            'damping',
            value=0.125,
            minValue=0.0,
            maxValue=5.0,
            parent=springSettingsAttrGrp)

        # Connect IO to controls
        self.drawDebugInputAttr.connect(self.springDrawDebugInputAttr)

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(),
                                        self,
                                        parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)
        self.deformerJoints = []
        self.boneOutputsTgt = []
        self.setNumDeformers(4)

        # =====================
        # Create Component I/O
        # =====================

        # Set IO Targets
        self.boneOutputs.setTarget(self.boneOutputsTgt)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.rootInputConstraint = PoseConstraint('_'.join([
            self.springCtrlSpaces[0].getName(), 'To',
            self.rootInputTgt.getName()
        ]))
        self.rootInputConstraint.setMaintainOffset(True)
        self.rootInputConstraint.addConstrainer(self.rootInputTgt)
        self.springCtrlSpaces[0].addConstraint(self.rootInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add Solver Canvas Op
        self.springOp = CanvasOperator('springSolverOp',
                                       'Kraken.Solvers.SpringOffsetSolver')
        self.addOperator(self.springOp)

        # Add Att Inputs
        self.springOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.springOp.setInput('rigScale', self.rigScaleInputAttr)
        self.springOp.setInput('targetOffset_X',
                               self.springtargetOffsetXInputAttr)
        self.springOp.setInput('targetOffset_Y',
                               self.springtargetOffsetYInputAttr)
        self.springOp.setInput('targetOffset_Z',
                               self.springtargetOffsetZInputAttr)
        self.springOp.setInput('frame', self.springFrameInputAttr)
        self.springOp.setInput('reset_frame', self.springResetFrameInputAttr)
        self.springOp.setInput('mass', self.springMassInputAttr)
        self.springOp.setInput('spring_strength',
                               self.springSpringStrengthInputAttr)
        self.springOp.setInput('damping', self.springDampingInputAttr)

        # Add Xfo Inputs
        self.springOp.setInput('inputs', self.springCtrls)

        # Add Xfo Outputs
        self.springOp.setOutput('outputs', self.boneOutputsTgt)

        # Add Deformer Splice Op
        self.deformersToOutputsKLOp = KLOperator('springDeformerKLOp',
                                                 'MultiPoseConstraintSolver',
                                                 'Kraken')
        self.addOperator(self.deformersToOutputsKLOp)

        # Add Att Inputs
        self.deformersToOutputsKLOp.setInput('drawDebug', False)
        self.deformersToOutputsKLOp.setInput('rigScale',
                                             self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.deformersToOutputsKLOp.setInput('constrainers',
                                             self.boneOutputsTgt)

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees',
                                              self.deformerJoints)

        Profiler.getInstance().pop()

    def setNumControls(self, numControls):

        # Add more controls
        if numControls > len(self.springCtrlSpaces):
            for i in xrange(len(self.springCtrlSpaces), numControls):
                boneName = 'spring' + str(i + 1).zfill(2)
                boneFKCtrlSpace = CtrlSpace(boneName, parent=self.ctrlCmpGrp)

                boneFKCtrl = Control(boneName,
                                     parent=boneFKCtrlSpace,
                                     shape='squarePointed')
                boneFKCtrl.alignOnXAxis()

                self.springCtrlSpaces.append(boneFKCtrlSpace)
                self.springCtrls.append(boneFKCtrl)

        # Remove extra ctrls
        elif numControls < len(self.springCtrlSpaces):
            numExtraCtrls = len(self.springCtrls) - numControls
            for i in xrange(numExtraCtrls):
                extraCtrlSpace = self.springCtrlSpaces.pop()
                extraCtrl = self.springCtrls.pop()
                extraCtrlSpace.getParent().removeChild(extraCtrlSpace)
                extraCtrl.getParent().removeChild(extraCtrl)

    def setNumDeformers(self, numDeformers):

        # Add more deformers and outputs
        if numDeformers > len(self.boneOutputsTgt):
            for i in xrange(len(self.boneOutputsTgt), numDeformers):
                name = 'bone' + str(i + 1).zfill(2)

                legOutput = ComponentOutput(name, parent=self.outputHrcGrp)
                self.boneOutputsTgt.append(legOutput)

                boneDef = Joint(name, parent=self.defCmpGrp)
                boneDef.setComponent(self)
                self.deformerJoints.append(boneDef)

        # Remove extra deformers and outputs
        elif numDeformers < len(self.boneOutputsTgt):
            numExtraOutputs = len(self.boneOutputsTgt) - numDeformers
            numExtraDefs = len(self.deformerJoints) - numDeformers

            for i in xrange(numExtraOutputs):
                extraOutput = self.boneOutputsTgt.pop()
                extraDef = self.deformerJoints.pop()

                extraOutput.getParent().removeChild(extraOutput)
                extraDef.getParent().removeChild(extraDef)

        return True

    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(MultiSpringComponentRig, self).loadData(data)

        boneXfos = data['boneXfos']
        numSprings = data['numSprings']

        # Add extra controls and outputs
        self.setNumControls(numSprings)
        self.setNumDeformers(numSprings)

        for i in xrange(numSprings):
            self.springCtrlSpaces[i].xfo = boneXfos[i]
            self.springCtrls[i].xfo = boneXfos[i]

        # ==========================
        # Create Output Constraints
        # ==========================

        # ============
        # Set IO Xfos
        # ============
        self.rootInputTgt.xfo = boneXfos[0]

        for i in xrange(numSprings):
            self.boneOutputsTgt[i].xfo = boneXfos[i]

        # =============
        # Set IO Attrs
        # =============

        # ====================
        # Evaluate Splice Ops
        # ====================
        # Eval Solver Ops
        self.springOp.evaluate()

        # evaluate the output splice op to evaluate with new outputs and deformers
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.rootInputConstraint.evaluate()
Ejemplo n.º 6
0
class FKCollisionComponentRig(FKCollisionComponent):
    """FK Collision Rig"""
    def __init__(self, name='FKCollision', parent=None):

        Profiler.getInstance().push("Construct FK Collision Rig Component:" +
                                    name)
        super(FKCollisionComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Ground
        self.groundCtrl = Control('ground',
                                  parent=self.ctrlCmpGrp,
                                  shape='square')
        self.groundCtrl.insertCtrlSpace()

        groundSettingsAttrGrp = AttributeGroup("DisplayInfo_ChainSettings",
                                               parent=self.groundCtrl)
        self.groundOffsetYInputAttr = ScalarAttribute(
            'ground_offsetY',
            0.0,
            minValue=0.0,
            maxValue=10.0,
            parent=groundSettingsAttrGrp)

        # FK
        self.fkCtrlSpaces = []
        self.fkCtrls = []
        self.transforms = []
        self.setNumControls(4)
        self.setNumTransforms(4)

        # Add Component Params to FK control
        chainSettingsAttrGrp = AttributeGroup("DisplayInfo_ChainSettings",
                                              parent=self.fkCtrls[0])
        chainDrawDebugInputAttr = BoolAttribute('drawDebug',
                                                value=False,
                                                parent=chainSettingsAttrGrp)

        # Connect IO to controls
        self.drawDebugInputAttr.connect(chainDrawDebugInputAttr)

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(),
                                        self,
                                        parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)
        self.deformerJoints = []
        self.boneOutputsTgt = []
        self.setNumDeformers(4)

        # =====================
        # Create Component I/O
        # =====================

        # Set IO Targets
        self.boneOutputs.setTarget(self.boneOutputsTgt)

        # ==============
        # Constrain I/O
        # ==============
        # Constrain inputs
        self.rootInputConstraint = PoseConstraint('_'.join([
            self.fkCtrlSpaces[0].getName(), 'To',
            self.rootInputTgt.getName()
        ]))
        self.rootInputConstraint.setMaintainOffset(True)
        self.rootInputConstraint.addConstrainer(self.rootInputTgt)
        self.fkCtrlSpaces[0].addConstraint(self.rootInputConstraint)

        # ===============
        # Add Canvas Ops
        # ===============
        # Add Output Canvas Op
        self.collisionCanvasOp = CanvasOperator(
            'collisionCanvasOp', 'Kraken.Solvers.CollideChainSolver')
        self.addOperator(self.collisionCanvasOp)

        # Add Att Inputs
        self.collisionCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.collisionCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.collisionCanvasOp.setInput('ground_offsetY',
                                        self.groundOffsetYInputAttr)

        # Add Xfo Inputs
        self.collisionCanvasOp.setInput('ground', self.groundCtrl)
        self.collisionCanvasOp.setInput('joints', self.transforms)

        # Add Xfo Outputs
        self.collisionCanvasOp.setOutput('outputs', self.boneOutputsTgt)

        # Add Deformer Canvas Op
        self.deformersToOutputsKLOp = KLOperator('fkChainDeformerKLOp',
                                                 'MultiPoseConstraintSolver',
                                                 'Kraken')
        self.addOperator(self.deformersToOutputsKLOp)

        # Add Att Inputs
        self.deformersToOutputsKLOp.setInput('drawDebug', False)
        self.deformersToOutputsKLOp.setInput('rigScale',
                                             self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.deformersToOutputsKLOp.setInput('constrainers',
                                             self.boneOutputsTgt)

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees',
                                              self.deformerJoints)

        Profiler.getInstance().pop()

    def setNumControls(self, numControls):

        # Add more controls
        if numControls > len(self.fkCtrlSpaces):
            for i in xrange(len(self.fkCtrlSpaces), numControls):
                if i == 0:
                    parent = self.ctrlCmpGrp
                else:
                    parent = self.fkCtrls[i - 1]

                boneName = 'bone' + str(i + 1).zfill(2) + 'FK'
                boneFKCtrlSpace = CtrlSpace(boneName, parent=parent)

                boneFKCtrl = Control(boneName,
                                     parent=boneFKCtrlSpace,
                                     shape="cube")
                boneFKCtrl.alignOnXAxis()

                self.fkCtrlSpaces.append(boneFKCtrlSpace)
                self.fkCtrls.append(boneFKCtrl)

        # Remove extra ctrls
        elif numControls < len(self.fkCtrlSpaces):
            numExtraCtrls = len(self.fkCtrls) - numControls
            for i in xrange(numExtraCtrls):
                extraCtrlSpace = self.fkCtrlSpaces.pop()
                extraCtrl = self.fkCtrls.pop()
                extraCtrlSpace.getParent().removeChild(extraCtrlSpace)
                extraCtrl.getParent().removeChild(extraCtrl)

    def setNumTransforms(self, numTransforms):

        numTransforms += 1

        # Add more transforms
        if numTransforms > len(self.transforms):
            for i in xrange(len(self.transforms), numTransforms):
                name = 'transform' + str(i + 1).zfill(2)

                transform = Transform(name, parent=self.outputHrcGrp)
                self.transforms.append(transform)

        # Remove extra transforms
        elif numTransforms < len(self.transforms):
            numExtraTransforms = len(self.transforms) - numTransforms

            for i in xrange(numExtraTransforms):
                extraTransform = self.transforms.pop()
                extraTransform.getParent().removeChild(extraTransform)

        return True

    def setNumDeformers(self, numDeformers):

        # Add more deformers and outputs
        if numDeformers > len(self.boneOutputsTgt):
            for i in xrange(len(self.boneOutputsTgt), numDeformers):
                name = 'bone' + str(i + 1).zfill(2)

                defOutput = ComponentOutput(name, parent=self.outputHrcGrp)
                self.boneOutputsTgt.append(defOutput)

                boneDef = Joint(name, parent=self.defCmpGrp)
                boneDef.setComponent(self)
                self.deformerJoints.append(boneDef)

        # Remove extra deformers and outputs
        elif numDeformers < len(self.boneOutputsTgt):
            numExtraOutputs = len(self.boneOutputsTgt) - numDeformers
            numExtraDefs = len(self.deformerJoints) - numDeformers

            for i in xrange(numExtraOutputs):
                extraOutput = self.boneOutputsTgt.pop()
                extraDef = self.deformerJoints.pop()

                extraOutput.getParent().removeChild(extraOutput)
                extraDef.getParent().removeChild(extraDef)

        return True

    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(FKCollisionComponentRig, self).loadData(data)

        jointXfos = data['jointXfos']
        boneXfos = data['boneXfos']
        boneLengths = data['boneLengths']
        numJoints = data['numJoints']

        # Add extra controls and outputs
        self.setNumControls(numJoints)
        self.setNumTransforms(numJoints)
        self.setNumDeformers(numJoints)

        for i in xrange(numJoints):
            self.fkCtrlSpaces[i].xfo = boneXfos[i]
            self.fkCtrls[i].xfo = boneXfos[i]
            self.fkCtrls[i].scalePoints(
                Vec3(boneLengths[i], boneLengths[i] * 0.45,
                     boneLengths[i] * 0.45))

        for i in xrange(len(self.transforms)):
            self.transforms[i].xfo = jointXfos[i]

        # ==========================
        # Create Output Constraints
        # ==========================
        # This needs to be done here since the 'numJoints' attribute resizes the
        # number of controls and outputs

        self.chainEndXfoOutputConstraint = PoseConstraint('_'.join([
            self.chainEndXfoOutputTgt.getName(), 'To',
            self.boneOutputsTgt[-1].getName()
        ]))
        self.chainEndXfoOutputConstraint.setMaintainOffset(True)
        self.chainEndXfoOutputConstraint.addConstrainer(
            self.boneOutputsTgt[-1])
        self.chainEndXfoOutputTgt.addConstraint(
            self.chainEndXfoOutputConstraint)

        self.chainEndPosOutputConstraint = PositionConstraint('_'.join([
            self.chainEndPosOutputTgt.getName(), 'To',
            self.boneOutputsTgt[-1].getName()
        ]))
        self.chainEndPosOutputConstraint.setMaintainOffset(True)
        self.chainEndPosOutputConstraint.addConstrainer(
            self.boneOutputsTgt[-1])
        self.chainEndPosOutputTgt.addConstraint(
            self.chainEndPosOutputConstraint)

        self.transformConstraints = []
        for i in xrange(len(self.transforms)):
            if i == len(self.transforms) - 1:
                constrainer = self.fkCtrls[i - 1]
            else:
                constrainer = self.fkCtrls[i]

            transformConstraint = PoseConstraint('_'.join(
                [self.transforms[i].getName(), 'To',
                 constrainer.getName()]))
            transformConstraint.setMaintainOffset(True)
            transformConstraint.addConstrainer(constrainer)
            self.transforms[i].addConstraint(transformConstraint)

            self.transformConstraints.append(transformConstraint)

        # ============
        # Set IO Xfos
        # ============
        self.rootInputTgt.xfo = boneXfos[0]

        for i in xrange(numJoints):
            self.boneOutputsTgt[i].xfo = boneXfos[i]

        self.chainEndXfoOutputTgt.xfo = data['endXfo']
        self.chainEndPosOutputTgt.xfo = data['endXfo']

        # =============
        # Set IO Attrs
        # =============

        # ====================
        # Evaluate Canvas Ops
        # ====================
        # Eval Collision Op to evaulate with new outputs and controls
        self.collisionCanvasOp.evaluate()

        # evaluate the output splice op to evaluate with new outputs and deformers
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        for constraint in self.transformConstraints:
            constraint.evaluate()

        self.rootInputConstraint.evaluate()
        self.chainEndXfoOutputConstraint.evaluate()
Ejemplo n.º 7
0
class FabriceHeadRig(FabriceHead):
    """Fabrice Head Component Rig"""

    def __init__(self, name='head', parent=None):

        Profiler.getInstance().push("Construct Head Rig Component:" + name)
        super(FabriceHeadRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Head Aim
        self.headAimCtrlSpace = CtrlSpace('headAim', parent=self.ctrlCmpGrp)
        self.headAimCtrl = Control('headAim', parent=self.headAimCtrlSpace, shape="sphere")
        self.headAimCtrl.scalePoints(Vec3(0.35, 0.35, 0.35))
        self.headAimCtrl.lockScale(x=True, y=True, z=True)

        self.headAimUpV = Locator('headAimUpV', parent=self.headAimCtrl)
        self.headAimUpV.setShapeVisibility(False)

        # Head
        self.headAim = Locator('headAim', parent=self.ctrlCmpGrp)
        self.headAim.setShapeVisibility(False)

        self.headCtrlSpace = CtrlSpace('head', parent=self.ctrlCmpGrp)
        self.headCtrl = Control('head', parent=self.headCtrlSpace, shape="circle")
        self.headCtrl.lockTranslation(x=True, y=True, z=True)
        self.headCtrl.lockScale(x=True, y=True, z=True)

        # Jaw
        self.jawCtrlSpace = CtrlSpace('jawCtrlSpace', parent=self.headCtrl)
        self.jawCtrl = Control('jaw', parent=self.jawCtrlSpace, shape="cube")
        self.jawCtrl.lockTranslation(x=True, y=True, z=True)
        self.jawCtrl.lockScale(x=True, y=True, z=True)
        self.jawCtrl.setColor("orange")

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        headDef = Joint('head', parent=defCmpGrp)
        headDef.setComponent(self)

        jawDef = Joint('jaw', parent=defCmpGrp)
        jawDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        self.headToAimConstraint = PoseConstraint('_'.join([self.headCtrlSpace.getName(), 'To', self.headAim.getName()]))
        self.headToAimConstraint.setMaintainOffset(True)
        self.headToAimConstraint.addConstrainer(self.headAim)
        self.headCtrlSpace.addConstraint(self.headToAimConstraint)

        # Constraint inputs
        self.headAimInputConstraint = PoseConstraint('_'.join([self.headAimCtrlSpace.getName(), 'To', self.headBaseInputTgt.getName()]))
        self.headAimInputConstraint.setMaintainOffset(True)
        self.headAimInputConstraint.addConstrainer(self.headBaseInputTgt)
        self.headAimCtrlSpace.addConstraint(self.headAimInputConstraint)

        # # Constraint outputs
        self.headOutputConstraint = PoseConstraint('_'.join([self.headOutputTgt.getName(), 'To', self.headCtrl.getName()]))
        self.headOutputConstraint.addConstrainer(self.headCtrl)
        self.headOutputTgt.addConstraint(self.headOutputConstraint)

        self.jawOutputConstraint = PoseConstraint('_'.join([self.jawOutputTgt.getName(), 'To', self.jawCtrl.getName()]))
        self.jawOutputConstraint.addConstrainer(self.jawCtrl)
        self.jawOutputTgt.addConstraint(self.jawOutputConstraint)

        # ==============
        # Add Operators
        # ==============

        # Add Aim Canvas Op
        # =================
        self.headAimCanvasOp = CanvasOperator('headAimCanvasOp', 'Kraken.Solvers.DirectionConstraintSolver')
        self.addOperator(self.headAimCanvasOp)

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

        # Add Xfo Inputs
        self.headAimCanvasOp.setInput('position', self.headBaseInputTgt)
        self.headAimCanvasOp.setInput('upVector', self.headAimUpV)
        self.headAimCanvasOp.setInput('atVector', self.headAimCtrl)

        # Add Xfo Outputs
        self.headAimCanvasOp.setOutput('constrainee', self.headAim)

        # Add Deformer KL Op
        # ==================
        self.deformersToOutputsKLOp = KLOperator('headDeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.deformersToOutputsKLOp)

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

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setInput('constrainers', [self.headOutputTgt, self.jawOutputTgt])

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees', [headDef, jawDef])

        Profiler.getInstance().pop()


    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(FabriceHeadRig, self).loadData( data )

        headXfo = data['headXfo']
        headCtrlCrvData = data['headCtrlCrvData']
        jawPosition = data['jawPosition']
        jawCtrlCrvData = data['jawCtrlCrvData']

        self.headAimCtrlSpace.xfo.ori = headXfo.ori
        self.headAimCtrlSpace.xfo.tr = headXfo.tr.add(Vec3(0, 0, 4))
        self.headAimCtrl.xfo = self.headAimCtrlSpace.xfo

        self.headAimUpV.xfo.ori = self.headAimCtrl.xfo.ori
        self.headAimUpV.xfo.tr = self.headAimCtrl.xfo.tr.add(Vec3(0, 3, 0))

        self.headAim.xfo = headXfo
        self.headCtrlSpace.xfo = headXfo
        self.headCtrl.xfo = headXfo
        self.headCtrl.setCurveData(headCtrlCrvData)

        self.jawCtrlSpace.xfo.tr = jawPosition
        self.jawCtrl.xfo.tr = jawPosition
        self.jawCtrl.setCurveData(jawCtrlCrvData)

        # ============
        # Set IO Xfos
        # ============
        self.headBaseInputTgt.xfo = headXfo
        self.headOutputTgt.xfo = headXfo
        self.jawOutputTgt.xfo.tr = jawPosition

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the constraint op so that all the joint transforms are updated.
        self.headAimCanvasOp.evaluate()
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.headToAimConstraint.evaluate()
        self.headAimInputConstraint.evaluate()
        self.headOutputConstraint.evaluate()
        self.jawOutputConstraint.evaluate()
Ejemplo n.º 8
0
    def addFinger(self, name):

        digitSizeAttributes = []
        fingerGuideCtrls = []

        firstDigitCtrl = Control(name + "01", parent=self.handCtrl, shape='sphere')
        firstDigitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))

        firstDigitShapeCtrl = Control(name + "Shp01", parent=self.guideCtrlHrcGrp, shape='square')
        firstDigitShapeCtrl.setColor('yellow')
        firstDigitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
        firstDigitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
        fingerGuideCtrls.append(firstDigitShapeCtrl)
        firstDigitCtrl.shapeCtrl = firstDigitShapeCtrl

        firstDigitVisAttr = firstDigitShapeCtrl.getVisibilityAttr()
        firstDigitVisAttr.connect(self.ctrlShapeToggle)

        triangleCtrl = Control('tempCtrl', parent=None, shape='triangle')
        triangleCtrl.rotatePoints(90.0, 0.0, 0.0)
        triangleCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        triangleCtrl.translatePoints(Vec3(0.0, 0.0875, 0.0))

        firstDigitCtrl.appendCurveData(triangleCtrl.getCurveData())
        firstDigitCtrl.lockScale(True, True, True)

        digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=firstDigitCtrl)
        digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
        digitSizeAttributes.append(digitSizeAttr)

        # Set Finger
        self.fingers[name] = []
        self.fingers[name].append(firstDigitCtrl)

        parent = firstDigitCtrl
        numJoints = self.numJointsAttr.getValue()
        if name == "thumb":
            numJoints = 3
        for i in xrange(2, numJoints + 2):
            digitCtrl = Control(name + str(i).zfill(2), parent=parent, shape='sphere')

            if i != numJoints + 1:
                digitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))
                digitCtrl.appendCurveData(triangleCtrl.getCurveData())

                digitShapeCtrl = Control(name + 'Shp' + str(i).zfill(2), parent=self.guideCtrlHrcGrp, shape='circle')
                digitShapeCtrl.setColor('yellow')
                digitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
                digitShapeCtrl.getVisibilityAttr().connect(self.ctrlShapeToggle)

                digitCtrl.shapeCtrl = digitShapeCtrl

                if i == 2:
                    digitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
                else:
                    digitShapeCtrl.rotatePoints(0.0, 0.0, 90.0)

                fingerGuideCtrls.append(digitShapeCtrl)

                # Add size attr to all but last guide control
                digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=digitCtrl)
                digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
                digitSizeAttributes.append(digitSizeAttr)
            else:
                digitCtrl.scalePoints(Vec3(0.0875, 0.0875, 0.0875))

            digitCtrl.lockScale(True, True, True)

            self.fingers[name].append(digitCtrl)

            parent = digitCtrl

        # ===========================
        # Create Canvas Operators
        # ===========================
        # Add Finger Guide Canvas Op
        fingerGuideCanvasOp = CanvasOperator(name + 'FingerGuideOp', 'Kraken.Solvers.Biped.BipedFingerGuideSolver')
        self.addOperator(fingerGuideCanvasOp)

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

        # Add Xfo Inputs
        fingerGuideCanvasOp.setInput('controls', self.fingers[name])
        fingerGuideCanvasOp.setInput('planeSizes', digitSizeAttributes)

        # Add Xfo Outputs
        fingerGuideCanvasOp.setOutput('result', fingerGuideCtrls)
        fingerGuideCanvasOp.setOutput('forceEval', firstDigitCtrl.getVisibilityAttr())

        return firstDigitCtrl