Example #1
0
def rotateOrientOrTransform(node,
                            rotation,
                            preserveChildren=True,
                            preserveShapes=True,
                            syncJointAxes=True):
    """
    Rotate a node in local space, or if its a joint, by
    modifying the joint orient. Additionally, can preserve
    child transform positions and/or shapes (such as control cvs).

    Args:
        node:
        rotation:
        preserveChildren:
        preserveShapes:
        syncJointAxes (bool): If True, joints will also have their
            translate and scale axes updated to match the new orientation
    """
    if node.nodeType() == 'joint':
        rotateJointOrient(node, rotation)
        if syncJointAxes:
            matchJointRotationToOrient(node, preserveChildren)
    else:
        pm.rotate(node, rotation, os=True, r=True, pcp=preserveChildren)

        # normalize eulers to 0..360, assumed as part of orienting
        normalizeEulerRotations(node)

        if preserveShapes:
            shapes = node.getShapes()
            for shape in shapes:
                rotateComponents(shape, -rotation)
Example #2
0
def CreateBallCTRL(CTRL_name, rad):
    
    nurbCTRL = cmds.circle( n = str(CTRL_name), nr =(1,0,0), c=(0, 0, 0), r= rad )
    nurbCTRL1 = cmds.circle( n = str('circle1'), nr =(0,0,1), c=(0, 0, 0), r= rad )
    nurbCTRL2 = cmds.circle( n = str('circle2'), nr =(0,1,0), c=(0, 0, 0), r= rad )

    nurbCTRL3 = cmds.circle( n = str('circle3'), nr =(1,0,0), c=(0, 0, 0), r= rad )
    pm.rotate(nurbCTRL3, [0,0,45])

    nurbCTRL4 = cmds.circle( n = str('circle4'), nr =(1,0,0), c=(0, 0, 0), r= rad )
    pm.rotate(nurbCTRL4, [0,0,-45])

    CleanHist(nurbCTRL[0])
    CleanHist(nurbCTRL1[0])
    CleanHist(nurbCTRL2[0])
    CleanHist(nurbCTRL3[0])
    CleanHist(nurbCTRL4[0])

    ReparentShape(nurbCTRL4, nurbCTRL)
    ReparentShape(nurbCTRL3, nurbCTRL)
    ReparentShape(nurbCTRL2, nurbCTRL)    
    ReparentShape(nurbCTRL1, nurbCTRL)    

    CleanHist(nurbCTRL[0])
    offset_GRP = pm.group( em=True, name= str(CTRL_name) + '_offset_GRP' )
    #pm.parent(nurbCTRL[0], offset_GRP)
    
    RecolourObj(CTRL_name)
Example #3
0
def maketext(t=u"temptext",name = u"temptext", p=[0,0,0], r=[0,0,0], s=0.1) :
    t = str(t)
    obj = pm.textCurves(n = name, t=t, f ='Courier')
    pm.move(obj[0], p[0],p[1],p[2])
    pm.rotate(obj[0],r[0],r[1],r[2])
    pm.scale(obj[0],s,s,s)
    return obj[0]
Example #4
0
def threePointlight( type):
    """
        description:

        inputs:

        outputs

    """
    l = ["keyLight", "rimLight", "fillLight"]

    if type == "directional":
        pm.rendering.directionalLight(n = l[0], i = 1.0, rgb = [1.0, 0.9, 0.8])
        pm.rendering.directionalLight(n = l[1], i = 2.0, rgb = [1.0, 0.9, 0.8])
        pm.rendering.directionalLight(n = l[2], i = 0.5, rgb = [0.6, 0.7, 0.8])

    elif type == "point":
        pm.rendering.pointLight(n = l[0])
        pm.rendering.pointLight(n = l[1])
        pm.rendering.pointLight(n = l[2])

    pm.rotate(l[0], [-44.5, 120, 0])
    pm.rotate(l[1], [-13, -55, 0])
    pm.scale(l[0], [4,4,4])
    pm.scale(l[1], [4,4,4])
    pm.scale(l[2], [4,4,4])
    return l
Example #5
0
	def _createMCurves(self , list = None):
		'''
		@list : list , This is the list is list
		'''
		if  list is None:
			OpenMaya.MGlobal_displayError('@list : This is the list is None : list = %s'%(list))
			return
		listCtrName = [] 
		
		for obj in list:
		
			ctrlMList = self.createCurves(obj.name() , 1)
						
			if ctrlMList[0].name().find('L') is -1:
				for a in ctrlMList:
					for s in a.getShapes():
						pm.rotate(s.cv , 0 , 180 , 0 , r = 1 )
					
			ctrlMList[0].getParent().getParent().setParent(self.featherCtrlGroup)
			obj.setParent(ctrlMList[0])
			#obj.v.set(0)
			self.featherDir[obj.name()] = ctrlMList
			
			listCtrName.append(ctrlMList)
		
		return listCtrName
Example #6
0
def createWtDriver(joint, target, rotation=(0, 0, 0), angle=None):

    joint = pm.ls(joint)[0]
    target = pm.ls(target)[0]

    angle = angle or sum(rot**2 for rot in rotation)**(1.0 / 2)
    invert = joint.name()[-2:] == '_L'

    wtdrv = pm.createNode('weightDriver')
    pm.rename(wtdrv.getParent(), 'wtDrv_{}1'.format(joint.name()))

    pm.delete(pm.parentConstraint(joint, wtdrv.getParent()))

    pm.rotate(wtdrv, rotation, os=True, r=True)

    pm.parentConstraint(joint.getParent(), wtdrv.getParent(), mo=True)

    # Connect matrices
    wtdrv.getParent().worldMatrix[0].connect(wtdrv.readerMatrix)
    target.worldMatrix[0].connect(wtdrv.driverMatrix)

    # Set weightDriver attributes
    wtdrv.angle.set(angle)
    wtdrv.invert.set(invert)
    wtdrv.blendCurve[0].blendCurve_Interp.set(1)

    return wtdrv
Example #7
0
def CreateCircleCTRL(CTRL_name, CTRL_list, prntJnt, norm, rad, offset):

    #create CTRL and offset grp
    CTRL = cmds.circle(n=str(CTRL_name), nr=norm, c=(0, 0, 0), r=rad)
    offset_GRP = pm.group(em=True, name=str(CTRL_name) + '_offset_GRP')
    pm.parent(CTRL[0], offset_GRP)

    # clear history for both objects
    CleanHist(CTRL[0])
    CleanHist(offset_GRP)

    # temp parentconstr GRP to move to pos (with rot)
    tempConst = pm.parentConstraint(prntJnt, str(offset_GRP), mo=False)
    pm.delete(tempConst)

    # rotate curve CVs
    curveCVs = cmds.ls('{0}.cv[:]'.format(CTRL[0]), fl=True)
    pm.rotate(curveCVs, offset)

    # parent const to joint
    pm.parentConstraint(str(CTRL_name), str(prntJnt), mo=False, w=1)

    # recolor CTRL and add to list
    RecolourObj(CTRL_name, 'nurbsCurve')
    CTRL_list.append(offset_GRP)
Example #8
0
def armAlign(shoulderCard, angle=2.0):
    ''' Rotates the lead joint to point down the +X axis, and the other joints
    to be almost straight, with a slight bend pointing behind, -Z.

    angle: In degrees, how much it is bent from +X axis

    MUST have a parent joint to rotate properly
    ASSUMES elbow already points backwards
    ASSUMES 3 joint humaniod arm
    '''
    shoulderJoint = shoulderCard.joints[0]

    shoulderRepose = getRJoint(shoulderJoint)

    xform(getCardParent(shoulderRepose), ws=True, ro=[0, 0, 90])

    out = pdil.dagObj.getPos(getRJoint(
        shoulderCard.joints[1])) - pdil.dagObj.getPos(
            getRJoint(shoulderCard.joints[0]))
    toRotate = math.degrees(out.angle((1, 0, 0)))
    rotate(
        shoulderRepose, [0, -toRotate + angle, 0], ws=True, r=True
    )  # &&& Assumption is that -toRotate will align with +X axis, then offest by `angle`

    elbowRepose = getRJoint(shoulderCard.joints[1])
    out = pdil.dagObj.getPos(getRJoint(
        shoulderCard.joints[2])) - pdil.dagObj.getPos(
            getRJoint(shoulderCard.joints[1]))
    toRotate = math.degrees(out.angle((1, 0, 0)))
    rotate(elbowRepose, [0, toRotate - angle, 0], ws=True, r=True)
Example #9
0
def build_head():
    headJnts = pm.ls('*_head*_jnt')
    ctrl = rigUtils.createRigControl('circle')[0]
    pm.rotate(90, 0, 0)
    pm.makeIdentity(ctrl, a=True, t=True, r=True)

    pm.rename(ctrl, 'head_ctrl')
    rigUtils.setControlColor(ctrl)

    pm.delete(pm.pointConstraint(headJnts[0], ctrl))
    orientConst = pm.orientConstraint(headJnts[0], ctrl, mo=False)

    pm.delete(orientConst)
    pm.makeIdentity(ctrl, a=True, t=True, r=True)

    pm.parent(headJnts[0], ctrl)

    headGrp = pm.group(n='head_grp', em=True)
    pm.parent(ctrl, headGrp)

    spineJntList = pm.ls('M_spine*_jnt')
    pm.parent(headGrp, 'neck_ctrl')
    rigUtils.hideAttributes(ctrl=ctrl,
                            trans=True,
                            rot=False,
                            scale=True,
                            vis=True,
                            radius=False)

    pm.delete(ctrl, ch=1)
Example #10
0
def legAlign(legCard):
    ''' Maintains the z postion of the end joint while putting it into the YZ plane.
    '''

    rCard = getCardParent(getRJoint(legCard.joints[0]))
    start = getRJoint(legCard.joints[0])
    end = getRJoint(legCard.end())
    ''' We need to preserve the z position of the end joint,
    so use that z component, but the out vector length doesn't change.
    '''

    out = pdil.dagObj.getPos(end) - pdil.dagObj.getPos(start)

    desiredAngleFromVertical = math.asin(out.z / out.length())
    ''' Then zero the rotations, and do the same calculations to see how off it is.
    '''
    xform(rCard, ws=True, ro=[0, 0, 0])

    planeStartPos = pdil.dagObj.getPos(start)
    planeEndPos = pdil.dagObj.getPos(end)

    planeOut = planeEndPos - planeStartPos
    currentAngleFromVertical = math.asin(planeOut.z / planeOut.length())

    #-
    xRot = math.degrees(desiredAngleFromVertical - currentAngleFromVertical)

    xRot = math.copysign(xRot, planeOut.cross(out).x)

    rotate(rCard, [xRot, 0, 0], ws=True, r=True)
Example #11
0
def CreateBallCTRL(CTRL_name, CTRL_list, rad):

    # create nurb circles & rotate
    nurbCTRL = pm.circle(n=str(CTRL_name), nr=(1, 0, 0), c=(0, 0, 0), r=rad)
    nurbCTRL1 = pm.circle(n=str('circle1'), nr=(0, 0, 1), c=(0, 0, 0), r=rad)
    nurbCTRL2 = pm.circle(n=str('circle2'), nr=(0, 1, 0), c=(0, 0, 0), r=rad)

    nurbCTRL3 = pm.circle(n=str('circle3'), nr=(1, 0, 0), c=(0, 0, 0), r=rad)
    pm.rotate(nurbCTRL3, [0, 0, 45])

    nurbCTRL4 = pm.circle(n=str('circle4'), nr=(1, 0, 0), c=(0, 0, 0), r=rad)
    pm.rotate(nurbCTRL4, [0, 0, -45])

    # clean all history
    CleanHist(nurbCTRL[0])
    CleanHist(nurbCTRL1[0])
    CleanHist(nurbCTRL2[0])
    CleanHist(nurbCTRL3[0])
    CleanHist(nurbCTRL4[0])

    # reparent shapes
    ReparentShape(nurbCTRL4, nurbCTRL)
    ReparentShape(nurbCTRL3, nurbCTRL)
    ReparentShape(nurbCTRL2, nurbCTRL)
    ReparentShape(nurbCTRL1, nurbCTRL)

    CleanHist(nurbCTRL[0])

    # create offset GRP, parent CTRL to it and add CTRL to list
    offset_GRP = pm.group(em=True, name=str(CTRL_name) + '_offset_GRP')

    RecolourObj(CTRL_name, 'nurbsCurve')
    CTRL_list.append(offset_GRP)
Example #12
0
    def move_object_pivot_to_selected_component(component):
        obj = pm.PyNode(component.split(".")[0]).getParent()
        loc = pm.spaceLocator()

        pm.select(component)
        pm.select(loc, add=True)

        pm.mel.eval(
            'doCreatePointOnPolyConstraintArgList 1 {"0" ,"0" ,"0" ,"1" ,"" ,"1"};'
        )
        poly_constraint = pm.listRelatives(loc, type="constraint")
        pm.delete(poly_constraint)
        pm.rotate(loc, [0, 0, '-180deg'], r=True, fo=True, os=True)

        obj_parent = pm.listRelatives(obj, p=True)

        pivot_translate = pm.xform(loc, q=True, ws=True, rotatePivot=True)
        obj.setParent(loc)
        pm.makeIdentity(
            obj, a=True, t=True, r=True,
            s=True)  # Freeze transform to match rotation of locator
        pm.xform(obj, pivots=pivot_translate, ws=True)
        pm.manipPivot(o=(0, 0, 180))  # Rotate pivot to face inwards

        if obj_parent:
            obj.setParent(obj_parent)
        else:
            obj.setParent(world=True)

        pm.delete(loc)

        for component in component_array:  # Select objects of faces when done
            to_select = obj
            select_array.append(to_select)
            pm.select(select_array)
Example #13
0
    def rotateNinety(self):
        mirrorAxis = self.rotate_axis
        maintainChildren = self.maintain_children
        maintainShape = self.maintain_shape
        sign = self.negative_rotate

        rotVector = pm.dt.Vector(mirrorAxis) * 90.0
        if not sign:
            rotVector *= -1.0
        newRotation = pm.dt.EulerRotation(rotVector, unit='degrees').asQuaternion()

        objs = pm.selected()
        for obj in objs:
            children = []
            if maintainChildren:
                for child in obj.getChildren(type=pm.nt.Transform):
                    child.setParent(None)
                    children.append(child)
            obj.rotateBy(newRotation, 'preTransform')
            if children and maintainChildren:
                for child in children:
                    child.setParent(obj)
            if maintainShape:
                for shape in obj.getShapes():
                    if isinstance(shape, pm.nt.Mesh):
                        pm.rotate(shape.vtx, rotVector * -1.0, os=1)
                    elif isinstance(shape, pm.nt.NurbsCurve):
                        pm.rotate(shape.cv, rotVector * -1.0, os=1)

        pm.select(objs, r=True)
Example #14
0
 def rotateComponents(self, rotation):
     for node in pm.selected():
         for shape in node.getShapes():
             if isinstance(shape, pm.nt.Mesh):
                 pm.rotate(shape.vtx, rotation, os=1)
             elif isinstance(shape, pm.nt.NurbsCurve):
                 pm.rotate(shape.cv, rotation, os=1)
Example #15
0
def makeLantern():
	#clear workspace
	cmds.select(all=True)
	cmds.delete()
	
	#get values from sliders
	ridges = cmds.intSliderGrp(ridgesSlider, q=True, value=True)
	deform = cmds.intSliderGrp(deformSlider, q=True, value=True)
	bend = cmds.intSliderGrp(bendSlider, q=True, value=True)
	bendNum = bend/100.0+1.0
	flatten = float(cmds.intSliderGrp(flattenSlider, q=True, value=True))

	
	lantern = pm.polySphere(n='lantern', sx=10, r=1, sy=ridges)
	rings = pm.polySelect( lantern, er=1)
	pm.select(lantern, cl=True)
	toggle = True
	for i in rings:
	    if toggle:
	        pm.polySelect( lantern, el=i)
	        pm.scale(pm.selected(), [bendNum,bendNum,bendNum], xz=True)
	    toggle = not toggle
	pm.select(lantern)
	pm.displaySmoothness(divisionsU=3, divisionsV=3, pointsWire=16, pointsShaded=4, polygonObject=3)
	wave = pm.nonLinear(type='wave', amplitude=0.03)
	pm.setAttr(wave[0]+'.wavelength', deform/100+0.1)
	pm.rotate(wave, 0, 0, '45deg')
	pm.select(all=True)
	pm.scale(lantern, [1,1-(flatten/100),1], xyz=True)
	pm.delete(ch=True)
Example #16
0
def _buildDrivers(name, xforms, controls, **kwargs):
    ctrl_orient = kwargs.get('ctrl_orient', None)

    # Create IK joints
    joints = createNodeChain(xforms, node_func=partial(
        pm.createNode, 'joint'), prefix='ikj_')
    for joint in joints:
        pm.makeIdentity(joint, apply=True)

    # Place control curve
    controls[0].getParent().setTransformation(xforms[-1].getMatrix(ws=True))

    if ctrl_orient:
        pm.rotate(controls[0].getParent(), ctrl_orient)

    # Create IK chain
    ik_handle, _ = pm.ikHandle(n="Ik_{}_handle".format(name),
                               sj=joints[0], ee=joints[-1])
    ik_handle.setParent(controls[0])

    # Constrain end driver joint
    pm.orientConstraint(controls[0], joints[-1], mo=True)

    # Hide intermediate nodes
    for node in joints + [ik_handle]:
        node.visibility.set(False)

    return joints
Example #17
0
    def bdBuildSphereController(self):
        circleA = pm.circle(n=self.ctrlName + 'A',
                            nr=(0, 1, 0),
                            c=(0, 0, 0),
                            radius=self.ctrlScale)
        circleB = pm.circle(n=self.ctrlName + 'B',
                            nr=(1, 0, 0),
                            c=(0, 0, 0),
                            radius=self.ctrlScale)
        circleC = pm.circle(n=self.ctrlName + 'C',
                            nr=(0, 0, 1),
                            c=(0, 0, 0),
                            radius=self.ctrlScale)

        circleBShape = pm.listRelatives(circleB[0], c=True)
        circleCShape = pm.listRelatives(circleC[0], c=True)
        pm.parent(circleBShape[0], circleA[0], r=True, s=True)
        pm.parent(circleCShape[0], circleA[0], r=True, s=True)
        pm.delete(circleB, circleC)
        ctrl = pm.rename(circleA[0], self.ctrlName)
        ctrlGrp = pm.group(ctrl, n=self.ctrlName + '_grp')

        pm.move(ctrlGrp, self.ctrlPos[0], self.ctrlPos[1], self.ctrlPos[2])
        pm.rotate(ctrlGrp, self.ctrlRot[0], self.ctrlRot[1], self.ctrlRot[2])

        self.ctrlGrp = ctrlGrp
Example #18
0
def createJointOffset(Offset):
    if Offset == "":
        Offset = "Offset"
    selectJoints = pm.selected()

    for joint in selectJoints: 
        offsetObjName = ""
        if prefix.getSelect() == 1: #置き換え
            offsetObjName = re.sub(r"^[a-zA-Z]*?_",Offset+"_",str(joint))
        elif prefix.getSelect() == 2: #追加
            offsetObjName = str(Offset) + "_" + str(joint)  
        offsetObj = pm.group(em = True,name = offsetObjName)
        jointName = re.sub(r"^[a-zA-Z]*?_","Rig_",offsetObjName)
        pm.circle( name=jointName )
        pm.select(jointName,r=30)
        # 回転の軸がなんでこれで(Z)いいのかわからないので確認する。
        pm.rotate(0,0,90,r = True)
        pm.scale(2,2,2)
        pm.makeIdentity(apply=True,t=1,r=1,s=1,n=0,pn=1)
        pm.parent(jointName,offsetObj)
        #AにBをコンストレイント!
        pm.parentConstraint(joint,offsetObj, weight=1)
        #必要のないコンストレイントノードの削除
        delNode = offsetObj.listRelatives(c=True,ad=True,type='constraint')
        pm.delete(delNode)
Example #19
0
def quickDyn(spread=5, num=10, joints=False, bake=False):
    target = []
    g = py.gravity()

    for i in range(0,num):
        c = py.polyCube()
        target.append(c)
        x = rnd(-spread,spread)
        y = rnd(-spread,spread) + 10
        z = rnd(-spread,spread)
        py.move(x,y,z)
        py.rotate(x,y,z)

    s(target)
    py.rigidBody()

    for i in range(0,len(target)):
        py.connectDynamic(target[i],f=g)

    if(joints==False and bake==True):
        bakeAnimation(target)
        
    if(joints==True):
        target2 = []

        for i in range(0,len(target)):
            s(target[i])
            jnt = py.joint()
            target2.append(jnt)
            
        if(bake==True):
            bakeAnimation(target2)

        for i in range(0,len(target2)):
            unparent(target2[i])
Example #20
0
    def buildBoxController(self):
        defaultPointsList = [(1, -1, 1), (1, -1, -1), (-1, -1, -1),
                             (-1, -1, 1), (1, 1, 1), (1, 1, -1), (-1, 1, -1),
                             (-1, 1, 1)]
        pointsList = []
        for p in defaultPointsList:
            pointsList.append((p[0] * self.ctrlScale, p[1] * self.ctrlScale,
                               p[2] * self.ctrlScale))

        knotsList = [i for i in range(16)]
        curvePoints = [
            pointsList[0], pointsList[1], pointsList[2], pointsList[3],
            pointsList[7], pointsList[4], pointsList[5], pointsList[6],
            pointsList[7], pointsList[3], pointsList[0], pointsList[4],
            pointsList[5], pointsList[1], pointsList[2], pointsList[6]
        ]

        ctrl = pm.curve(d=1, p=curvePoints, k=knotsList)
        ctrl = pm.rename(ctrl, self.ctrlName)
        ctrlGrp = pm.group(ctrl, n=str(self.ctrlName + '_grp'))

        # pm.addAttr(ctrl,ln='parent',at='message')
        # pm.connectAttr(ctrlGrp.name() + '.message' , ctrl.name() + '.parent')

        pm.move(ctrlGrp, self.ctrlPos[0], self.ctrlPos[1], self.ctrlPos[2])
        pm.rotate(ctrlGrp, self.ctrlRot[0], self.ctrlRot[1], self.ctrlRot[2])
        self.ctrlGrp = ctrlGrp
Example #21
0
 def createGroups(self):
     pm.select(cl=1)
     self.mainGrp = pm.group(n=self.name + '_grp')
     pm.select(cl=1)
     self.jntGrp = pm.group(name=self.name+'_ik_jnt_grp')
     pm.rotate(self.jntGrp ,0,-90,0,r=1)
     pm.parent(self.jntGrp,self.mainGrp)
     pm.select(cl=1)
Example #22
0
 def createGroups(self):
     pm.select(cl=1)
     self.mainGrp = pm.group(n=self.name + '_grp')
     pm.select(cl=1)
     self.jntGrp = pm.group(name=self.name + '_ik_jnt_grp')
     pm.rotate(self.jntGrp, 0, -90, 0, r=1)
     pm.parent(self.jntGrp, self.mainGrp)
     pm.select(cl=1)
Example #23
0
def rotateJointOrient(joint, rotation):
    """
    Rotate the orientation of a joint

    Args:
        joint (Joint): The joint to modify
        rotation (Vector): The rotation to apply to the orient
    """
    pm.rotate(joint.rotateAxis, rotation, r=True, os=True)
Example #24
0
def rotate_curve(x, y, z, obj):
    X = 0.0
    Y = 0.0
    Z = 0.0
    if x:
        X = x
    if y:
        Y = y
    if z:
        Z = z
    pmc.rotate(obj, X, Y, Z)
Example #25
0
 def size(self):
     connectorRotation = position.get(tempConnectorName)[1]
     py.rotate(tempConnectorName, (0, 0, 0))
     connectorBoundingBox = py.ls(tempConnectorName)[0].getBoundingBox()
     py.rotate(tempConnectorName, connectorRotation)
     connectorWidth = round(connectorBoundingBox.width(), locationPrecision)
     connectorHeight = round(connectorBoundingBox.height(),
                             locationPrecision)
     connectorDepth = round(connectorBoundingBox.depth() / 3.625,
                            locationPrecision)
     return [connectorWidth, connectorHeight, connectorDepth]
Example #26
0
	def _PlumeJiont(self , rootJoint = None , endJoint = None , name = None):
		'''
		@rootJoint : str  node , This is the rootJoint of is joint node
		@endJoint : str Node , This is the endJoint is joint node
		@name : str , this is ths name that will be used as a base for all the names
		'''
		
		jointGroup = self._objectGroup(rootJoint)
		
		lsitJoint = self.getObjectPoint(rootJoint.getTranslation(space = 'world') , endJoint.getTranslation(space = 'world') , num = 5)
		
		tupleListJoint = [(t[0] , t[1] , t[2]) for t in lsitJoint]
		
		bottomJoint = [pm.joint(n = name + '_' + str(i+1) , p = point1 ) for i , point1 in enumerate(tupleListJoint)]
		
		bottomJoint[0].orientJoint( 'xyz' , sao = 'yup' , zso = 1 , ch = 1)
		bottomJoint[-1].orientJoint( 'none' , sao = 'yup' , zso = 1 )

		if name.find('L') is -1:
			self._jointOrient(bottomJoint)
			
		bottomJointGroup = self._objectGroup(bottomJoint[0])
		
		bottomCtril = self.createCurves(bottomJoint[0].name() , 0 , ['Rx' ,'Ry' , 'Rz' , 'Rx1' , 'Ry1' , 'Rz1'])			
			
		if bottomCtril.name().find('L') is -1:
			for s in bottomCtril.getShapes():
					pm.rotate(s.cv , 0 , 0 , 180 , r = 1 )	
		
		if self.ctr.control.hasAttr('ctrl'):
						
			self.ctr.control.ctrl.connect(bottomCtril.getParent().getParent().v)
		
		bottomJointGroup.setParent(bottomCtril)
		
		bottomCtril.getParent().getParent().setParent(rootJoint)	

		PMANode = pm.createNode('plusMinusAverage', n = bottomJoint[0] + '_plus')
		
		bottomCtril.Rx.connect(PMANode.input3D[0].input3Dx)
		bottomCtril.Ry.connect(PMANode.input3D[0].input3Dy)
		bottomCtril.Rz.connect(PMANode.input3D[0].input3Dz)
		
		bottomCtril.Rx1.connect(PMANode.input3D[1].input3Dx)
		bottomCtril.Ry1.connect(PMANode.input3D[1].input3Dy)
		bottomCtril.Rz1.connect(PMANode.input3D[1].input3Dz)
		
		for a in bottomJoint:
			PMANode.output3Dx.connect(a.rx)
			PMANode.output3Dy.connect(a.ry)
			PMANode.output3Dz.connect(a.rz)

		return	jointGroup		
Example #27
0
def build():

    components = dict()
    # components['Spine'] = buildFkIkSpine(
    #     ('Root_M', 'Spine1_M', 'Spine2_M', 'Spine3_M', 'Chest_M'))

    for side in '_L', '_R':
        # Build components
        for c, spec in COMP_SPECS.items():
            cside = side
            if c.endswith('_M'):
                cside = ''
                if c in components:
                    continue

            cname = c + cside

            buildfn = spec['builder']
            xforms = [jn + cside for jn in spec['joints']]
            print('Building {2}({0}) with joints {1}'.format(
                buildfn.__name__, xforms, cname))

            components[cname] = buildfn(xforms, cname)

            # Set parents
            if spec.get('parent', None):
                parname = spec['parent'] if spec['parent'].endswith(
                    '_M') else spec['parent'] + cside
                pm.parentConstraint(parname,
                                    components[cname]['root'],
                                    mo=True)

    # Create main and COM controls
    main = createControlCurve(name='Main', size=40.0, color=(.15, 1, 1))
    pm.rotate(main, (0, 0, 90))
    pm.makeIdentity(main, apply=True)
    com = createControlCurve(name='CTRL_COM_M', shape='com', size=60.0)
    com.setMatrix(components['Spine_M']['root'].getMatrix(ws=True), ws=True)
    createOffset(com)
    com.getParent().setParent(main)

    # Add controls to ControlSet
    pm.select(None)
    ctrlset = pm.sets(name='ControlSet')

    # Parent under main control
    for component in components.values():
        component['root'].setParent(com)
        for unit in component['units']:
            print(unit['controls'])
            ctrlset.addMembers(unit['controls'])

    return components
Example #28
0
def build_arms():
	armBuilder.LimbGen(spacing=0, num_sections=5, side='L', base_name='arm')
	armBuilder.LimbGen(spacing=0, num_sections=5, side='R', base_name='arm')

	pm.rotate('R_arm0_rigHelper', (0, 180, 0))
	pm.move('L_arm0_rigHelper', (0.17, 1.6, 0))
	pm.move('R_arm0_rigHelper', (-0.17, 1.6, 0))


	# create the symmetry for each helper
	for i in range(5):
		createSym('L_arm' + str(i) + '_rigHelper', 'R_arm' + str(i) + '_rigHelper')
Example #29
0
    def createNeckCtrl(self):

        headCtrl = rigUtils.createRigControl('circle')
        headCtrl = pm.rename(headCtrl[0], 'M_head_ctrl')
        rigUtils.setControlColor(headCtrl)

        pm.move(
            headCtrl,
            (self.headRootPos[0], self.headRootPos[1], self.headRootPos[2]))
        pm.rotate(headCtrl, (0, 0, 90))
        pm.scale(headCtrl, (1.5, 1.5, 1.5))
        pm.makeIdentity(a=True, r=True, t=True, s=True)
 def randomize(self, list, transRot):
     list = pm.ls(list, fl = True)
     rt = self.randSliderT.getValue()
     rr = self.randSliderR.getValue()
     for x in list:
         if transRot == 2 or transRot == 0:
             pm.move(str(x), random.uniform(-rt*self.TXCheckBox.getValue(),rt*self.TXCheckBox.getValue()), \
             random.uniform(-rt*self.TYCheckBox.getValue(),rt*self.TYCheckBox.getValue()), \
             random.uniform(-rt*self.TZCheckBox.getValue(),rt*self.TZCheckBox.getValue()),  relative = True)
         if transRot == 2 or transRot == 1:
             pm.rotate(str(x), [random.uniform(-rr*self.RXCheckBox.getValue(),rr*self.RXCheckBox.getValue()),\
              +random.uniform(-rr*self.RYCheckBox.getValue(),rr*self.RYCheckBox.getValue()),\
               +random.uniform(-rr*self.RZCheckBox.getValue(),rr*self.RZCheckBox.getValue())], relative = True )
Example #31
0
def floorPlaneForward(card, baseJoint):
    ''' Rotates in world Y axis to point directly forward.  'Forward' is determined by the baseJoint and it's child
    '''
    rCard = getRCard(card)
    orientState = baseJoint.getOrientState()
    targetRJoint = getRJoint(orientState.joint)

    aim = pdil.dagObj.getPos(targetRJoint) - pdil.dagObj.getPos(
        getRJoint(baseJoint))
    print(baseJoint, targetRJoint)
    rotate(rCard, [0, -math.degrees(math.atan2(aim.x, aim.z)), 0],
           ws=True,
           r=True)
Example #32
0
    def buildCircleController(self):
        pm.select(cl=1)
        ctrl = pm.circle(name=self.ctrlName,
                         c=[0, 0, 0],
                         nr=self.ctrlAxis,
                         ch=0,
                         radius=self.ctrlScale)[0]
        ctrlGrp = pm.group(ctrl, n=str(self.ctrlName + '_grp'))
        pm.select(cl=1)
        pm.move(ctrlGrp, self.ctrlPos[0], self.ctrlPos[1], self.ctrlPos[2])
        pm.rotate(ctrlGrp, self.ctrlRot[0], self.ctrlRot[1], self.ctrlRot[2])

        self.ctrlGrp = ctrlGrp
Example #33
0
def cyroFinish():
    print 'Finishing cyro'

    rig_quadFinalize()

    pm.setAttr("neckFocus_CTRL.focusNeck", 0.75)

    pm.setAttr("spineUpperPivot_CTRL.translateY", -17.164)
    pm.setAttr("spineUpperPivot_CTRL.translateZ", 1.81)
    pm.setAttr("spineUpper_CTRL.stretch", 0.2)

    pm.move('tailUpperAim_LOCUp', 0, 1000, 0, r=True, os=True)
    pm.move('tailLowerAim_LOCUp', 0, 1000, 0, r=True, os=True)

    pm.move(pm.PyNode('neckTipIK_CTRL.cv[:]'), 0, 0, -5, r=True, os=True)
    pm.move(pm.PyNode('neckMidBIK_CTRL.cv[:]'), 0, -8.5, -13, r=True, os=True)
    pm.move(pm.PyNode('neckMidAIK_CTRL.cv[:]'), 0, -1, -23, r=True, os=True)

    controlSet = pm.PyNode('cyroRigPuppetControlSet')
    for s in ('l', 'r'):
        pm.setAttr("displayModulesToggleControl." + s + "_fingers", 0)
        pm.setAttr("displayModulesToggleControl." + s + "_toes", 0)

        pm.setAttr(s + "_armPV_CTRL.space", 1)
        #pm.setAttr(s+"_shoulder_CTRL.followArm", 1)

        pm.rotate(pm.PyNode(s + '_handBall_CTRL').cv,
                  0,
                  90,
                  0,
                  r=True,
                  os=True)
        pm.scale(pm.PyNode(s + '_handBall_CTRL').cv, 2, 2, 2)

        pm.parentConstraint(s + '_anklePos_JNT',
                            s + '_toeThumbModify1_GRP',
                            mo=True)

        controlSet.removeMembers([s + '_shoulder_CTRL'])

    hiDeltaMush = mm.eval('rig_returnDeformers("skin_C_body_GV", "deltaMush")')
    if len(hiDeltaMush) > 0:
        cNode = conditionNode('hiDeltaMush', 'equal', ('', 0), ('', 2),
                              ('', 1), ('', 0))
        pm.connectAttr("global_CTRL.lodDisplay", cNode + '.secondTerm')
        pm.connectAttr(cNode + '.outColorR', hiDeltaMush[0] + '.envelope')

    pm.setAttr("displayModulesToggleControl.flex", 0)
    # mid LOD
    cmds.setAttr("global_CTRL.lodDisplay", 1)
Example #34
0
 def __aimCnt(self):
     '''
     corectly aims the control according to the proper aim axis
     '''
     y = 0
     z = 0
     
     if self.aimAxis == "y":
         z = 90
     elif self.aimAxis == "z":
         y = -90
     
     for s in self.control.getShapes():
         pm.rotate(s.cv, 0, y, z, r=1) 
Example #35
0
    def _aim_ctrl(self):
        """
        Aims control based on a provided aim axis.
        """
        y = 0
        z = 0

        if self.aim_axis == "y":
            z = 90
        elif self.aim_axis == "z":
            y = -90

        for s in self.ctrl.getShapes():
            pm.rotate(s.cv, 0, y, z, r=1)
Example #36
0
 def specialfk(self):
     selectedList = pm.selected()
     print selectedList
     for current in selectedList:
         #円のカーブの作成
         crv_circle = pm.circle()
         pm.select(crv_circle)
         #オブジェクト座標形でyに90度回転
         pm.rotate([0,0,90])
         #移動、回転、スケールをフリーズする
         pm.makeIdentity(apply=True, translate=True, rotate=True, scale=True, normal=1)
         #カーブのシェイプノードのみをジョイントの子供にする
         #こうすることで、カーブをコントロールすることでジョイントもコントロールできる
         pm.parent(crv_circle[0].getShape(), current,relative=True, shape=True)
         #余分なシェイプノードを削除する
         pm.delete(crv_circle)
Example #37
0
 def addCtrl(self,num):
     ctrl = pm.circle(name = self.name + '_ik_ctrl_0' + str(num),nr=[1,0,0],radius = self.width * 1.2)[0]
     pm.delete(ctrl,ch=1)
     #ctrl.translate.lock()
     '''
     for a in ['X','Y','Z']:
         ctrl.attr('translate' + a).set( lock = True, keyable = False, channelBox = False )
     ctrl.scaleX.set( lock = True, keyable = False, channelBox = False )
     '''
     #pm.addAttr(ctrl,ln='falloff',defaultValue=0.2, minValue=0.01, maxValue=1,keyable=1)
     #pm.addAttr(ctrl,ln='position',defaultValue=0, minValue=0, maxValue=1,keyable=1)
     ctrlGrp = pm.group(ctrl,name=ctrl.name() + '_grp')
     
     pm.rotate(ctrlGrp,0,-90,0,r=1)
     
     return ctrl
Example #38
0
 def addIk(self):
     self.createJntChain()
     #create the surface that will be skinned to the joints
     self.createSrf()
     #create the follicles on the surface and also the controllers
     self.createFlcAndCtrl('u', 0)
     #get the joint position on the surface and store it as an attribute
     self.addJntPosAttr()
 
     self.jntGrp = pm.group(name=self.name+'_drv_jnt_grp')
     pm.rotate(self.jntGrp ,0,-90,0,r=1)
     pm.parent(self.jntList[0],self.jntGrp)
 
     pm.parent(self.jntGrp,self.mainGrp)
     self.addMainCtrl()
 
     pm.skinCluster( self.srf,self.jntList, tsb=1, ih=1, skinMethod = 0, maximumInfluences = 1, dropoffRate = 10.0 )        
 def addIk(self):
     self.createJntChain()
     #create the surface that will be skinned to the joints
     self.createSrf()
     self.createIkCrv()
     #create the follicles on the surface and also the controllers
     self.createFlcAndCtrl('u', 1)
     #get the joint position on the surface and store it as an attribute
     self.addJntPosAttr()
 
     self.jntGrp = pm.group(name=self.name+'_ik_jnt_grp')
     pm.rotate(self.jntGrp ,0,-90,0,r=1)
     pm.parent(self.jntList[0],self.jntGrp)
 
     pm.parent(self.jntGrp,self.mainGrp)
     self.addMainCtrl()
 
     self.skinSrf()
Example #40
0
def alignCtrlToJnt():
    selComp = pm.ls(sl = True, fl = True)
    checkSelection(selComp)
    tmpGroup = pm.group(selComp[:-1])
    pm.parent(tmpGroup, selComp[-1])
    tmpGroup.rotate.set([0, 0, 0])
    tmpGroup.translate.set([0, 0, 0])
    pm.parent(tmpGroup, world = True)
    pm.ungroup(tmpGroup)
    # Convert controls to control vertices
    selComp2 = selComp[:-1]

    for i in range(len(selComp2)):
        selComp2[i] += '.cv[*]'

    pm.select(selComp2)
    pm.rotate([0, 0, 90])
    pm.select(cl = True)
    pm.select(selComp[:])
Example #41
0
 def addCtrl(self,num):
     ctrl = pm.circle(name = self.name + '_vfk_ctrl_0' + str(num),nr=[1,0,0],radius = self.width * 1.2)[0]
     pm.delete(ctrl,ch=1)
     #ctrl.translate.lock()
     for a in ['X','Y','Z']:
         ctrl.attr('translate' + a).set( lock = True, keyable = False, channelBox = False )
     ctrl.scaleX.set( lock = True, keyable = False, channelBox = False )
     
     pm.addAttr(ctrl,ln='falloff',defaultValue=0.2, minValue=0.01, maxValue=1,keyable=1)
     pm.addAttr(ctrl,ln='position',defaultValue=0, minValue=0, maxValue=1,keyable=1)
     ctrlRev = pm.group(ctrl,name=ctrl.name() + '_rev_rot')
     ctrlGrp = pm.group(ctrlRev,name=ctrl.name() + '_grp')
     
     rotRev = pm.shadingNode('reverse',name = ctrl.name() + '_rot_rev',asUtility=1)
     ctrl.rotate >> rotRev.input
     rotRev.output >> ctrlRev.rotate
     
     pm.rotate(ctrlGrp,0,-90,0,r=1)
     
     return ctrl
Example #42
0
def create_master_controls(type = "", assetName=""):
    if not type:
        return

    global_round_square_with_arrow = "curve -d 3 -p 0 0 0.75 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.375 0 0.5 -p 0.5 0 0.5 -p 0.5 0 0.375 -p 0.5 0 -0.375 -p 0.5 0 -0.5 -p 0.375 0 -0.5 -p -0.375 0 -0.5 -p -0.5 0 -0.5 -p -0.5 0 -0.375 -p -0.5 0 0.375 -p -0.5 0 0.5 -p -0.375 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p 0 0 0.75 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17"
    local_round_square_with_arrow = "curve -d 3 -p 0 0 0.5 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.25 0 0.375 -p 0.375 0 0.375 -p 0.375 0 0.25 -p 0.375 0 -0.25 -p 0.375 0 -0.375 -p 0.25 0 -0.375 -p -0.25 0 -0.375 -p -0.375 0 -0.375 -p -0.375 0 -0.25 -p -0.375 0 0.25 -p -0.375 0 0.375 -p -0.25 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p 0 0 0.5 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17"
    root_crosshair = "curve -d 1 -p 0 0 0.325 -p -0.0634045 0 0.318755 -p -0.124372 0 0.300261 -p -0.180561 0 0.270228 -p -0.22981 0 0.22981 -p -0.270228 0 0.180561 -p -0.300261 0 0.124372 -p -0.318755 0 0.0634045 -p -0.325 0 0 -p -0.318755 0 -0.0634045 -p -0.300261 0 -0.124372 -p -0.270228 0 -0.180561 -p -0.22981 0 -0.22981 -p -0.180561 0 -0.270228 -p -0.124372 0 -0.300261 -p -0.0634045 0 -0.318755 -p 0 0 -0.325 -p 0.0634045 0 -0.318755 -p 0.124372 0 -0.300261 -p 0.180561 0 -0.270228 -p 0.22981 0 -0.22981 -p 0.270228 0 -0.180561 -p 0.300261 0 -0.124372 -p 0.318755 0 -0.0634045 -p 0.325 0 0 -p 0.318755 0 0.0634045 -p 0.300261 0 0.124372 -p 0.270228 0 0.180561 -p 0.22981 0 0.22981 -p 0.180561 0 0.270228 -p 0.124372 0 0.300261 -p 0.0634045 0 0.318755 -p 0 0 0.325 -p 0 0 -0.325 -p 0 0 -0.25 -p -0.0487726 0 -0.245197 -p -0.095671 0 -0.23097 -p -0.138893 0 -0.207868 -p -0.176777 0 -0.176777 -p -0.207868 0 -0.138893 -p -0.23097 0 -0.095671 -p -0.245197 0 -0.0487726 -p -0.25 0 0 -p -0.325 0 0 -p 0.325 0 0 -p -0.25 0 0 -p -0.245197 0 0.0487726 -p -0.23097 0 0.095671 -p -0.207868 0 0.138893 -p -0.176777 0 0.176777 -p -0.138893 0 0.207868 -p -0.095671 0 0.23097 -p -0.0487726 0 0.245197 -p 0 0 0.25 -p 0.0487726 0 0.245197 -p 0.095671 0 0.23097 -p 0.138893 0 0.207868 -p 0.176777 0 0.176777 -p 0.207868 0 0.138893 -p 0.23097 0 0.095671 -p 0.245197 0 0.0487726 -p 0.25 0 0 -p 0.245197 0 -0.0487726 -p 0.23097 0 -0.095671 -p 0.207868 0 -0.138893 -p 0.176777 0 -0.176777 -p 0.138893 0 -0.207868 -p 0.095671 0 -0.23097 -p 0.0487726 0 -0.245197 -p 0 0 -0.25 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 -k 40 -k 41 -k 42 -k 43 -k 44 -k 45 -k 46 -k 47 -k 48 -k 49 -k 50 -k 51 -k 52 -k 53 -k 54 -k 55 -k 56 -k 57 -k 58 -k 59 -k 60 -k 61 -k 62 -k 63 -k 64 -k 65 -k 66 -k 67 -k 68 -k 69"
    
    if type == "global": c = pm.mel.eval(global_round_square_with_arrow)
    if type == "local": c = pm.mel.eval(local_round_square_with_arrow)    
    if type == "root": c = pm.mel.eval(root_crosshair)
                        
    if assetName and type == 'global':
        text_curve = pm.PyNode( pm.textCurves(ch=False, font="Arial Black", text=assetName, name='text_curve')[0] )
        text_curve_length = text_curve.boundingBox()[1][0] #max X
        text_curve_height = text_curve.boundingBox()[1][1] #max Y
        
        shapes = pm.listRelatives(text_curve, ad=True, type="shape")
        
        pm.xform(text_curve, piv=[0,text_curve_height,0], ws=True)

        pm.move(text_curve, 0, -text_curve_height ,0.755)
        pm.rotate(text_curve, -90, 45,0)
        
        scales = 0.3535 / text_curve_length
        pm.scale(text_curve, scales, scales, scales)
                
        pm.makeIdentity(text_curve, apply=True, t=True, r=True, s=True)
    
        for s in shapes:
            pm.parent(s, c, s=True, r=True)

        pm.delete(text_curve)
    
    try:
        curve = pm.PyNode(c)
    except:
        pass
    
    return curve
Example #43
0
 def set_ctrl_color(self):
     """
     Sets the color of the control object.
     """
     for s in self.ctrl.getShapes():
         pm.rotate(s.cv, 0, y, z, r = 1)
         if self.ctrl_color == "yellow":
             s.overrideEnabled.set(True)
             s.overrideColor.set(17)
         elif self.ctrl_color == "blue":
             if self.side == "l":
                 s.overrideEnabled.set(True)
                 s.overrideColor.set(6)
             elif self.side == "r":
                 s.overrideEnabled.set(True)
                 s.overrideColor.set(13)
         elif self.cc_color == "red":
             if self.side == "l":
                 s.overrideEnabled.set(True)
                 s.overrideColor.set(13)
             elif self.side == "r":
                 s.overrideEnabled.set(True)
                 s.overrideColor.set(6)
Example #44
0
def add_global_text(global_control, assetName, size):
    if assetName:
        text_curve = pm.PyNode( pm.textCurves(ch=False, font="Arial Black", text=assetName, name='text_curve')[0] )
        text_curve_length = text_curve.boundingBox()[1][0] #max X
        text_curve_height = text_curve.boundingBox()[1][1] #max Y
        
        shapes = pm.listRelatives(text_curve, ad=True, type="shape")
        
        pm.xform(text_curve, piv=[0,text_curve_height,0], ws=True)

        pm.move(text_curve, 0, -text_curve_height ,0.755 * size)
        pm.rotate(text_curve, -90, 45,0)
        
        scales = 0.3535 / text_curve_length * size
        pm.scale(text_curve, scales, scales, scales)
                
        pm.makeIdentity(text_curve, apply=True, t=True, r=True, s=True)
    
        for s in shapes:
            pm.parent(s, global_control, s=True, r=True)
            s.rename('%sText'%global_control.name())                

        pm.delete(text_curve)
Example #45
0
 def make_chain(self, obj, link_length, chain_length, preserve_object=False):
     """
     Uses provided geometry to create a straight chain
     
     obj: object to be used for the chain
     linklenght: lenght of the obj
     chainlenght: number of links that are created
     """
     if preserve_object:
         obj = pm.duplicate(obj, un=True)[0]
     pm.move(obj, 0, 0, 0)
     chain = [obj]
         
     rotation_value = 0
     for i in range(1, chain_length):
         obj = pm.duplicate(chain[0])[0]
         rotation_value += 90 + random.randint(-self.variation, self.variation)
         if rotation_value >= 360:
             rotation_value -= 360
         pm.rotate(obj, [rotation_value, 0, 0])
         distance = link_length * i
         pm.move(obj, distance, 0, 0)
         chain.append(obj)
     return chain
Example #46
0
	def bdRotateCon(self,axis):
		selection = pm.ls(sl=True)
		conChild = ''
		if selection.count > 0:
			print selection[0].name()
			if 'GRP' in selection[0].name():
				pm.warning('Select the curves not the GRP')
			else:
				rotPivot = selection[0].getTranslation(space='world')
				for sel in selection:
					shapes = sel.getChildren()
					for shape in shapes:
						selCVs = shape.cv
						if axis == 'x':
							pm.rotate(selCVs,90,0,0,r=True,p=rotPivot,os=True,)
						elif axis == 'y':
							pm.rotate(selCVs,0,90,0,r=True,p=rotPivot,os=True,)	
						elif axis == 'z':
							pm.rotate(selCVs,0,0,90,r=True,p=rotPivot,os=True,)	
Example #47
0
def createIKLeg( listJnts, side ):
    
    toeBaseJnt = listJnts[-3]

    # create ik handle
    ikh = pm.ikHandle( sj=listJnts[0], ee=toeBaseJnt, sol='ikRPsolver', name=toeBaseJnt + '_' +Names.suffixes['ikhandle'] )
    ikh[0].hide()
    
    # create ik sc solvers for foot and toe
    ikhfoot = pm.ikHandle( sj=toeBaseJnt, ee=listJnts[-2], sol='ikSCsolver', name=listJnts[-2] + '_' +Names.suffixes['ikhandle'] )
    ikhfoot[0].hide()
    ikhtoe = pm.ikHandle( sj=listJnts[-2], ee=listJnts[-1], sol='ikSCsolver', name=listJnts[-1] + '_' +Names.suffixes['ikhandle'] )
    ikhtoe[0].hide()
    
    # parent ik handles to inverse foot
    inverseFoot = str(toeBaseJnt.name()) 
    inverseFoot = pm.ls( inverseFoot.replace('_'+Names.suffixes['ik'], '_inversefoot'),r=1 )[0]
    
    inverseToe = pm.ls(str(inverseFoot.name())+'1',r=1)[0]
    inverseToeEnd = pm.ls(str(inverseFoot.name()+'2'),r=1)[0]

    # create offset for toe roll
    offsetGrp = pm.group(em=1,name=str(inverseToeEnd.name()) + '_offsetGrpA')
    offsetGrpB = pm.group(em=1,name=str(inverseToeEnd.name()) + '_offsetGrpB')
    offsetGrp.setParent( inverseToe )
    offsetGrp.setTranslation([0,0,0])
    offsetGrp.setRotation([0,0,0])
    offsetGrp.setParent(w=1)
    offsetGrpB.setParent(offsetGrp)
    offsetGrpB.setTranslation([0,0,0])
    offsetGrpB.setRotation([0,0,0])
    
    
    ikh[0].setParent(inverseFoot)
    ikhfoot[0].setParent(inverseToe)
    
    ikhtoe[0].setParent(offsetGrpB)
    offsetGrp.setParent(inverseToeEnd)
    
    
    
    # create curve for ik foot
    if side == Names.prefixes['left']: ctrl = Names.controls_leftLegIK
    elif side ==Names.prefixes['right']: ctrl = Names.controls_rightLegIK
    else: raise Exception('Make sure side: %s is valid '%side)
    
    
    posjnt = pm.xform(toeBaseJnt, query = True, translation = True, ws=1)
    rotjnt = pm.xform(toeBaseJnt, query = True, ro = True, ws=1)
 
    foot_cnt = Control.create( name=ctrl, offsets=1, shape='circle_01', 
                    size=1.5, color=getSideColor(side), 
                    pos=posjnt,rot=rotjnt, parent=None, typ='body' )
    
    
    ############ fix this! need to rotate 180 to make sure that ctrl behaves properly
    if side == Names.prefixes['right']:
        pm.rotate(foot_cnt,0,0,180,os=1, r=1)
       
    ankleFloorJnt = pm.ls('%s%s' %(side,'AnkleFloor_if'),r=1  )[0]
    foot_ctrl = foot_cnt.listRelatives(ad=1)[0].getParent()
    ankleFloorJnt.setParent( foot_ctrl )
    ankleFloorJnt.hide()
    
    # add attr to foot control
    pm.addAttr(foot_ctrl, longName='heel_roll',k=True)
    pm.addAttr(foot_ctrl, longName='toe_roll',k=True)
    pm.addAttr(foot_ctrl, longName='toeEnd_roll',k=True)
    pm.addAttr(foot_ctrl, longName='toe_up_down',k=True)
    
    # connect attrs
    pm.connectAttr( foot_ctrl + '.' + 'heel_roll', ankleFloorJnt + '.' + 'rotateZ' )
    pm.connectAttr( foot_ctrl + '.' + 'toe_roll', inverseToe + '.' + 'rotateZ' )
    pm.connectAttr( foot_ctrl + '.' + 'toeEnd_roll', inverseToeEnd + '.' + 'rotateZ' )
    pm.connectAttr( foot_ctrl + '.' + 'toe_up_down', offsetGrpB + '.' + 'rotateZ' )
    
    
    
    #####################
    # create pole vector
    if side == Names.prefixes['left']: ctrl = Names.controls_leftLegIKPV
    elif side ==Names.prefixes['right']: ctrl = Names.controls_rightLegIKPV
    else: raise Exception('Make sure side: %s is valid '%side)
    
    pv_cnt = Control.create( name=ctrl, offsets=1, shape='cube', 
                    size=0.4, color=getSideColor(side), 
                    pos=None, parent=None, typ='body' )
    
    # parent constraint w/o offsets to UpLeg, Leg
    cons = pm.parentConstraint( listJnts[0], listJnts[1],listJnts[2], pv_cnt, mo=0 )
    pm.delete(cons)
    # aim contraint to leg
    cons = pm.aimConstraint( listJnts[1], pv_cnt,mo=0 )
    pm.move( pv_cnt, 10,0,0, os=1,r=1)
    pm.delete(cons)
    
    # connect pole vector
    pm.poleVectorConstraint( pv_cnt.getChildren()[0], ikh[0] )
    ####################
    
    rList = [pv_cnt, foot_cnt, ikh]
    return rList
Example #48
0
        dst.append(element)
    else:
        pm.error('ERROR')

print('src', src)
print('dst', dst)

# Make instances.
group = []
for target in dst:
    # group.append(pm.instance(src))
    clone = pm.instance(src)

    # getPosition works only with vertices
    if isinstance(target, pm.MeshVertex):
        move_to = target.getPosition(space='world')
    if isinstance(target, (pm.MeshFace, pm.MeshEdge)):
        pm.select(target, replace=True)
        faceBox = pm.polyEvaluate(boundingBoxComponent=True)
        centerX = 0.5 * (faceBox[0][0] + faceBox[0][1])
        centerY = 0.5 * (faceBox[1][0] + faceBox[1][1])
        centerZ = 0.5 * (faceBox[2][0] + faceBox[2][1])
        move_to = pm.datatypes.Point(centerX, centerY, centerZ)

    print(repr(move_to))
    pm.move(move_to.x, move_to.y, move_to.z, clone, absolute=True)

    rotate_to = pm.angleBetween(v1=(0.0, 1.0, 0.0), v2=target.getNormal(), euler=True)
    pm.rotate(clone, rotate_to)
# pm.group(group)
Example #49
0
pm.circle( n='Center_Controller',nr=(0, 1, 0), c=(0, 0, 0) , sw=360,r=1,d=3,ut=False,tol=0.01,s=24,cch=True)
pm.scale(4.0,4.0,4.0,r=True)
pm.select('Center_Controller.cv[1]','Center_Controller.cv[3]','Center_Controller.cv[5]','Center_Controller.cv[7]','Center_Controller.cv[9]','Center_Controller.cv[11]','Center_Controller.cv[13]','Center_Controller.cv[15]','Center_Controller.cv[17]','Center_Controller.cv[19]','Center_Controller.cv[21]','Center_Controller.cv[23]')
pm.scale(.3,.3,.3,pivot=(0,0,0),r=True)
pm.select('Center_Controller')
pm.scale(2.5,2.5,2.5,r=True)
pm.makeIdentity(apply=True,t=1,r=1,s=1,n=0,pn=1)

#Back Controllers Create

pm.curve(n='Bottom_Center_Controller',d=3,p=[(0, 0, 0),(0 ,0 ,-6),(0, -0.499797, -7.37584),(0,  -1.30294 ,-6.319076),(0, -0.837963 ,-5.727286 ),(0 ,-0.457527 ,-5.980911),(0 ,-0.542068 ,-6.445888 ),(0, -0.795692 ,-6.488159),(0 ,-0.880233 ,-6.319076)],k=[0,0,0,1,2,3,4,5,6,6,6])
pm.scale(1, 1, 1.235647,r=True)

pm.group('Bottom_Center_Controller','Bottom_Center_Controller',n='Bottom_Center_Ctrl_Grp',r=True)
pm.select('Bottom_Center_Controller.cv[0:8]')
pm.rotate(0,-90,0,r=True)
pm.rotate(0,0,-90,r=True)

# Creating Back Controller and Mid Controller

#Creating Center Controller link 

#Creating Bottom Center Back Controllers
pm.parentConstraint('Lumbar_Jnt','Bottom_Center_Ctrl_Grp',mo=False,w=1)
pm.select('Bottom_Center_Controller')
Bottom_Center_Ctrl_Pos = pm.xform('Lumbar_Jnt',query=True,ws=True,matrix=True)
pm.xform('Bottom_Center_Controller',ws=True,m=Bottom_Center_Ctrl_Pos)
Bottom_Center_Pivot_Pos = pm.xform('Lumbar_Jnt',query=True,ws=True,matrix=True)
pm.xform('Bottom_Center_Ctrl_Grp_parentConstraint1.scalePivot', 'Bottom_Center_Ctrl_Grp_parentConstraint1.rotatePivot',ws=True,m=Bottom_Center_Pivot_Pos)
pm.delete('Bottom_Center_Ctrl_Grp_parentConstraint1')
Example #50
0
	def draw_axiom(self,axiom,ang,dist):
		stack = []

		zdegr = 0
		ydegr = 0
		xdegr = 0
		width = 0.5
		dist = 0
		world = False
		previous = None
		pdist = 0 #previous distance

		first_itr = True

		for c in axiom:
			
			command = c[0]
			argument = c[1]

			# draw flower
			if command is 'L':
				if argument is 'def':
					argument = self.dist
				current = self.make_flower(self.flower_index)
				self.flower_index += 1
				if previous is not None:
					current.setMatrix(previous.getMatrix(worldSpace=True))
					pm.parent(current,previous)
				pm.scale(15,15,15)
				if xdegr != 0 or zdegr != 0 or ydegr != 0:
					# print(pdist)
					current.translateY.set(pdist)
					# pm.move(0,pdist,0,current,os=True)
					# pm.rotate(current,xdegr,ydegr,zdegr,os=True,relative=True)
					print(width)
					# pm.move(0,width,0,current,os=True,relative=True)
				else:
					pm.move(0,dist+argument/2,0,current,os=True,relative=True)

				zdegr = 0
				ydegr = 0
				xdegr = 0
				dist = 0
				world = False
				previous = current

			if command is 'F':
				print ("{} {} {} {}".format("F command triggered", world, xdegr+ydegr+zdegr,width))
				if argument is 'def':
					argument = self.dist

				if command is 'F':
					current = self.make_branch(argument,width)[0]
				elif command is 'L': 
					current = self.make_flower(self.flower_index)
					# pm.scale(3,3,3)
					self.flower_index += 1
				
				if previous is not None:
					current.setMatrix(previous.getMatrix(worldSpace=True))
					pm.parent(current,previous)
				if command is 'L':
					pm.scale(8,8,8)

				
				#apply rotates and transforms				
				if xdegr != 0 or zdegr != 0 or self.ternaryflag:
					pm.move(0,pdist,0,current,os=True)
					# print(tn.process(current))
					
					if previous is not None and command is 'F' and self.ternaryflag:
						tn.apply_tropism(current,self.e,self.tropism)

					pm.rotate(current,xdegr,ydegr,zdegr,os=True,relative=True)
					if command is 'F':
						pm.move(0,dist+argument/2,0,current,os=True,relative=True)
					if command is 'L':
						pm.move(0,width,0,current,os=True,relative=True)

				else:
					if command is 'F':
						pm.move(0,pdist+dist+argument/2,0,current,os=True,relative=True)
					if command is 'L':
						pm.move(0,dist+argument/2,0,current,os=True,relative=True)

				zdegr = 0
				ydegr = 0
				xdegr = 0
				dist = 0
				world = False
				
				if command is 'F':
					pdist = argument/2

				# print(xdegr)
				previous = current

			elif command is 'f':
				if argument is 'def':
					dist = 5
				else:
					dist = argument

			elif command is '-':
				if argument is 'def':
					argument = ang
				zdegr += -argument
				print ("{} {}".format("- command triggered", zdegr))

			elif command is '+':
				if argument is 'def':
					argument = ang
				zdegr += argument
				print ("{} {}".format("+ command triggered", zdegr))

			elif command is '&':
				if argument is 'def':
					argument = ang
				print("& command triggered")
				xdegr += -argument
				print ("{} {}".format("+ command triggered", xdegr))

			elif command is '^':
				if argument is 'def':
					argument = ang
				xdegr += argument

			elif command == "\\":
				print("\\ command triggered")
				ydegr += -argument

			elif command is '/':
				if argument is 'def':
					argument = ang
				ydegr += argument

			elif command is '[':
				print("[ triggered")
				stack.append([previous,xdegr,ydegr,zdegr,width,dist,world])
				# print(stack)

			elif command is ']':
				print("] triggered")
				# print(stack)
				prev_state = stack.pop()
				previous = prev_state[0]
				xdegr = prev_state[1]
				ydegr = prev_state[2]
				zdegr = prev_state[3]
				width = prev_state[4]
				dist = prev_state[5]
				world = prev_state[6]
				# print(stack)

			#decrement width
			elif command is '!':
				print("! triggered")
				if argument is 'def':
					width*=0.9
				else:
					width = argument

			#rotate Y and until Z-axis is horizontal (WIP)
			elif command is '$':
				pass
Example #51
0
def sCameraCubeCam(p = [0,0,0], r = [0,0,0], fov=90, name="camera"):
    name = getUniqueName(name)
    target = py.camera(n=str(name), horizontalFieldOfView=fov)
    py.move(p[0],p[1],p[2])
    py.rotate(r[0],r[1],r[2])
    return target
Example #52
0
def repeat_over_sphere( width, radius, rand_rot_min_max=[0,5], rotate_axis=[1, 1, 1] ):
	'''
	Args:
		width (float): width of panels
		radius (float): radius of disco ball
		rand_rot_min_max (list of float): min/max rotation random of list of size 2
	Returns: (None)
	Usage:
		repeat_over_sphere( .13, 1, rand_rot_min_max=[-2,2], rotate_axis=[1,1,.2] )
	'''	
	namer = lib_env.AssetNameFormatter()
	
	master = pm.polyPlane(w=width, h=width, sx=1, sy=1)[0]
	master.translate.set(0,0,radius)
	master.rotateX.set(90)
	
	main_grp = pm.group(n=namer.get(name='disco_ball', type='group'), em=True)
	#Initial column creation
	rotation_angle, num_copies = lib_math.get_repetitions_around_circle( width, radius )
	rotate_rand = rotation_angle/2
	#create seed rows
	rows, row_grps, panels = [], [], []
	for r in range(0, int( math.ceil(num_copies/2.0) )):
		mirror_alpha = chr( r+97 ).upper()
		name = 'mirror_row%02d_%02d'%( r, 0 )
		
		grp = pm.group( n=namer.get(name=name+'Offset', type='group'), em=True )
		dup = pm.duplicate( master, n=namer.get(name=name, type='mesh'), rr=True )[0]
		
		dup.setParent(grp)
		pm.rotate( grp, [(-1*rotation_angle*r)-90, 0, 0], r=True)
		panels.append( dup )
		rows.append( grp )
	
	for mirror_index, mirror in enumerate(rows):
		row_grp = pm.group(n=namer.get( name='mirror_row%02dOffset'%( mirror_index ), type='group'), em=True)
		mirror.setParent( row_grp )
		
		height = mirror.getBoundingBoxMax(space='world')[1]
		if height<0:
			height = mirror.getBoundingBoxMin(space='world')[1]
		cross_section_r = lib_math.get_sphere_cross_section_radius( radius, height )
		rotation_angle, num_copies = lib_math.get_repetitions_around_circle( width, cross_section_r )
		
		for i in range(1, num_copies):
			dup = pm.duplicate(mirror, n=namer.get( name='mirror_row%02d_%02dOffset'%( mirror_index, i ), type='group' ), rr=True)[0]
			dup.getChildren(type='transform')[0].rename( namer.get( name='mirror_row%02d_%02d'%( mirror_index, i ), type='mesh' ) )
			dup.setParent( row_grp )
			dup.rotatePivot.set( 0,0,0 )
			dup.scalePivot.set( 0,0,0 )
			pm.rotate( dup, [0, rotation_angle*i, 0], r=True )
			panels.append( dup.getChildren(type='transform')[0] )
		row_grp.setParent( main_grp )
		row_grps.append( row_grp )
	rot = rotate_rand
	#now rotate all the rows randomly to appear shifted
	for row_grp in row_grps:	
		row_grp.rotateY.set( rot )
		rot += rotate_rand*2
	#randomly rotate panels
	min, max = rand_rot_min_max
	if not min==max:
		for panel in panels:
			rand_rot = [(random.randrange(min, max)) * rotate_axis[0] + panel.rotate.get()[0],
						(random.randrange(min, max)) * rotate_axis[1] + panel.rotate.get()[1],
						(random.randrange(min, max)) * rotate_axis[2] + panel.rotate.get()[2]]
			panel.rotate.set( rand_rot )
	#cleanup
	pm.delete( master )
Example #53
0
 def zeroTransforms(self, obj):
     pc.rotate(obj, a=True, xyz=0)
     pc.move(obj, a=True, xyz=0)
Example #54
0
	def spine_pack ( self
						, size=5.0
						, limbName='spine'
						, mode='biped'
						, numOfJnts=4 
						, mainCtrl=None
						, midCtrl=False
						, ss=True
						, stretchSwitch=True
						, volume=True
						, numOfFKctrl=None
						, numOfSpans=3 
						, *args ):
		
		try:# if in UI mode, get number of joints from UI
			size = pm.floatSliderGrp( self.spineSizeF, q=True, value=True)
			limbName = pm.textField( self.limbNameTF, q=True, text=True)
			selectedMode = pm.radioCollection( self.characterModeRC, q=True, select=True)
			mode = pm.radioButton( selectedMode, q=True, label=True ).lower()
			numOfJnts = pm.intSliderGrp( self.numOfJntsIS, q=True, value=True)
			numOfFKctrl = pm.intSliderGrp( self.numOfFKctrlIS, q=True, value=True )
			ss = pm.checkBox( self.ssCB, q=True, value=True )	
			volume = pm.checkBox( self.volumeCB, q=True, value=True )
			stretchSwitch = pm.checkBox( self.stretchSwitchCB, q=True, value=True )
			midCtrl = pm.checkBox( self.midCtrlCB, q=True, value=True )			
		except:
			pass	
		
		# create spine curve and it's joints 	
		crv = pm.duplicate( self.tmpCrv, name=('%s_crv'%limbName) )[0]
		crv.getShape().template.set(False)
		pm.rebuildCurve( crv, ch=False, s=numOfSpans )
		jnts = (JntOnCrv( numOfJnts=numOfJnts, crv=crv )).newJnts

		Renamer( objs=jnts , name="%s_###_jnt"%limbName )


		# orient spine joints 
		pm.joint( jnts[0],  e=True, oj='xzy', secondaryAxisOrient='xup', ch=True, zso=True )



		# create joints which will drive the spine curve
		if not midCtrl: # create base and end control joints
			controlJnts = (JntOnCrv( crv=crv , numOfJnts=2 )).newJnts
			startJnt  = pm.rename(controlJnts[0],'hip_ctrl' )
			endJnt    = pm.rename(controlJnts[1],'torso_ctrl' )
			pm.parent(  endJnt , world=True )

		else: # create base, end and middle control joint
			controlJnts = (JntOnCrv( crv=crv , numOfJnts=3 )).newJnts
			startJnt  = pm.rename(controlJnts[0],'hip_ctrl' )
			midJnt    = pm.rename(controlJnts[1],'mid_ctrl' )
			endJnt    = pm.rename(controlJnts[2],'torso_ctrl' )
			pm.parent( midJnt, endJnt , world=True )


		# orient control joints
		for jnt in controlJnts:
			if mode=='biped':
				jnt.jointOrient.set(90,0,90)
			elif mode=='quadruped':
				jnt.jointOrient.set(180,-90,0)	

		# remove init joints and curve
		pm.delete( self.tmpCrv, self.spine_initJnts )

		
		# create body control
		body_ctrl = (pm.curve ( d = 1 , p = [ (0, -size*.3 ,  size*.3)
											, (0, -size*.3 , -size*.3)
											, (0,  size*.3 , -size*.3)
											, (0,  size*.3 ,  size*.3)
											, (0, -size*.3 ,  size*.3) ]
							, k = [ 0 , 1 , 2 , 3 , 4 ] 
							, name = 'body_ctrl'
							) )
		body_ctrl.getShape().overrideEnabled.set(True)	
		body_ctrl.getShape().overrideColor.set(17)	
		pm.xform( body_ctrl, ws=True, t=pm.xform(startJnt, q=True, ws=True, t=True) )
		pm.xform( body_ctrl, ws=True, ro=pm.xform(startJnt, q=True, ws=True, ro=True) )
			

		# create IK controls 
		JntToCrv( jnts=controlJnts, shape='circle', size=size*0.25 )
		for jnt in controlJnts:
			jnt.overrideEnabled.set(True)
			jnt.overrideColor.set(17)	

		IKzeroGrps = ZeroGrp( objs=controlJnts )

		# create FK controls 
		if numOfFKctrl :
			fkCtrls = [] 		
			for i in range(numOfFKctrl):
				fkCtrls.append( (pm.circle( c=(0,0,0), nr=(1,0,0), r=size*0.25, name = "%s_FK_%s)ctrl"%(limbName,i) ) )[0]  )
				fkCtrls[i].getShape().overrideEnabled.set(True)	
				fkCtrls[i].getShape().overrideColor.set(18)	
				pm.xform( fkCtrls[i], ws=True, t=pm.xform(startJnt, q=True, ws=True, t=True) )
				moveAmount = size*0.07+(size/float(numOfFKctrl)*i)
				if mode=='biped':
					pm.move( fkCtrls[i], (0,moveAmount,0), r=True )
					pm.rotate( fkCtrls[i], (90,0,90)  , r=True )
				elif mode=='quadruped':
					pm.move( fkCtrls[i], (0,0,moveAmount), r=True )
					pm.rotate( fkCtrls[i], (180,-90,0), r=True )			

			pm.parent ( IKzeroGrps[0][-1] , fkCtrls[-1] )

			for i in range(numOfFKctrl-1):
				fkCtrls[i+1].setParent( fkCtrls[i] )

			fkCtrlsZeroGrps = ZeroGrp( objs=fkCtrls[0] )


		# keep mid control between first and last joints
		if midCtrl:
			startNull= pm.group(em=True,name='%s_start_null'%limbName)
			endNull= pm.group(em=True,name='%s_end_null'%limbName)
			startNull.setParent( startJnt )
			endNull.setParent( endJnt )
			pm.xform( startNull, t=(size*.3,0,0), ro=(0,0,0), os=True )
			pm.xform( endNull, t=(-size*.3,0,0), ro=(0,0,0), os=True )
			pm.pointConstraint( startNull, endNull, IKzeroGrps[0][1] )
			midOriNull= pm.group(em=True,name='%s_midOrient_null'%limbName)
			pm.pointConstraint( startJnt, midOriNull )
			pm.aimConstraint( endJnt, midOriNull, aimVector=(1,0,0), worldUpType="none")
			midOriNull.rotate >> IKzeroGrps[0][1].rotate		


		# parent FK, IK and mid cotrol to body
		if midCtrl and numOfFKctrl:
			pm.parent( fkCtrlsZeroGrps[0], midOriNull, IKzeroGrps[0][:-1], body_ctrl )
		elif numOfFKctrl:
			pm.parent( fkCtrlsZeroGrps[0], IKzeroGrps[0][:-1], body_ctrl )

		elif midCtrl:
			pm.parent( midOriNull, IKzeroGrps[0], body_ctrl )
		else:
			pm.parent( IKzeroGrps[0], body_ctrl )

		bodyCtrlZeroGrp = ZeroGrp( objs=body_ctrl )


		# lock and hide extra attributes
		if numOfFKctrl:
			for i in range(numOfFKctrl):
				LockHideAttr(objs=fkCtrls[i],attr='t')
				LockHideAttr(objs=fkCtrls[i],attr='s')
				LockHideAttr(objs=fkCtrls[i],attr='v')


		# create ik spline handle
		ikhStuff = pm.ikHandle ( solver = "ikSplineSolver" , startJoint = jnts[0]  , endEffector = jnts[-1] , curve=crv, freezeJoints=True, simplifyCurve = True, numSpans=numOfSpans  )  #, createCurve = False, rootOnCurve = True 

		if midCtrl:
			skinClust = pm.skinCluster( ikhStuff[2], startJnt , midJnt , endJnt)
		else:
			skinClust = pm.skinCluster( ikhStuff[2], startJnt ,  endJnt)

		
		# set skin weights for ik spline curve
		if midCtrl and numOfSpans==3:
			pm.skinPercent( skinClust , crv.cv[1], transformValue=[(startJnt, 0.8),(midJnt, 0.2)] )
			pm.skinPercent( skinClust , crv.cv[3], transformValue=[(midJnt, 0.8),(endJnt, 0.2)] )


		# rename IK stuff
		pm.rename (ikhStuff[0], "%s_ikh"%limbName )
		pm.rename (ikhStuff[1], "%s_eff"%limbName )
		ikCrv = pm.rename (ikhStuff[2], "%s_crv"%limbName )


		# outliner cleaup and hide extra objects
		pm.group( ikhStuff[::2],jnts[0], name='%s_skinJnts_grp'%limbName )
		pm.setAttr ( ikhStuff[2] + ".inheritsTransform" , 0 )
		LockHideAttr( objs=ikhStuff[::2],attr='vv')


		# stretchable back if ss in ON
		if ss :
			MakeSplineStretchy( ikCrv=crv, volume=True, stretchSwitch=True, thicknessPlace="mid" )
		pm.select (clear=True)
		
		# clean memory
		del ( self.spine_initJnts )
		del ( self.tmpCrv )
 def populate( self , obj = [] ):
     
     customRange = len(obj)
     self.obj = obj
     
     pm.select( '%sFollicle*' % self.geo )
     pm.select( '%sFollicleShape*' % self.geo , d=1 )
     self.folls = pm.ls( selection = True)
     
     self.window()
     
     # finding the name of the hair system to name the group() that all the duplicated objects will be parented to
     pm.select('%sFollicle*' % self.geo)
     pm.select('%sFollicleShape*' % self.geo, d = 1 )
     folls = pm.ls( selection = True )
     myHair = folls[0].getParent()
     system = myHair.split( 'F' )
     mySystem = system[0]
     
     # the group() for the duplicated geo
     self.geoPad = pm.group(name = '%s_geo' % mySystem, em= True)
     # creating a pop up window to show the progress
     print self.obj , customRange
     
     
     
     for foll in self.folls:
         # picking a random number between 0 and 4
         # this number will be plugged into a list[rand] to pick a random object
         self.rand = random.randrange(int(customRange))
         
         # this section will randomize the transformations
         sx = random.uniform( xScaleFieldMin.getValue() , xScaleFieldMax.getValue() )
         sy = random.uniform( yScaleFieldMin.getValue() , yScaleFieldMax.getValue() )
         sz = random.uniform( zScaleFieldMin.getValue() , zScaleFieldMax.getValue() )
         
         tx = random.uniform( xTranslateFieldMin.getValue() , xTranslateFieldMax.getValue() )
         ty = random.uniform( yTranslateFieldMin.getValue() , yTranslateFieldMax.getValue() )
         tz = random.uniform( zTranslateFieldMin.getValue() , zTranslateFieldMax.getValue() )
         
         rx = random.uniform( xRotateFieldMin.getValue() , xRotateFieldMax.getValue() )
         ry = random.uniform( yRotateFieldMin.getValue() , yRotateFieldMax.getValue() )
         rz = random.uniform( zRotateFieldMin.getValue() , zRotateFieldMax.getValue() )
         
         #print self.bar
         
         # duplicating the object
         newobj = pm.duplicate( self.obj[ self.rand ] , rr = True )
         point = pm.pointConstraint( foll , newobj )
         pm.delete( point )
         pm.makeIdentity( newobj , apply = True , t = 1 , r = 1 , s = 1 , n = 0 )
         # apllying the random Transforms
         pm.scale( newobj , [ sx , sy , sz ]  )
         pm.move( newobj , [ tx , ty , tz ]  )
         pm.rotate( newobj , [ rx , ry , rz ] )
         # parentConstraint() to the follicle
         print rx, ry, rz, tx, tz, ty, sx, sy, sz
         pm.parentConstraint( foll , newobj, mo = True )
         # parenting the objects to the group
         pm.parent(newobj , self.geoPad)
         
         self.edit()
     
     self.delete()
Example #56
0
    def createSymmetricShapeFromPoints(points, knots = None, degree = 1, count = 2, axis = None, **kwargs):
        """
        Creates a radially symmetric shape from a list of points.

        :param list points: list of tuple of float
        :param list knots: list of int
        :param uint degree:
        :param uint count: int between 2 & 360
        :param pm.dt.Vector axis:

        :returns: :py:class:`pm.nt.Transform`
        """

        curveArgs = {}

        curveArgs['point']  = points
        curveArgs['degree'] = degree

        if knots:
            curveArgs['knot'] = knots

        count = max(2, min(360, count))

        if axis:
            for index in range(len(axis)):
                axis[index] = 0 if axis[index] == 0 else 1
        else:
            axis = pm.dt.Vector(0, 1, 0)

        rotation = 360 / count

        constructionCurves = [pm.modeling.curve(**curveArgs)]

        for index in range(1, count):

            constructionCurves.append(pm.duplicate(constructionCurves[0], returnRootsOnly = True))
            pm.rotate(
                constructionCurves[index],
                (
                    axis.x * rotation * index,
                    axis.y * rotation * index,
                    axis.z * rotation * index
                ),
                relative = True
            )

        finalCurve = pm.modeling.attachCurve(
            constructionCurves,
            constructionHistory = False,
            replaceOriginal = False,
            keepMultipleKnots = False
        )[0]

        if 'radius' in kwargs:

            finalCurve.setScale((kwargs['radius'], kwargs['radius'], kwargs['radius']))
            pm.makeIdentity(finalCurve, apply = True)

        pm.delete(constructionCurves)

        return finalCurve