def __mirrorData(jsonData, plane): if isinstance(jsonData, Vec3): return jsonData if isinstance(jsonData, Quat): newQuat = Quat(jsonData) newQuat.mirror(plane) return newQuat elif isinstance(jsonData, Xfo): newXfo = Xfo(jsonData) if plane == 0: newXfo.tr.x = -newXfo.tr.x elif plane == 1: newXfo.tr.y = -newXfo.tr.y elif plane == 2: newXfo.tr.z = -newXfo.tr.z newXfo.ori.mirror(plane) return newXfo elif type(jsonData) is list: newList = [] for item in jsonData: newList.append(__mirrorData(item, plane)) return newList elif type(jsonData) is dict: newDict = {} for key, value in jsonData.iteritems(): newDict[key] = __mirrorData(value, plane) return newDict return jsonData
def __init__(self, name='head', parent=None, *args, **kwargs): Profiler.getInstance().push("Construct Head Guide Component:" + name) super(HeadComponentGuide, self).__init__(name, parent, *args, **kwargs) # ========= # Controls # ========= guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self) sphereCtrl = Control('sphere', shape='sphere') sphereCtrl.scalePoints(Vec3(0.375, 0.375, 0.375)) self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape='square') self.headCtrl.rotatePoints(90, 0, 0) self.headCtrl.translatePoints(Vec3(0.0, 0.5, 0.0)) self.headCtrl.scalePoints(Vec3(1.8, 2.0, 2.0)) self.eyeLeftCtrl = Control('eyeLeft', parent=self.headCtrl, shape='arrow_thin') self.eyeLeftCtrl.translatePoints(Vec3(0, 0, 0.5)) self.eyeLeftCtrl.rotatePoints(0, 90, 0) self.eyeLeftCtrl.appendCurveData(sphereCtrl.getCurveData()) self.eyeRightCtrl = Control('eyeRight', parent=self.headCtrl, shape='arrow_thin') self.eyeRightCtrl.translatePoints(Vec3(0, 0, 0.5)) self.eyeRightCtrl.rotatePoints(0, 90, 0) self.eyeRightCtrl.appendCurveData(sphereCtrl.getCurveData()) self.jawCtrl = Control('jaw', parent=self.headCtrl, shape='square') self.jawCtrl.rotatePoints(90, 0, 0) self.jawCtrl.rotatePoints(0, 90, 0) self.jawCtrl.translatePoints(Vec3(0.0, -0.5, 0.5)) self.jawCtrl.scalePoints(Vec3(1.0, 0.8, 1.5)) self.jawCtrl.setColor('orange') eyeXAlignOri = Quat() eyeXAlignOri.setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(-90)) self.default_data = { "name": name, "location": "M", "headXfo": Xfo(Vec3(0.0, 17.5, -0.5)), "headCrvData": self.headCtrl.getCurveData(), "eyeLeftXfo": Xfo(tr=Vec3(0.375, 18.5, 0.5), ori=eyeXAlignOri), "eyeLeftCrvData": self.eyeLeftCtrl.getCurveData(), "eyeRightXfo": Xfo(tr=Vec3(-0.375, 18.5, 0.5), ori=eyeXAlignOri), "eyeRightCrvData": self.eyeRightCtrl.getCurveData(), "jawXfo": Xfo(Vec3(0.0, 17.875, -0.275)), "jawCrvData": self.jawCtrl.getCurveData() } self.loadData(self.default_data) Profiler.getInstance().pop()
def getRigBuildData(self): """Returns the Guide data used by the Rig Component to define the layout of the final rig.. Return: The JSON rig data object. """ data = super(FKCollisionComponentGuide, self).getRigBuildData() numJoints = self.numJoints.getValue() # Calculate Xfos boneXfos = [] boneLengths = [] for i in xrange(numJoints): boneVec = self.jointCtrls[i + 1].xfo.tr.subtract( self.jointCtrls[i].xfo.tr) boneLengths.append(boneVec.length()) xfo = Xfo() q = Quat() q.setFromDirectionAndUpvector( boneVec.unit(), self.jointCtrls[i].xfo.ori.getYaxis()) qDir = Quat().setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(-90)) xfo.ori = q * qDir xfo.tr = self.jointCtrls[i].xfo.tr boneXfos.append(xfo) data['jointXfos'] = [x.xfo for x in self.jointCtrls] data['boneXfos'] = boneXfos data['endXfo'] = self.jointCtrls[-1].xfo data['boneLengths'] = boneLengths return data
def evaluate(self): """invokes the constraint causing the output value to be computed. Return: Boolean, True if successful. """ if self.getMaintainOffset() is False: newOri = Quat(); newOri.set(Vec3(), 0.0) for constrainer in self.getConstrainers(): newOri = newOri.add(constrainer.xfo.ori) newOri.setUnit() self.getConstrainee().xfo.ori = newOri 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
def __init__(self, name='arm', parent=None): Profiler.getInstance().push("Construct Arm Guide Component:" + name) super(ArmComponentGuide, self).__init__(name, parent) # =========== # Attributes # =========== # Add Component Params to IK control guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self) self.bicepFKCtrlSizeInputAttr = ScalarAttribute( 'bicepFKCtrlSize', value=1.75, minValue=0.0, maxValue=10.0, parent=guideSettingsAttrGrp) self.forearmFKCtrlSizeInputAttr = ScalarAttribute( 'forearmFKCtrlSize', value=1.5, minValue=0.0, maxValue=10.0, parent=guideSettingsAttrGrp) # ========= # Controls # ========= # Guide Controls self.bicepCtrl = Control('bicepFK', parent=self.ctrlCmpGrp, shape="sphere") self.bicepCtrl.setColor('blue') self.forearmCtrl = Control('forearmFK', parent=self.ctrlCmpGrp, shape="sphere") self.forearmCtrl.setColor('blue') self.wristCtrl = Control('wristFK', parent=self.ctrlCmpGrp, shape="sphere") self.wristCtrl.setColor('blue') self.handCtrl = Control('hand', parent=self.ctrlCmpGrp, shape="cube") self.handCtrl.setColor('blue') data = { "name": name, "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 } self.loadData(data) Profiler.getInstance().pop()