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': for each in armGuide.getItems().values(): # Only log hierarchy for Layer objects as Layers in this test are added to # the component since there is no rig object. if each.isTypeOf('Layer'): logHierarchy(each) elif mode == 'rig': for each in arm.getItems().values(): # Only log hierarchy for Layer objects as Layers in this test are added to # the component since there is no rig object. if each.isTypeOf('Layer'): logHierarchy(each)
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()
from kraken.core.maths import Xfo, Vec3, Quat from kraken_components.biped.arm_component import ArmComponentGuide, ArmComponentRig # from kraken.core.io.kraken_saver import KrakenSaver # from kraken.core.io.kraken_loader import KrakenLoader from kraken.core.profiler import Profiler from kraken.helpers.utility_methods import logHierarchy Profiler.getInstance().push("arm_persistence") armGuide = ArmComponentGuide("arm") 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 })
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("neck") neckComponentGuide.loadData({ "location": "M", "neckXfo": Xfo(ori=Quat( Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 16.0, -0.75), sc=Vec3(1.00000011921, 1.0, 1.00000011921)), "neckMidXfo": Xfo(ori=Quat( Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 16.5, -0.5), sc=Vec3(1.00000011921, 1.0, 1.00000011921)), "neckEndXfo": Xfo(ori=Quat( Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 17.0, -0.25), sc=Vec3(1.0, 1.0, 1.0)) }) neckComponent = NeckComponentRig("neck", self) neckComponent.loadData(neckComponentGuide.getRigBuildData()) headComponent = HeadComponentRig("head", self) headComponent.loadData( data={ "headXfo": Xfo(Vec3(0.0, 17.5, -0.5)), "eyeLeftXfo": Xfo(tr=Vec3(0.375, 18.5, 0.5), ori=Quat(Vec3(-0.0, -0.707106769085, -0.0), 0.707106769085)), "eyeRightXfo": Xfo(tr=Vec3(-0.375, 18.5, 0.5), ori=Quat(Vec3(-0.0, -0.707106769085, -0.0), 0.707106769085)), "jawXfo": Xfo(Vec3(0.0, 17.875, -0.275)) }) clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle") 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()) clavicleRightComponentGuide = ClavicleComponentGuide("clavicle") 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)) }) 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') spineGlobalSrtInput = spineComponent.getInputByName('globalSRT') spineGlobalSrtInput.setConnection(mainSrtOffsetOutput) spineRigScaleInput = spineComponent.getInputByName('rigScale') spineRigScaleInput.setConnection(mainSrtRigScaleOutput) # Neck to Main SRT neckGlobalSrtInput = neckComponent.getInputByName('globalSRT') neckGlobalSrtInput.setConnection(mainSrtOffsetOutput) # Neck to Spine spineEndOutput = spineComponent.getOutputByName('spineEnd') neckSpineEndInput = neckComponent.getInputByName('neckBase') neckSpineEndInput.setConnection(spineEndOutput) # Head to Main SRT headGlobalSrtInput = headComponent.getInputByName('globalSRT') headGlobalSrtInput.setConnection(mainSrtOffsetOutput) headBaseInput = headComponent.getInputByName('worldRef') headBaseInput.setConnection(mainSrtOffsetOutput) # Head to Neck neckEndOutput = neckComponent.getOutputByName('neckEnd') headBaseInput = headComponent.getInputByName('neckRef') 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('root') armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput) clavicleRightEndOutput = clavicleRightComponent.getOutputByName( 'clavicleEnd') armRightClavicleEndInput = armRightComponent.getInputByName('root') 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()
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("neck") neckComponentGuide.loadData({ "location": "M", "neckXfo": Xfo(ori=Quat(Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 16.0, -0.75), sc=Vec3(1.00000011921, 1.0, 1.00000011921)), "neckMidXfo": Xfo(ori=Quat(Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 16.5, -0.5), sc=Vec3(1.00000011921, 1.0, 1.00000011921)), "neckEndXfo": Xfo(ori=Quat(Vec3(-0.371748030186, -0.601501047611, 0.371748059988), 0.601500988007), tr=Vec3(0.0, 17.0, -0.25), sc=Vec3(1.0, 1.0, 1.0)) }) neckComponent = NeckComponentRig("neck", self) neckComponent.loadData(neckComponentGuide.getRigBuildData()) headComponent = HeadComponentRig("head", self) headComponent.loadData(data={ "headXfo": Xfo(Vec3(0.0, 17.5, -0.5)), "eyeLeftXfo": Xfo(tr=Vec3(0.375, 18.5, 0.5), ori=Quat(Vec3(-0.0, -0.707106769085, -0.0), 0.707106769085)), "eyeRightXfo": Xfo(tr=Vec3(-0.375, 18.5, 0.5), ori=Quat(Vec3(-0.0, -0.707106769085, -0.0), 0.707106769085)), "jawXfo": Xfo(Vec3(0.0, 17.875, -0.275)) }) clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle") 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()) clavicleRightComponentGuide = ClavicleComponentGuide("clavicle") 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)) }) 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') spineGlobalSrtInput = spineComponent.getInputByName('globalSRT') spineGlobalSrtInput.setConnection(mainSrtOffsetOutput) spineRigScaleInput = spineComponent.getInputByName('rigScale') spineRigScaleInput.setConnection(mainSrtRigScaleOutput) # Neck to Main SRT neckGlobalSrtInput = neckComponent.getInputByName('globalSRT') neckGlobalSrtInput.setConnection(mainSrtOffsetOutput) # Neck to Spine spineEndOutput = spineComponent.getOutputByName('spineEnd') neckSpineEndInput = neckComponent.getInputByName('neckBase') neckSpineEndInput.setConnection(spineEndOutput) # Head to Main SRT headGlobalSrtInput = headComponent.getInputByName('globalSRT') headGlobalSrtInput.setConnection(mainSrtOffsetOutput) headBaseInput = headComponent.getInputByName('worldRef') headBaseInput.setConnection(mainSrtOffsetOutput) # Head to Neck neckEndOutput = neckComponent.getOutputByName('neckEnd') headBaseInput = headComponent.getInputByName('neckRef') 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('root') armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput) clavicleRightEndOutput = clavicleRightComponent.getOutputByName('clavicleEnd') armRightClavicleEndInput = armRightComponent.getInputByName('root') 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()
""" nameTemplate = super(CustomConfig, self).initNameTemplate() nameTemplate["formats"] = { "Container": ["name"], "Layer": ["container", "sep", "name"], "ComponentGroup": ["location", "sep", "name", "sep", "type"], "default": ["location", "sep", "component", "sep", "name", "sep", "type"], } return nameTemplate armGuide = ArmComponentGuide("arm") 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 }) armGuideData = armGuide.getRigBuildData() arm = ArmComponentRig()
for i in xrange(self.component.getNumAttributeGroups()): attrGrp = self.component.getAttributeGroupByIndex(i) if attrGrp.getName() == "implicitAttrGrp": continue grp = self.component.getAttributeGroupByIndex(i) self.addSeparator(grp.getName()) for j in xrange(grp.getNumAttributes()): displayAttribute(grp.getAttributeByIndex(j)) # Add a stretch so that the widgets pack at the top. self.addStretch(2) # ======= # Events # ======= def closeEvent(self, event): if self.nodeItem is not None: self.nodeItem.inspectorClosed() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) from kraken_components.biped.arm_component import ArmComponentGuide armGuide = ArmComponentGuide("arm") widget = ComponentInspector(component=armGuide) widget.show() sys.exit(app.exec_())
from kraken import plugins from kraken.core.maths import Xfo, Vec3, Quat from kraken_components.biped.arm_component import ArmComponentGuide, ArmComponentRig from kraken.core.profiler import Profiler from kraken.helpers.utility_methods import logHierarchy Profiler.getInstance().push("arm_component_symmetry") 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') rightArmGuide.setLocation('R') rightArmGuide.pasteData(leftArmGuide.copyData(), setLocation=False) builder = plugins.getBuilder()