Exemple #1
0
 def classyCube(cls, **kwargs):
     """Doc..."""
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name='classyCube', height=height)
     cmds.move(x, 20, 0, res[0])
     return res
Exemple #2
0
    def _create(self, shapeData):
        point = None
        count = 0
        while True:
            count += 1
            if count > 10000:
                return False

            point = shapeData['box'].getRandomPointInside(padding=self._padding)

            if not cmds.elixirGeneral_PointInsideMesh(mesh=shapeData['name'], point=point):
                continue

            if self._padding > 0:
                cmds.setAttr(self._meshPointNode + '.inPosition', *point, type='double3')
                closestPoint = cmds.getAttr(self._meshPointNode + '.result.position')[0]

                dx = (closestPoint[0] - point[0])
                dy = (closestPoint[1] - point[1])
                dz = (closestPoint[2] - point[2])
                dist = math.sqrt(dx*dx + dy*dy + dz*dz)

                if dist < self._padding:
                    continue
            break

        cube = cmds.polyCube(width=self._size, height=self._size, depth=self._size)
        cmds.move(point[0], point[1], point[2], cube[0], absolute=True)
        return True
Exemple #3
0
    def run(self):
        """ This method is where your nimble script should be implemented. Prior to Nimble calling
            this method the class receives the arguments passed through Nimble needed by the
            your method implementation. """

        # Retrieve the arguments passed by Nimble using the fetch method, which includes a default
        # value to assign if the argument was not specified in the Nimble call
        sphereCount = self.fetch('count', 6)
        ringRadius  = self.fetch('radius', 10)
        yOffset     = self.fetch('y', 0)

        # Create the spheres using Maya commands imported through Nimble, which allows this script
        # to be run flexibly both inside and outside of Maya
        sphereNames = []
        for i in range(sphereCount):
            result = cmds.sphere()
            sphereNames.append(result[0])

            # Position the sphere in the ring
            cmds.move(
                ringRadius*math.cos(2.0*math.pi*i/sphereCount),
                0,
                ringRadius*math.sin(2.0*math.pi*i/sphereCount),
                result[0])

        # Place the spheres within a group node to represent the ring and move the group up the
        # y-axis by the value specified by the script arguments
        ringGroupNode = cmds.group(*sphereNames, name='sphereRing1')
        cmds.move(0, yOffset, 0, ringGroupNode)

        # Set the results of the script with the put command for returning to the Nimble calling
        # environment
        self.put('ringName', ringGroupNode)
        self.put('sphereNames', sphereNames)
    def _handlePerturb(self):
        """
        This perturbs the selected object.

        """

        selectedObjects = cmds.ls(selection=True, long=True)

        vertsList = []
        for object in selectedObjects:
            totalVerts = cmds.polyEvaluate(object, vertex=True)

            for number in range(totalVerts):
                vertsList.append(object +
                                 '.vtx[{number}]'.format(number=number))

        for vert in vertsList:
            min = float(self.minInput.displayText())
            max = float(self.maxInput.displayText())
            randNumX = random.uniform(min, max)
            randNumY = random.uniform(min, max)
            randNumZ = random.uniform(min, max)
            cmds.select(vert, replace=True)
            cmds.move(randNumX, randNumY, randNumZ, relative=True)
            cmds.select(selectedObjects, replace=True)
Exemple #5
0
 def staticCube(**kwargs):
     """Doc..."""
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name='staticCube', height=height)
     cmds.move(x, 30, 0, res[0])
     return res
Exemple #6
0
    def _makeMolecule(self):
        #H2O
        O = cmds.polySphere(r=1, n='O', ax = [0,0,0]);
        H1 = cmds.polySphere(r=0.8, n='H1', ax=[0,0,0]);
        H2 = cmds.polySphere(r=0.8, n='H2', ax=[0,0,0]);
        cmds.move(0.0,0.0,1,H1, r=True)
        cmds.move(0.0,0.0,-1,H2, r=True)
        cmds.xform(H1, piv=[0,0,0], ws=True)
        cmds.xform(H2, piv=[0,0,0], ws=True)
        cmds.rotate(0,'60',0, H1);

        #group O, H1, H2 as a water molecule
        H2O = cmds.group( empty=True, name='H2O' )
        cmds.parent(H1,H2,O,H2O)

        #paint on colors for the water molecule
        #create red lambert
        cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name='O_WhiteSG' )
        cmds.shadingNode( 'lambert', asShader=True, name='O_White' )
        cmds.setAttr( 'O_White.color', 1, 1, 1, type='double3')
        cmds.connectAttr('O_White.outColor', 'O_WhiteSG.surfaceShader')
        #create red lambert
        cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name='H_RedSG' )
        cmds.shadingNode( 'lambert', asShader=True, name='H_Red' )
        cmds.setAttr( 'H_Red.color', 1, 0, 0, type='double3')
        cmds.connectAttr('H_Red.outColor', 'H_RedSG.surfaceShader')

        #assign the material
        cmds.sets('H1', edit=True, forceElement='H_RedSG')
        cmds.sets('H2', edit=True, forceElement='H_RedSG')
        cmds.sets('O', edit=True, forceElement='O_WhiteSG')
        return H2O
Exemple #7
0
 def __call__(self, **kwargs):
     name   = self._name if self._name else 'calledCube'
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name=name, height=height, width=self._width)
     cmds.move(x, 40, 0, res[0])
     return res
Exemple #8
0
 def __call__(self, **kwargs):
     name   = self._name if self._name else 'calledCube'
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name=name, height=height, width=self._width)
     cmds.move(x, 40, 0, res[0])
     return res
Exemple #9
0
def doSingle():

    #keyframes a bubble, does NOT use slider
    r = .1
    c = cmds.polySphere(r=r)
    cmds.setAttr(c[0] + ".visibility", 0)
    cmds.setKeyframe(time=60)
    cmds.scale(11, 10, 11)
    cmds.move(0, 20, 0)
    cmds.setKeyframe(time=50)
    cmds.setAttr(c[0] + ".visibility", 1)
    cmds.rotate(100, 0, 0)
    cmds.scale(10, 9, 9.5)
    cmds.setKeyframe(time=40)
    cmds.move(4, 10, 0)
    cmds.rotate(60, 0, 0)
    cmds.setKeyframe(time=30)
    cmds.move(0, 6, 0)
    cmds.rotate(0, 0, 0)
    cmds.setKeyframe(time=20)
    cmds.move(0, 3, 0)
    cmds.scale(3, 3, 3)
    cmds.setKeyframe(time=10)
    cmds.move(0, 0, 0)
    cmds.scale(1, .8, 1)
    cmds.setKeyframe(time=1)
Exemple #10
0
    def _handleBubbleButton(self):
        """
        This callback creates a polygonal sphere in the Maya scene.
        it then translates it.
        """
        decRange = np.arange(-1,1,.1)
        decRange2 = np.arange(0,1,.1)
        r = 2
        a = 2.0*r
        y = (0, 1, 0) # y up
        c = cmds.polySphere(
            r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
        cmds.select(c)
        cmd.setKeyframe()

        cmd.setKeyframe()
        for i in range(1,300,5):
            x = rand.choice(decRange)
            y = 5*rand.choice(decRange2)
            z = rand.choice(decRange)
            cmd.currentTime(i)
            cmd.move(x,y,z,r=True)
            cmd.setKeyframe()
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemple #11
0
    def _create(self, shapeData):
        point = None
        count = 0
        while True:
            count += 1
            if count > 10000:
                return False

            point = shapeData['box'].getRandomPointInside(padding=self._padding)

            if not cmds.elixirGeneral_PointInsideMesh(mesh=shapeData['name'], point=point):
                continue

            if self._padding > 0:
                cmds.setAttr(self._meshPointNode + '.inPosition', *point, type='double3')
                closestPoint = cmds.getAttr(self._meshPointNode + '.result.position')[0]

                dx = (closestPoint[0] - point[0])
                dy = (closestPoint[1] - point[1])
                dz = (closestPoint[2] - point[2])
                dist = math.sqrt(dx*dx + dy*dy + dz*dz)

                if dist < self._padding:
                    continue
            break

        cube = cmds.polyCube(width=self._size, height=self._size, depth=self._size)
        cmds.move(point[0], point[1], point[2], cube[0], absolute=True)
        return True
Exemple #12
0
    def _createGeometry(self, name):
        '''
        #create tibia
        self.tibia = mc.polyCube(sx=1, sy=1, sz=1, w=2,h=50, d=2, n=name+'_tibia')[0]
        mc.move(0,28,-12)

        self.knee = mc.polyCylinder(h=5,r=2,n=name+'_knee')[0]
        mc.move(0,54,-12,r=True)
        mc.rotate(0,0,'90deg')
        self.tibia = mc.polyUnite(self.tibia,self.knee, n=name+'_tibia')[0]
        mc.move(0,54,-12, self.tibia+".scalePivot", self.tibia+".rotatePivot")

        #create feamer
        self.femur = mc.polyCube(sx=1, sy=1, sz=1, w=3,h=50, d=3, n=name+'_feamer')[0]
        mc.move(0,80,-12)
        self.hip = mc.polySphere(r=5,n=name+'_hip')
        mc.move(0,107,-12)
        self.femur = mc.polyUnite(self.femur,self.hip, n=name+'_femur')[0]
        mc.move(0,107,-12, self.femur+".scalePivot", self.femur+".rotatePivot")
        pass
        '''

        self.spine = mc.polyCylinder(h=75, r=2, n=name + '_spine')[0]
        mc.move(0, 30, 0)
        self.pelvic = mc.polyCylinder(h=40, r=2, n=name + '_pelvic')[0]
        mc.rotate(0, 0, '90deg')
        self.clavical = mc.polyCylinder(h=56, r=2, n=name + '_clavical')[0]
        mc.rotate(0, 0, '90deg')
        mc.move(0, 67, 0)

        #self.hip = mc.polySphere(r=5,n=name+'_hip')

        self.torso = mc.polyUnite(self.spine, self.pelvic, n=name)[0]
Exemple #13
0
    def run(self):
        """ This method is where your nimble script should be implemented. Prior to Nimble calling
            this method the class receives the arguments passed through Nimble needed by the
            your method implementation. """

        # Retrieve the arguments passed by Nimble using the fetch method, which includes a default
        # value to assign if the argument was not specified in the Nimble call
        sphereCount = self.fetch('count', 6)
        ringRadius  = self.fetch('radius', 10)
        yOffset     = self.fetch('y', 0)

        # Create the spheres using Maya commands imported through Nimble, which allows this script
        # to be run flexibly both inside and outside of Maya
        sphereNames = []
        for i in range(sphereCount):
            result = cmds.sphere()
            sphereNames.append(result[0])

            # Position the sphere in the ring
            cmds.move(
                ringRadius*math.cos(2.0*math.pi*i/sphereCount),
                0,
                ringRadius*math.sin(2.0*math.pi*i/sphereCount),
                result[0])

        # Place the spheres within a group node to represent the ring and move the group up the
        # y-axis by the value specified by the script arguments
        ringGroupNode = cmds.group(*sphereNames, name='sphereRing1')
        cmds.move(0, yOffset, 0, ringGroupNode)

        # Set the results of the script with the put command for returning to the Nimble calling
        # environment
        self.put('ringName', ringGroupNode)
        self.put('sphereNames', sphereNames)
Exemple #14
0
 def staticCube(**kwargs):
     """Doc..."""
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name='staticCube', height=height)
     cmds.move(x, 30, 0, res[0])
     return res
Exemple #15
0
    def plieHalf(self, start, end):
        if (self.gundamIns.currentFeet != "first"):
            moveFeetFirst(self.gundamIns)
            self.gundamIns.currentFeet = "first"

        mc.setKeyframe(self.gundamIns.torso.h_hips,
                       self.gundamIns.leftLeg.h_foot,
                       self.gundamIns.rightLeg.h_foot,
                       self.gundamIns.torso.h_shoulders,
                       self.gundamIns.rightArm.h_hand,
                       self.gundamIns.leftArm.h_hand,
                       t=self.start)
        mc.select(self.gundamIns.torso.h_hips,
                  self.gundamIns.torso.h_shoulders,
                  self.gundamIns.rightArm.h_hand,
                  self.gundamIns.leftArm.h_hand)
        currentY = mc.getAttr(".translateY")
        print((self.start))
        mc.move(0, -31, 0, r=True)
        mc.select(cl=True)
        #mc.currentTime((end-start)*2/2)
        mc.setKeyframe(self.gundamIns.torso.h_hips,
                       self.gundamIns.leftLeg.h_foot,
                       self.gundamIns.rightLeg.h_foot,
                       self.gundamIns.torso.h_shoulders,
                       self.gundamIns.rightArm.h_hand,
                       self.gundamIns.leftArm.h_hand,
                       t=self.end)
        mc.select(self.gundamIns.torso.h_hips,
                  self.gundamIns.torso.h_shoulders,
                  self.gundamIns.rightArm.h_hand,
                  self.gundamIns.leftArm.h_hand)
        mc.select(cl=True)
        print(self.end)
Exemple #16
0
 def classyCube(cls, **kwargs):
     """Doc..."""
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name='classyCube', height=height)
     cmds.move(x, 20, 0, res[0])
     return res
def doMulti(time):

    for i in range(0, time / 2):
        #makes time/2 bubbles and sets up a bunch of random stats for them
        initTime = randint(0, time - 30)
        initX = randint(-10, 10)
        initZ = randint(-10, 10)
        xRand = randint(-5, 5)
        zRand = randint(-5, 5)

        #keyframes all the bubbles based on time that user sets in Qt slider
        r = .1
        c = cmds.polySphere(r=r)
        cmds.setAttr(c[0] + ".visibility", 0)
        cmds.setKeyframe(time=initTime + 60)
        cmds.scale(11, 10, 11)
        cmds.move(initX, 20, initZ)
        cmds.setKeyframe(time=initTime + 50)
        cmds.setAttr(c[0] + ".visibility", 1)
        cmds.rotate(100, 0, 0)
        cmds.scale(10, 9, 9.5)
        cmds.setKeyframe(time=initTime + 40)
        cmds.move(initX + xRand, 10, initZ + zRand)
        cmds.rotate(60, 0, 0)
        cmds.setKeyframe(time=initTime + 30)
        cmds.move(initX, 6, initZ)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe(time=initTime + 20)
        cmds.move(initX, 3, initZ)
        cmds.scale(3, 3, 3)
        cmds.setKeyframe(time=initTime + 10)
        cmds.move(initX, 0, initZ)
        cmds.scale(1, .8, 1)
        cmds.setKeyframe(time=initTime)
Exemple #18
0
    def _handleExampleButton(self):
        time = 120
        d = cmds.polyCylinder(r=15,
                              h=20,
                              sx=40,
                              sy=10,
                              sz=1,
                              ax=(0, 0, 0),
                              rcp=0,
                              cuv=2,
                              ch=1,
                              n='CylinderContainer')[0]
        cmds.move(0, 10, 0)

        cmds.select(d)

        response = nimble.createRemoteResponse(globals())
        response.put('name', d)
        num = self.NumBubbles.value()
        bubble = "bubble"
        for i in range(num):

            randomX = random.randrange(-10, 10)
            randomY = random.randrange(1, 2)
            randomZ = random.randrange(-10, 10)
            circleShape(randomX, randomY, randomZ, bubble, 1, None, time)
            bubble = "bubble" + str(i)
Exemple #19
0
    def _handleInit(self):
        floor = mc.polyPlane(w=600,h=600)
        mc.move(0,-5,0)

        mc.ambientLight()
        mc.pointLight()
        mc.move(600,600,600)
Exemple #20
0
def createRing(name, index):
    cmds.polyCylinder(r=1.288, sx=48, n=fn('cyl', index))
    cmds.polyTorus(n=fn('torus', index), sx=48, sy=24)
    cmds.polyBoolOp(fn('torus', index),
                    fn('cyl', index),
                    op=2,
                    n=fn(name, index))
    cmds.move(.407, y=True)
Exemple #21
0
 def instanceCube(self, **kwargs):
     """Doc..."""
     name   = self._name if self._name else 'instanceCube'
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name=name, height=height, width=self._width)
     cmds.move(x, 10, 0, res[0])
     return res
Exemple #22
0
 def instanceCube(self, **kwargs):
     """Doc..."""
     name   = self._name if self._name else 'instanceCube'
     height = kwargs['height'] if 'height' in kwargs else 2
     x      = kwargs['x'] if 'x' in kwargs else 0
     res    = cmds.polyCube(name=name, height=height, width=self._width)
     cmds.move(x, 10, 0, res[0])
     return res
Exemple #23
0
def createBubble(tx, tz, name):
    """
    :param tx: translate x value
    :param tz: translate z value
    :param name: string name of bubble
    :return: nothing
    """
    cmds.polySphere(sx=15, sy=15, r=.1, n=name)
    cmds.move(tx,0,tz, name, absolute=True)
Exemple #24
0
 def _handleDefendButton(self):
     #driven: all arms and joint; driver: the translateX of the ball
     self._rightArmDrivenKeyframe()
     #set the new values
     cmds.move( -2.5, 0, 0, 'ball', relative=True)
     cmds.rotate('0', '-72', '0', 'SF|RShoulderJoint|RightArm')
     cmds.rotate('0', '0', '53', 'SF|RShoulderJoint|RightArm|RHandJoint|RHand')
     #reset driven: all arms and joint; driver: the translateX of the ball
     self._rightArmDrivenKeyframe()
def doSecond():
    filePath = "C:/Users/Kyle/Downloads/x_wing/x_wing.mb"

    cmds.file(filePath, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='x_wing', i=True )
    cmds.select('x_wing:polySurface3')
    cmds.scale(.1,.1,.1)
    cmds.move(0,10,10)
    cmds.setKeyframe(time=1)
    cmds.move(0,10,-10)
    cmds.setKeyframe(time=120)
Exemple #26
0
def createBar(name, index):
    ## actual standard gold bar dimensions (inches)
    y = 1.75
    x = 7.
    z = 3.63
    cmds.polyCube(h=y, w=x, d=z, n=fn(name, index))
    cmds.scale(.94, .9, fn(name, index) + '.f[1]', xz=True)
    cmds.move(y / 4 + .001, y=True, relative=True)
    cmds.scale(.5, .5, .5)
    cmds.polyBevel(fn(name, index), o=.07, sg=12)
 def handleSchnauzDownBtn(self):
     global schnauzActAmt
     global incAmt
     btmCapAmt = 0.000
     cmds.select("schnauzClusterHandle")
     schnauzActAmt -= incAmt
     if schnauzActAmt >= btmCapAmt:
         print schnauzActAmt
         cmds.move(0, schnauzActAmt, 0)
     else:
         schnauzActAmt = btmCapAmt
 def handleSchnauzUpBtn(self):
     global schnauzActAmt
     global incAmt
     topCapAmt = 0.028
     cmds.select('schnauzClusterHandle')
     schnauzActAmt += incAmt
     if schnauzActAmt <= topCapAmt:
         print schnauzActAmt
         cmds.move(0, schnauzActAmt, 0)
     else:
         schnauzActAmt = topCapAmt
 def handleDownBtn(self):
     global smileActAmt
     global incAmt
     btmCapAmt = -0.032
     cmds.select('smileClusterHandle')
     smileActAmt -= incAmt
     if smileActAmt >= btmCapAmt:
         print smileActAmt
         cmds.move(0, smileActAmt, 0)
     else:
         smileActAmt = btmCapAmt
 def handleEyebrowsDwnBtn(self):
     global eyebrowsActAmt
     global eyebrowsIncAmt
     btmCapAmt = -0.014
     cmds.select('eyebrowsClusterHandle')
     eyebrowsActAmt -= eyebrowsIncAmt
     if eyebrowsActAmt >= btmCapAmt:
         print eyebrowsActAmt
         cmds.move(0, eyebrowsActAmt, 0)
     else:
         eyebrowsActAmt = btmCapAmt
 def handleDownBtn(self):
     global smileActAmt
     global incAmt
     btmCapAmt = -0.032
     cmds.select("smileClusterHandle")
     smileActAmt -= incAmt
     if smileActAmt >= btmCapAmt:
         print smileActAmt
         cmds.move(0, smileActAmt, 0)
     else:
         smileActAmt = btmCapAmt
 def handleUpBtn(self):
     global smileActAmt
     global incAmt
     topCapAmt = 0.016
     cmds.select('smileClusterHandle')
     smileActAmt += incAmt
     if smileActAmt <= topCapAmt:
         print smileActAmt
         cmds.move(0, smileActAmt, 0)
     else:
         smileActAmt = topCapAmt
 def handleEyebrowsDwnBtn(self):
     global eyebrowsActAmt
     global eyebrowsIncAmt
     btmCapAmt = -0.014
     cmds.select("eyebrowsClusterHandle")
     eyebrowsActAmt -= eyebrowsIncAmt
     if eyebrowsActAmt >= btmCapAmt:
         print eyebrowsActAmt
         cmds.move(0, eyebrowsActAmt, 0)
     else:
         eyebrowsActAmt = btmCapAmt
 def handleEyebrowsUpBtn(self):
     global eyebrowsActAmt
     global eyebrowsIncAmt
     topCapAmt = 0.021
     cmds.select("eyebrowsClusterHandle")
     eyebrowsActAmt += eyebrowsIncAmt
     if eyebrowsActAmt <= topCapAmt:
         print eyebrowsActAmt
         cmds.move(0, eyebrowsActAmt, 0)
     else:
         eyebrowsActAmt = topCapAmt
 def handleUpBtn(self):
     global smileActAmt
     global incAmt
     topCapAmt = 0.016
     cmds.select("smileClusterHandle")
     smileActAmt += incAmt
     if smileActAmt <= topCapAmt:
         print smileActAmt
         cmds.move(0, smileActAmt, 0)
     else:
         smileActAmt = topCapAmt
 def handleEyebrowsUpBtn(self):
     global eyebrowsActAmt
     global eyebrowsIncAmt
     topCapAmt = 0.021
     cmds.select('eyebrowsClusterHandle')
     eyebrowsActAmt += eyebrowsIncAmt
     if eyebrowsActAmt <= topCapAmt:
         print eyebrowsActAmt
         cmds.move(0, eyebrowsActAmt, 0)
     else:
         eyebrowsActAmt = topCapAmt
 def handleSchnauzDownBtn(self):
     global schnauzActAmt
     global incAmt
     btmCapAmt = 0.000
     cmds.select('schnauzClusterHandle')
     schnauzActAmt -= incAmt
     if schnauzActAmt >= btmCapAmt:
         print schnauzActAmt
         cmds.move(0, schnauzActAmt, 0)
     else:
         schnauzActAmt = btmCapAmt
 def handleSchnauzUpBtn(self):
     global schnauzActAmt
     global incAmt
     topCapAmt = 0.028
     cmds.select("schnauzClusterHandle")
     schnauzActAmt += incAmt
     if schnauzActAmt <= topCapAmt:
         print schnauzActAmt
         cmds.move(0, schnauzActAmt, 0)
     else:
         schnauzActAmt = topCapAmt
        def MoveVertex(min, max):
            cmds.select(ado=True)
            selected = cmds.ls(selection=True, long=True)

            for object in selected:
                total = cmds.polyEvaluate(object, vertex=True)
                for i in range(total):

                    randNumX = random.uniform(min, max)
                    randNumY = random.uniform(min, max)
                    randNumZ = random.uniform(min, max)
                    vertex = object+'.vtx['+str(i)+']'
                    cmds.select(vertex)
                    cmds.move(randNumX, randNumY, randNumZ, relative=True)
Exemple #40
0
 def _handleSphereButton(self):
     """
     This callback creates a polygonal sphere in the Maya scene.
     it then translates it.
     """
     r = 2
     a = 2.0*r
     y = (0, 1, 0) # y up
     c = cmds.polySphere(
         r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
     cmds.select(c)
     cmd.move(0, 5, 0, r = True)
     response = nimble.createRemoteResponse(globals())
     response.put('name', c)
Exemple #41
0
    def handleBallBtn(self):
        cmds.select('ball')
        cmds.currentTime(74)
        cmds.setKeyframe('ball')

        cmds.currentTime(112)
        cmds.move(-0.757, 6.434, 15.831)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')

        cmds.currentTime(144)
        cmds.move(-0.772, 0.637, 22.462)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')
Exemple #42
0
    def _handleGoButton(self):
        start = self.rangeStartSlide.value()    #get user-def range start
        end = self.rangeEndSlide.value()        #get user-def range end
        selObj = cmds.ls(sl=True)[0]            #Get selected object
        numVerts = cmds.polyEvaluate(selObj, v=True)

        #-----For each vertex...------
        for i in range(numVerts):
            pos = cmds.pointPosition(selObj+'.vtx['+str(i)+']')
            randX = random.randrange(start,end)
            randY = random.randrange(start,end)
            randZ = random.randrange(start,end)
            cmds.move(randX, randY, randZ, selObj+'.vtx['+str(i)+']', r=True)
            print cmds.pointPosition(selObj+'.vtx['+str(i)+']')
        def MoveVertex(min, max):
            cmds.select(ado=True)
            selected = cmds.ls(selection=True, long=True)

            for object in selected:
                total = cmds.polyEvaluate(object, vertex=True)
                for i in range(total):

                    randNumX = random.uniform(min, max)
                    randNumY = random.uniform(min, max)
                    randNumZ = random.uniform(min, max)
                    vertex = object + '.vtx[' + str(i) + ']'
                    cmds.select(vertex)
                    cmds.move(randNumX, randNumY, randNumZ, relative=True)
    def handleBallBtn(self):
        cmds.select('ball')
        cmds.currentTime(74)
        cmds.setKeyframe('ball')

        cmds.currentTime(112)
        cmds.move(-0.757, 6.434, 15.831)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')

        cmds.currentTime(144)
        cmds.move(-0.772, 0.637, 22.462)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')
Exemple #45
0
 def _handleRoadButton(self):
     exist = cmds.ls('road')
     if(len(exist) != 0):
         cmds.delete('road')
     road=cmds.group(empty=True, name='road')
     transformName = cmds.ls('brick', typ='transform')[0]
     num = int(self.bricksNum.text())
     for i in range(0, num):
         instanceResult = cmds.instance(transformName, name=transformName + '_instance#')
         #print 'instanceResult: ' + str(instanceResult)
         x = random.uniform(-3, 34)
         z = random.uniform(-3,3)
         cmds.move(x, 0, z, instanceResult)
         yRot = random.uniform(0,360)
         cmds.rotate(0, yRot, 0, instanceResult)
         cmds.parent(instanceResult, road)
Exemple #46
0
    def _duplicate(self):
        #set the random seed
        random.seed(1024)

        for i in range (0, 100):
            cmds.duplicate('H2O')
            #let the instances rotate
            objName='H2O' + str(i+1)
            #random place
            x = random.uniform(-30,30)
            y = random.uniform(0, 40)
            z = random.uniform(-30, 30)
            cmds.move(x, y, z, objName)
            #random rotate
            xRot=random.uniform(0, 360)
            yRot=random.uniform(0, 360)
            zRot=random.uniform(0, 360)
            cmds.rotate(xRot, yRot, zRot, objName)
Exemple #47
0
    def _createJoints(self, name):
        #bone
        mc.select(cl=True)

        self.j_root = mc.joint(p=(0, 0, 0), n=name + '_j_root')
        self.j_s1 = mc.joint(p=(0, 11, 1), n=name + '_j_s1')
        self.j_s2 = mc.joint(p=(0, 22, 1), n=name + '_j_s2')
        self.j_s3 = mc.joint(p=(0, 33, 1), n=name + '_j_s3')
        self.j_s4 = mc.joint(p=(0, 44, 1), n=name + '_j_s4')
        self.j_s5 = mc.joint(p=(0, 55, 1), n=name + '_j_s5')
        self.j_neck = mc.joint(p=(0, 67, 0), n=name + '_j_neck')

        mc.select(cl=True)
        self.j_bind_root = mc.joint(p=(0, 0, 0), n=name + '_j_bind_root')
        mc.select(cl=True)
        self.j_bind_neck = mc.joint(p=(0, 67, 0), n=name + '_j_bind_neck')

        #mc.parent(self.j_bind_root, self.j_root)
        #mc.parent(self.j_bind_neck, self.j_neck)

        self.h_hips = mc.circle(nr=(0, 1, 0),
                                c=(0, 0, 0),
                                r=50,
                                n=name + "_hips_IK_handle")[0]
        self.h_shoulders = mc.circle(nr=(0, 1, 0),
                                     c=(0, 67, 0),
                                     r=70,
                                     n=name + "_shoulders_IK_handle")[0]
        mc.move(0, 67, 0, self.h_shoulders + ".scalePivot",
                self.h_shoulders + ".rotatePivot")

        mc.parentConstraint(self.h_hips, self.j_bind_root, mo=True)
        mc.parentConstraint(self.h_shoulders, self.j_bind_neck, mo=True)
        #mc.parent(self.h_hips, self.torso)
        #mc.parent(self.h_shoulders, self.torso)

        mc.parent(self.torso, self.j_root)
        mc.parent(self.clavical, self.j_neck)
        mc.parent(self.cockpit, self.j_s3)
        mc.parent(self.chest, self.j_s5)

        pass
Exemple #48
0
 def _handleDuplicatedButton(self):
     random.seed(1234)
     exist = cmds.ls('dust')
     if(len(exist) != 0):
         cmds.delete('dust')
     dust=cmds.group(empty=True, name='dust')
     transformName = cmds.ls('pie', typ='transform')[0]
     num = int(self.dustNum.text())
     for i in range(0, num):
         instanceResult = cmds.instance(transformName, name=transformName + '_instance#')
         #print 'instanceResult: ' + str(instanceResult)
         x = random.uniform(-3, 34)
         y = random.uniform(0,4)
         z = random.uniform(-3,3)
         cmds.move(x, y, z, instanceResult)
         xRot = random.uniform(0,360)
         yRot = random.uniform(0,360)
         zRot = random.uniform(0,360)
         cmds.rotate(xRot, yRot, zRot, instanceResult)
         cmds.parent(instanceResult, dust)
Exemple #49
0
    def createRenderEnvironment(self):
        lightName = 'scenic_light1'
        if not cmds.objExists(lightName):
            lightName = cmds.directionalLight(name=lightName, intensity=0.5)
            cmds.move(0, 2500, 0, lightName)
            cmds.rotate('-45deg', '-45deg', 0, lightName)

        lightName = 'scenic_light2'
        if not cmds.objExists(lightName):
            lightName = cmds.directionalLight(name=lightName, intensity=0.5)
            cmds.move(0, 2500, 0, lightName)
            cmds.rotate('-45deg', '135deg', 0, lightName)

        floorName = 'floor'
        if not cmds.objExists(floorName):
            floorName = cmds.polyPlane(width=10000, height=10000, name=floorName)[0]
        shader, shaderEngine = self.createShader('Whiteout_Surface', 'surfaceShader')
        cmds.setAttr(shader + '.outColor', 1.0, 1.0, 1.0, type='double3')
        cmds.select([floorName])
        cmds.sets(forceElement=shaderEngine)
Exemple #50
0
def drawBubble(radius, xpoint, ypoint, zpoint, name, time):
    """
    Arguments: radius is the size of the overall shape
    Return: None
    """

    y = (0, 1, 0)
    d = cmds.polyCylinder(r=10,
                          h=20,
                          sx=40,
                          sy=10,
                          sz=1,
                          ax=(0, 0, 0),
                          rcp=0,
                          cuv=2,
                          ch=1,
                          n='CylinderContainer')[0]
    cmds.move(0, 10, 0)
    cmds.select(d)
    response = nimble.createRemoteResponse(globals())
    response.put('name', d)
    c = cmds.polySphere(r=radius, ax=y, cuv=2, ch=1, n=name)[0]

    xpoint = 0
    for i in range(1, time + 1, 3):  # figure out best time step
        cmds.setKeyframe(name, t=i)
        cmds.move(xpoint, ypoint, zpoint, relative=False)
        cmds.select(name)
        response = nimble.createRemoteResponse(globals())
        response.put('name', name)
        xpoint = xpoint + .1  # need to do some physics for theses
        print(ypoint, i)
        if ypoint >= 19.5:
            ypoint = 20
            print("pop")
            break
        else:
            ypoint = (.55 + float(ypoint))
        zpoint = zpoint + .001
    #cmds.setKeyframe( name , at="translateY", t=time, v=xpoint + 3)
    return None
Exemple #51
0
def main(bubbleQuantity, allAtts):
    for i in range(bubbleQuantity): # create 50 bubbles
        name = 'bubble' + str(i) # name them sequentially

        """
        first -- a random integer between 1 and 50
        which represents the keyframe in which a
        bubble is generated
        """
        first = random.randint(1,300)

        last = first + 66 # all bubbles take 66 keyframes to rise
        x = 10 - random.random()*20 # this makes x values in the range [-10.0,10.0]
        z = 10 - random.random()*20 # this makes z values in the range [-10.0,10.0]
        createBubble(x,z,name)
        cmds.currentTime(first)

        cmds.setKeyframe( name, v=1, at='visibility' )
        cmds.setKeyframe(name)
        cmds.currentTime(last)

        ############ keyframe all attributes ############
        if allAtts:
            cmds.scale(10,10,10, name)
            cmds.move(0, 20, 0, name, relative=True)
            cmds.setKeyframe()
        #################################################

        ####### keyframe only necessary attributes ######
        else:
            cmds.setKeyframe( name, v=10, at='scaleX' )
            cmds.setKeyframe( name, v=10, at='scaleY' )
            cmds.setKeyframe( name, v=10, at='scaleZ' )
            cmds.setKeyframe( name, v=10, at='translateY' )
        #################################################

        cmds.currentTime(last + 1)
        cmds.setKeyframe( name, v=0, at='visibility' )
    cmds.currentTime(1)
Exemple #52
0
    def initializeCadenceCam(self):
        """ This creates an orthographic camera that looks down the Y axis onto
            the XZ plane, and rotated so that the AI file track labels are
            legible.  This camera is positioned so that the given track nodeName
            is centered in its field by setCameraFocus. """

        if cmds.objExists(self.CADENCE_CAM):
            return

        priorSelection = MayaUtils.getSelectedTransforms()

        c = cmds.camera(
            orthographic=True,
            nearClipPlane=1,
            farClipPlane=100000,
            orthographicWidth=400)
        cmds.setAttr(c[0] + '.visibility', False)
        cmds.rename(c[0], self.CADENCE_CAM)
        cmds.rotate(-90, 180, 0)
        cmds.move(0, 100, 0, self.CADENCE_CAM, absolute=True)

        MayaUtils.setSelection(priorSelection)
    def _handlePerturb(self):
        """
        This perturbs the selected object.

        """

        selectedObjects = cmds.ls(selection=True, long=True)

        vertsList = []
        for object in selectedObjects:
            totalVerts = cmds.polyEvaluate(object, vertex=True)

            for number in range(totalVerts):
                vertsList.append(object+'.vtx[{number}]'.format(number=number))

        for vert in vertsList:
            min = float(self.minInput.displayText())
            max = float(self.maxInput.displayText())
            randNumX = random.uniform(min, max)
            randNumY = random.uniform(min, max)
            randNumZ = random.uniform(min, max)
            cmds.select(vert, replace=True)
            cmds.move(randNumX, randNumY, randNumZ, relative=True)
            cmds.select(selectedObjects, replace=True)
Exemple #54
0
    def createToken(cls, uid, props, trackSetNode =None):
        """ A token is created, provided with some additional Maya attributes,
            and placed in the scene. Tokens are functtionally similar to
            TrackNodes, but with different shapes and attributes. """

        cylinderHeight = 5.0
        coneHeight     = 10.0

        if not trackSetNode:
            trackSetNode = TrackSceneUtils.getTrackSetNode()

        if not trackSetNode:
            return None

        node = cls.getTrackNode(uid, trackSetNode=trackSetNode)

        if node:
            return node

        # determine whether left or right, and manus or pes, from name
        name = props['name'] if props else None
        if not name:
            print('createToken:  No properties specified')
            return
        # remove '_proxy' or '_token' if present (as in S6_LP3_proxy)
        nameFields = cls.decomposeName(name.split('_')[0])
        isLeft     = nameFields['left']
        isPes      = nameFields['pes']

        # make a cone for the token of an proxy else a cylinder
        if uid.endswith('_proxy'):
            node = cmds.polyCone(
                radius=0.5,
                height=coneHeight,
                subdivisionsX=10,
                subdivisionsY=1,
                subdivisionsZ=1,
                axis=(0, 1, 0),
                createUVs=0,
                constructionHistory=0,
                name='Token_0')[0]
            cmds.move(0, 0.5 * coneHeight, 0)
        else:
            node = cmds.polyCylinder(
                radius=0.5,
                height=cylinderHeight,
                subdivisionsX=10,
                subdivisionsY=1,
                subdivisionsZ=1,
                subdivisionsCaps=0,
                axis=(0, 1, 0),
                createUVs=0,
                constructionHistory=0,
                name='Token_0')[0]
            cmds.move(0, 0.5 * cylinderHeight, 0)

        # Set up the basic cadence attributes
        cmds.addAttr(longName='cadence_dx', shortName='dx', niceName='DX')
        cmds.addAttr(longName='cadence_dy', shortName='dy', niceName='DY')

        cmds.addAttr(
             longName='cadence_uniqueId',
             shortName='track_uid',
             dataType='string',
             niceName='UID')

        cmds.addAttr(
             longName='cadence_name',
             shortName='token_name',
             dataType='string',
             niceName='Name')

        # Disable some transform attributes
        cmds.setAttr(node + '.rotateX',    lock=True)
        cmds.setAttr(node + '.rotateZ',    lock=True)
        cmds.setAttr(node + '.scaleY',     lock=True)
        cmds.setAttr(node + '.translateY', lock=True)

        # Scale the cylinder/cone in x and z to represent 'dy' and 'dx' in
        # centimeters. There is a change of coordinates between Maya (X, Z) and
        # the simulator (X, Y) space. For example, for the right manus:
        #    x = int(100*float(entry['rm_y']))
        #    z = int(100*float(entry['rm_x']))
        # and likewise for dx and dy.

        # the DX and DY attributes affect scaleZ and scaleX in the node
        cmds.connectAttr(node + '.dx', node + '.scaleZ')
        cmds.connectAttr(node + '.dy', node + '.scaleX')

        # add a short annotation based on the name
        annotation = cmds.annotate(node, text=cls.shortName(props['name']))
        cmds.select(annotation)
        aTransform = cmds.pickWalk(direction='up')[0]

        # control it's position by that of the node, so that it stays 15 cm
        # above the pes and 10 cm above the manus
        if isPes:
            cmds.move(0.0, 15.0, 0.0, aTransform)
        else:
            cmds.move(0.0, 10.0, 0.0, aTransform)

        cmds.connectAttr(node + '.translateX', aTransform + '.translateX')
        cmds.connectAttr(node + '.translateZ', aTransform + '.translateZ')

        # and make it non-selectable
        cmds.setAttr(aTransform + '.overrideEnabled', 1)
        cmds.setAttr(aTransform + '.overrideDisplayType', 2)
        cmds.rename(aTransform, "TokenAnnotation_0")

        if isPes:
            if isLeft:
                color = TrackwayShaderConfig.LEFT_PES_TOKEN_COLOR
            else:
                color = TrackwayShaderConfig.RIGHT_PES_TOKEN_COLOR
        else:
            if isLeft:
                color = TrackwayShaderConfig.LEFT_MANUS_TOKEN_COLOR
            else:
                color = TrackwayShaderConfig.RIGHT_MANUS_TOKEN_COLOR
        ShadingUtils.applyShader(color, node)

        cmds.select(node)
        # add the new node to the Cadence track set
        cmds.sets(node, add=trackSetNode)

        # finally, initialize all the properties from the dictionary props
        cls.setTokenProps(node, props)

        return node
Exemple #55
0
    def createTrackNode(cls, uid, trackSetNode =None, props =None):
        """ A track node consists of a triangular pointer (left = red, right =
            green) which is selectable but only allows rotateY, translateX, and
            translateZ. The node has a child, a transform called inverter, which
            serves to counteract the scaling in x and z that is applied to the
            triangular node.  There are two orthogonal rulers (width and
            length).  Width and length uncertainty is represented by rectangular
            bars at the ends of the rulers.  In Maya one can directly adjust
            track position (translateX and translateZ) and orientation
            (rotationY); other attributes are adjusted only through the UI. """

        if not trackSetNode:
            trackSetNode = TrackSceneUtils.getTrackSetNode()

        if not trackSetNode:
            return None

        node = cls.getTrackNode(uid, trackSetNode=trackSetNode)
        if node:
            return node

        # Set up dimensional constants for the track node
        nodeThickness  = 1.0
        thetaBreadth   = 0.1
        thetaThickness = 0.5
        barBreadth     = 2.0
        barThickness   = 0.5
        rulerBreadth   = 1.0
        rulerThickness = 0.25
        epsilon        = 1.0

        # Create an isoceles triangle pointer, with base aligned with X, and
        # scaled by node.width.  The midpoint of the base is centered on the
        # 'track center' and the altitude extends from that center of the track
        # 'anteriorly' to the perimeter of the track's profile (if present, else
        # estimated).  The node is scaled longitudinally (in z) based on the
        # distance zN (the 'anterior' length of the track, in cm).  The triangle
        # is initially 1 cm on a side.
        sideLength = 1.0
        node = cmds.polyPrism(
            length=nodeThickness,
            sideLength=sideLength,
            numberOfSides=3,
            subdivisionsHeight=1,
            subdivisionsCaps=0,
            axis=(0, 1, 0),
            createUVs=0,
            constructionHistory=0,
            name='Track0')[0]

        # Point the triangle down the +Z axis
        cmds.rotate(0.0, -90.0, 0.0)

        # push it down below ground level so that the two rulers are just
        # submerged, and scale the triangle in Z to match its width (1 cm) so it
        # is ready to be scaled
        cmds.move(0, -(nodeThickness/2.0 + rulerThickness), math.sqrt(3.0)/6.0)

        # move the node's pivot to the 'base' of the triangle so it scales
        # outward from that point
        cmds.move(
            0, 0, 0, node + ".scalePivot", node + ".rotatePivot", absolute=True)
        cmds.scale(2.0/math.sqrt(3.0), 1.0, 100.0)
        cmds.makeIdentity(
            apply=True,
            translate=True,
            rotate=True,
            scale=True,
            normal=False)

        # Set up the cadence attributes
        cmds.addAttr(
             longName='cadence_width',
             shortName=TrackPropEnum.WIDTH.maya,
             niceName='Width')
        cmds.addAttr(
             longName='cadence_widthUncertainty',
             shortName=TrackPropEnum.WIDTH_UNCERTAINTY.maya,
             niceName='Width Uncertainty')
        cmds.addAttr(
             longName='cadence_length',
             shortName=TrackPropEnum.LENGTH.maya,
             niceName='Length')
        cmds.addAttr(
             longName='cadence_lengthUncertainty',
             shortName=TrackPropEnum.LENGTH_UNCERTAINTY.maya,
             niceName='Length Uncertainty')
        cmds.addAttr(
             longName='cadence_lengthRatio',
             shortName=TrackPropEnum.LENGTH_RATIO.maya,
             niceName='Length Ratio')
        cmds.addAttr(
             longName='cadence_rotationUncertainty',
             shortName=TrackPropEnum.ROTATION_UNCERTAINTY.maya,
             niceName='Rotation Uncertainty')
        cmds.addAttr(
             longName='cadence_uniqueId',
             shortName=TrackPropEnum.UID.maya,
             dataType='string',
             niceName='Unique ID')

        # Construct a ruler representing track width, then push it down just
        # below ground level, and ake it non-selectable.  Drive its scale by the
        # node's width attribute.
        widthRuler = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=rulerThickness,
            depth=rulerBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='WidthRuler')[0]

        # Push it down to just rest on the triangular node (which is already
        # submerged by the thickness of the ruler and half the node thickness.
        cmds.move(0.0, -rulerThickness/2.0, 0.0)
        cmds.setAttr(widthRuler + '.overrideEnabled', 1)
        cmds.setAttr(widthRuler + '.overrideDisplayType', 2)

        # Construct a ruler representing track length and push it down the same
        # as the width ruler, and make it non-selectable.  Its length will be
        # driven by the node's length attribute.
        lengthRuler = cmds.polyCube(
            axis=(0, 1, 0),
            width=rulerBreadth,
            height=rulerThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='LengthRuler')[0]
        cmds.move(0.0, -rulerThickness/2.0, 0.0)
        cmds.setAttr(lengthRuler + '.overrideEnabled', 1)
        cmds.setAttr(lengthRuler + '.overrideDisplayType', 2)

        # Now construct 'error bars' to the North, South, West, and East of the
        # node, to visualize uncertainty in width (West and East bars) and
        # length (North and South bars), and push them just below ground level,
        # and make them non-selectable.
        barN = cmds.polyCube(
            axis=(0,1,0),
            width=barBreadth,
            height=barThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarN')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barN + '.overrideEnabled', 1)
        cmds.setAttr(barN + '.overrideDisplayType', 2)

        barS = cmds.polyCube(
            axis=(0, 1, 0),
            width=barBreadth,
            height=barThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarS')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barS + '.overrideEnabled', 1)
        cmds.setAttr(barS + '.overrideDisplayType', 2)

        barW = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=barThickness,
            depth=barBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarW')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barW + '.overrideEnabled', 1)
        cmds.setAttr(barW + '.overrideDisplayType', 2)

        barE = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=barThickness,
            depth=barBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarE')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barE + '.overrideEnabled', 1)
        cmds.setAttr(barE + '.overrideDisplayType', 2)

        # Create two diverging lines that indicate rotation uncertainty (plus
        # and minus), with their pivots placed so they extend from the node
        # center, and each is made non-selectable.  First make the indicator of
        # maximum (counterclockwise) estimated track rotation
        thetaPlus = cmds.polyCube(
            axis=(0, 1, 0),
            width=thetaBreadth,
            height=thetaThickness,
            depth=1.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='ThetaPlus')[0]
        cmds.setAttr(thetaPlus + '.overrideEnabled',     1)
        cmds.setAttr(thetaPlus + '.overrideDisplayType', 2)

        # Next, construct the indicator of the minimum (clockwise) estimate of
        # track rotation
        thetaMinus = cmds.polyCube(
            axis=(0, 1, 0),
            width=thetaBreadth,
            height=thetaThickness,
            depth=1.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='ThetaMinus')[0]
        cmds.setAttr(thetaMinus + '.overrideEnabled',     1)
        cmds.setAttr(thetaMinus + '.overrideDisplayType', 2)

        # The two width 'error bars' will be translated outward from the node
        # center.  First, the width attribute is converted from meters (as it
        # comes from the database) to centimeters; the computation is available
        # in the output of the node 'width'.
        width = cmds.createNode('multiplyDivide', name='width')
        cmds.setAttr(width + '.operation', 1)
        cmds.setAttr(width + '.input1X', 100.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.WIDTH.maya, width + '.input2X')

        # Translate barW in x by width/2.0; output is in xW.outputX
        xW = cmds.createNode('multiplyDivide', name = 'xW')
        cmds.setAttr(xW + '.operation', 2)
        cmds.connectAttr(width + '.outputX', xW + '.input1X')
        cmds.setAttr(xW + '.input2X', 2.0)
        cmds.connectAttr(xW + '.outputX', barW + '.translateX')

        # Translate barE in x by -width/2.0; output is in xE.outputX
        xE = cmds.createNode('multiplyDivide', name = 'xE')
        cmds.setAttr(xE + '.operation', 2) # division operation
        cmds.connectAttr(width + '.outputX', xE + '.input1X')
        cmds.setAttr(xE + '.input2X', -2.0)
        cmds.connectAttr(xE + '.outputX', barE + '.translateX')

        # Now regarding length, first convert the node.length attribute from
        # meters to centimeters. This computation is available in the output of
        # the node 'length'
        length = cmds.createNode('multiplyDivide', name='length')
        cmds.setAttr(length + '.operation', 1)
        cmds.setAttr(length + '.input1X', 100.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.LENGTH.maya, length + '.input2X')

        # scale thetaPlus and thetaMinus by length (since they are 1 cm,
        # multiply by length in cm)
        cmds.connectAttr(length + '.outputX', thetaPlus  + '.scaleZ')
        cmds.connectAttr(length + '.outputX', thetaMinus + '.scaleZ')

        # Then barN is translated forward in z by zN = lengthRatio*length
        # (centimeters)
        zN = cmds.createNode('multiplyDivide', name='zN')
        cmds.setAttr(zN + '.operation', 1)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.LENGTH_RATIO.maya, zN + '.input1X')
        cmds.connectAttr(length + '.outputX',  zN + '.input2X')
        cmds.connectAttr(zN + '.outputX', barN + '.translateZ')

        # Next, translate barS backward in z by (zN - length); output is in
        # zS.output1D
        zS = cmds.createNode('plusMinusAverage', name='sZ')
        cmds.setAttr(zS + '.operation', 2)
        cmds.connectAttr(zN + '.outputX',     zS + '.input1D[0]')
        cmds.connectAttr(length + '.outputX', zS + '.input1D[1]')
        cmds.connectAttr(zS + '.output1D',    barS + '.translateZ')

        # Next, compute the half length, hl = length/2.0 (centimeters)
        hl = cmds.createNode('multiplyDivide', name='hl')
        cmds.setAttr(hl + '.operation', 2)
        cmds.connectAttr(length + '.outputX', hl + '.input1X')
        cmds.setAttr(hl + '.input2X', 2.0)

        # Translate lengthRuler along z by zL = (zN - hl) (centimeters)
        zL = cmds.createNode('plusMinusAverage', name='zL')
        cmds.setAttr(zL + '.operation', 2)
        cmds.connectAttr(zN + '.outputX',  zL + '.input1D[0]')
        cmds.connectAttr(hl + '.outputX',  zL + '.input1D[1]')
        cmds.connectAttr(zL + '.output1D', lengthRuler + '.translateZ')

        # Scale the four 'error bars' to represent the width and length
        # uncertainties (centimeters)
        cmds.connectAttr(
            node + "." + TrackPropEnum.WIDTH_UNCERTAINTY.maya,
            barW + '.scaleX')
        cmds.connectAttr(
            node + "." + TrackPropEnum.WIDTH_UNCERTAINTY.maya,
            barE + '.scaleX')
        cmds.connectAttr(
            node + "." + TrackPropEnum.LENGTH_UNCERTAINTY.maya,
            barN + '.scaleZ')
        cmds.connectAttr(
            node + "." + TrackPropEnum.LENGTH_UNCERTAINTY.maya,
            barS + '.scaleZ')

        # Create an 'inverter' transform under which all the other parts are
        # hung as children, which counteracts scaling applied to its parent
        # triangular node.
        inverter = cmds.createNode('transform', name='inverter')

        # drive the inverter's .scaleX and .scaleZ as the inverse of the parent
        # node's scale values
        sx = cmds.createNode('multiplyDivide', name='sx')
        cmds.setAttr(sx + '.operation', 2)
        cmds.setAttr(sx + '.input1X', 1.0)
        cmds.connectAttr(node + '.scaleX', sx + '.input2X')
        cmds.connectAttr(sx + '.outputX', inverter + '.scaleX')

        sz = cmds.createNode('multiplyDivide', name='sz')
        cmds.setAttr(sz + '.operation', 2)
        cmds.setAttr(sz + '.input1X', 1.0)
        cmds.connectAttr(node + '.scaleZ', sz + '.input2X')
        cmds.connectAttr(sz + '.outputX', inverter + '.scaleZ')

        # Assemble the parts as children under the scale inverter node
        cmds.parent(lengthRuler, inverter)
        cmds.parent(widthRuler,  inverter)
        cmds.parent(barN,        inverter)
        cmds.parent(barS,        inverter)
        cmds.parent(barW,        inverter)
        cmds.parent(barE,        inverter)
        cmds.parent(thetaPlus,   inverter)
        cmds.parent(thetaMinus,  inverter)
        cmds.parent(inverter,    node)

        # Rotate thetaPlus and thetaMinus about the Y axis to indicate
        # rotational uncertainty
        cmds.connectAttr(
            node + '.' + TrackPropEnum.ROTATION_UNCERTAINTY.maya,
            node + '|' + inverter + '|' + thetaPlus + '.rotateY')

        neg = cmds.createNode('multiplyDivide', name='negative')
        cmds.setAttr(neg + '.operation', 1)
        cmds.setAttr(neg + '.input1X',  -1.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.ROTATION_UNCERTAINTY.maya,
            neg + '.input2X')
        cmds.connectAttr(
            neg + '.outputX',
            node + '|' + inverter + '|' + thetaMinus + '.rotateY')

        # Disable some transforms of the node
        cmds.setAttr(node + '.rotateX',    lock=True)
        cmds.setAttr(node + '.rotateZ',    lock=True)
        cmds.setAttr(node + '.scaleY',     lock=True)
        cmds.setAttr(node + '.translateY', lock=True)

        # Now, the width of the triangle will be driven by its width attribute
        # (driving .scaleX)
        cmds.connectAttr(node + '.width',  node + '.scaleX')

        # The quantity zN is used to scale length of the triangle
        cmds.connectAttr(zN + '.outputX',  node + '.scaleZ')

        # Scale the 'length' (in x) of the width ruler
        cmds.connectAttr(
            node + '.width',  node + '|' + inverter + '|WidthRuler.scaleX')

        # Scale the length of the length ruler
        cmds.connectAttr(
            node + '.length', node + '|' + inverter + '|LengthRuler.scaleZ')

        # Translate the track node epsilon below ground level (to reveal the
        # overlaid track siteMap)
        cmds.move(0, -epsilon, 0, node)

        # Initialize all the properties from the dictionary
        if props:
            cls.setTrackProps(node, props)
        else:
            print('in createTrackNode:  properties not provided')
            return node

        # Add the new nodeName to the Cadence track scene set, color it, and
        # we're done
        cmds.sets(node, add=trackSetNode)
        cls.colorTrackNode(node, props)
        return node
Exemple #56
0
 def _handleRestoreButton(self):
     ball = cmds.ls('ball')[0]
     if(ball != None):
         cmds.delete(ball)
     cmds.polySphere(r=0.658, n='ball', ax = [0,0,0])
     cmds.move(29.108,2,-0.2, 'ball')
Exemple #57
0
def functionCube(**kwargs):
    height = kwargs['height'] if 'height' in kwargs else 2
    x      = kwargs['x'] if 'x' in kwargs else 0
    res     = cmds.polyCube(name='functionCube', height=height)
    cmds.move(x, 50, 0, res[0])
    return res
Exemple #58
0
import nimble
from nimble import cmds

kwargs = nimble.getRemoteKwargs(globals())

result = cmds.polySphere()
name = result[0]

offset = kwargs.get('offset', 10)

cmds.move(offset, offset, offset, name)
cmds.rotate(50, 20, 10, name)
cmds.scale(2, 2, 2, name)

response = nimble.createRemoteResponse(globals())
response.put('name', name)
response.put('offset', offset)
Exemple #59
0
    def buildScene(self):
        """Doc..."""

        groupItems = []
        hinds      = []
        fores      = []

        for c in self._data.getChannelsByKind(ChannelsEnum.POSITION):
            isHind = c.target in [TargetsEnum.LEFT_HIND, TargetsEnum.RIGHT_HIND]
            radius = 20 if isHind else 15
            res    = cmds.polySphere(radius=radius, name=c.target)
            groupItems.append(res[0])
            if isHind:
                hinds.append(res[0])
            else:
                fores.append(res[0])

            if c.target == TargetsEnum.LEFT_HIND:
                self._leftHind = res[0]
            elif c.target == TargetsEnum.RIGHT_HIND:
                self._rightHind = res[0]
            elif c.target == TargetsEnum.RIGHT_FORE:
                self._rightFore = res[0]
            elif c.target == TargetsEnum.LEFT_FORE:
                self._leftFore = res[0]

            for k in c.keys:
                frames = [
                    ['translateX', k.value.x, k.inTangentMaya[0], k.outTangentMaya[0]],
                    ['translateY', k.value.y, k.inTangentMaya[1], k.outTangentMaya[1]],
                    ['translateZ', k.value.z, k.inTangentMaya[2], k.outTangentMaya[2]]
                ]
                for f in frames:
                    cmds.setKeyframe(
                        res[0],
                        attribute=f[0],
                        time=k.time,
                        value=f[1],
                        inTangentType=f[2],
                        outTangentType=f[3]
                    )

                if k.event == 'land':
                    printResult = cmds.polyCylinder(
                        name=c.target + '_print1',
                        radius=radius,
                        height=(1.0 if isHind else 5.0)
                    )
                    cmds.move(k.value.x, k.value.y, k.value.z, printResult[0])
                    groupItems.append(printResult[0])

        cfg = self._data.configs
        name = 'cyc' + str(int(cfg.get(GaitConfigEnum.CYCLES))) + \
               '_ph' + str(int(cfg.get(GaitConfigEnum.PHASE))) + \
               '_gad' + str(int(cfg.get(SkeletonConfigEnum.FORE_OFFSET).z)) + \
               '_step' + str(int(cfg.get(SkeletonConfigEnum.STRIDE_LENGTH)))

        cube        = cmds.polyCube(name='pelvic_reference', width=20, height=20, depth=20)
        self._hips  = cube[0]
        groupItems.append(cube[0])
        cmds.move(0, 100, 0, cube[0])

        backLength = self._data.configs.get(SkeletonConfigEnum.FORE_OFFSET).z - \
                     self._data.configs.get(SkeletonConfigEnum.HIND_OFFSET).z

        cube2 = cmds.polyCube(name='pectoral_comparator', width=15, height=15, depth=15)
        cmds.move(0, 115, backLength, cube2[0])
        cmds.parent(cube2[0], cube[0], absolute=True)

        cmds.expression(
            string="%s.translateZ = 0.5*abs(%s.translateZ - %s.translateZ) + min(%s.translateZ, %s.translateZ)" %
            (cube[0], hinds[0], hinds[1], hinds[0], hinds[1])
        )

        cube = cmds.polyCube(name='pectoral_reference', width=15, height=15, depth=15)
        self._pecs = cube[0]
        groupItems.append(cube[0])
        cmds.move(0, 100, 0, cube[0])
        cmds.expression(
            string="%s.translateZ = 0.5*abs(%s.translateZ - %s.translateZ) + min(%s.translateZ, %s.translateZ)" %
            (cube[0], fores[0], fores[1], fores[0], fores[1])
        )

        self._group = cmds.group(*groupItems, world=True, name=name)

        cfg = self._data.configs
        info = 'Gait Phase: ' + \
                str(cfg.get(GaitConfigEnum.PHASE)) + \
                '\nGleno-Acetabular Distance (GAD): ' + \
                str(cfg.get(SkeletonConfigEnum.FORE_OFFSET).z) + \
                '\nStep Length: ' + \
                str(cfg.get(SkeletonConfigEnum.STRIDE_LENGTH)) + \
                '\nHind Duty Factor: ' + \
                str(cfg.get(GaitConfigEnum.DUTY_FACTOR_HIND)) + \
                '\nFore Duty Factor: ' + \
                str(cfg.get(GaitConfigEnum.DUTY_FACTOR_FORE)) + \
                '\nCycles: ' + \
                str(cfg.get(GaitConfigEnum.CYCLES))

        cmds.select(self._group)
        if not cmds.attributeQuery('notes', node=self._group, exists=True):
            cmds.addAttr(longName='notes', dataType='string')
            cmds.setAttr(self._group + '.notes', info, type='string')

        self.createShaders()
        self.createRenderEnvironment()

        minTime = min(0, int(cmds.playbackOptions(query=True, minTime=True)))

        deltaTime = cfg.get(GeneralConfigEnum.STOP_TIME) - cfg.get(GeneralConfigEnum.START_TIME)
        maxTime = max(
            int(float(cfg.get(GaitConfigEnum.CYCLES))*float(deltaTime)),
            int(cmds.playbackOptions(query=True, maxTime=True))
        )

        cmds.playbackOptions(
            minTime=minTime, animationStartTime=minTime, maxTime= maxTime, animationEndTime=maxTime
        )

        cmds.currentTime(0, update=True)

        cmds.select(self._group)
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """

        random.seed(1234)

        #check
        sphereList = cmds.ls('hydrogen1','hydrogen2', 'oxygen','H2O')

        if len(sphereList)>0:
            cmds.delete(sphereList)

        #create 2 hydrogen and oxygen
        h1 = cmds.polySphere(r=12.0, name='hydrogen1')
        h2 = cmds.polySphere(r=12.0, name='hydrogen2')
        oxygen = cmds.polySphere(r=15.0, name='oxygen')


        #move
        cmds.move(-15,0,0,h1)
        cmds.move(15,0,0,h2)
        cmds.xform(h1, piv=[0,0,0],ws=True)
        cmds.xform(h2, piv=[0,0,0],ws=True)
        cmds.rotate(0,'75',0,h1)

        #group hydrogen and oxygen together
        H2O = cmds.group(empty=True, name='H2O#')
        cmds.parent('hydrogen1','hydrogen2','oxygen','H2O1')

        #add color
        def createMaterial( name, color, type ):
            cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG' )
            cmds.shadingNode( type, asShader=True, name=name )
            cmds.setAttr( name+'.color', color[0], color[1], color[2], type='double3')
            cmds.connectAttr(name+'.outColor', name+'SG.surfaceShader')

        def assignMaterial (name, object):
            cmds.sets(object, edit=True, forceElement=name+'SG')

        def assignNewMaterial( name, color, type, object):
            createMaterial (name, color, type)
            assignMaterial (name, object)

        #H is white and O is red
        assignNewMaterial('Red', (1,0,0), 'lambert', 'oxygen');
        assignNewMaterial('White',(1,1,1),'lambert', 'hydrogen1');
        assignMaterial('White', 'hydrogen2');

        #key frame
        def keyFullRotation( pObjectName, pStartTime, pEndTime, pTargetAttribute,pValueStart, pvalueEnd ):
            keyt = (pStartTime[0], pStartTime[0])
            cmds.cutKey( pObjectName, time=(keyt, keyt), attribute=pTargetAttribute )
            cmds.setKeyframe( pObjectName, time=pStartTime, attribute=pTargetAttribute, value=pValueStart )
            cmds.setKeyframe( pObjectName, time=pEndTime, attribute=pTargetAttribute, value=pvalueEnd )
            #cmds.selectKey( pObjectName, time=(pStartTime, [pEndTime]), attribute=pTargetAttribute, keyframe=True )

        #duplicate H2O
        for i in range(1,52):
            cmds.duplicate(H2O)
            #get random coord
            x = random.uniform(-200,200)
            y = random.uniform(0,300)
            z = random.uniform(-200,200)

            cmds.move(x,y,z, H2O)


            xRot = random.uniform(0,360)
            yRot = random.uniform(0,360)
            zRot = random.uniform(0,360)

            cmds.rotate(xRot,yRot,zRot,H2O)

            startTime = cmds.playbackOptions(minTime=1 )
            endTime = cmds.playbackOptions( maxTime=30 )

            h2o = "H2O"+str(i)

            for y in range(3):
                coordsX = cmds.getAttr( h2o+'.translateX' )
                coordsY = cmds.getAttr( h2o+'.translateY' )
                coordsZ = cmds.getAttr( h2o+'.translateZ' )

                ranStartX = int(random.uniform(0,15))
                ranStartY = int(random.uniform(0,15))
                ranStartZ = int(random.uniform(0,15))

                ranEndX = int(random.uniform(15,30))
                ranEndY = int(random.uniform(15,30))
                ranEndZ = int(random.uniform(15,30))

                x = random.uniform(coordsX-50,coordsX+50)
                y = random.uniform(coordsY,coordsY+50)
                z = random.uniform(coordsZ-50,coordsZ+50)
                #print x,y,z

                keyFullRotation( h2o, ranStartZ, 15, 'translateZ',coordsZ,z)
                keyFullRotation( h2o, ranStartX, 15, 'translateX', coordsX,x)
                keyFullRotation( h2o, ranStartY, 15, 'translateY', coordsY,y)

                keyFullRotation( h2o, 15, ranEndZ, 'translateZ',z,coordsZ)
                keyFullRotation( h2o, 15, ranEndX, 'translateX', x,coordsX)
                keyFullRotation( h2o, 15, ranEndY, 'translateY', y,coordsY)

                RcoordsX = cmds.getAttr( h2o+'.rotateX' )
                RcoordsY = cmds.getAttr( h2o+'.rotateY' )
                RcoordsZ = cmds.getAttr( h2o+'.rotateZ' )

                xRot = random.uniform(0,360)
                yRot = random.uniform(0,360)
                zRot = random.uniform(0,360)

                keyFullRotation( h2o, ranStartZ, 15, 'rotateZ',RcoordsZ,zRot)
                keyFullRotation( h2o, ranStartX, 15, 'rotateX', RcoordsX,xRot)
                keyFullRotation( h2o, ranStartY, 15, 'rotateY', RcoordsY,zRot)

                keyFullRotation( h2o, 15, ranEndZ, 'rotateZ',zRot,RcoordsZ)
                keyFullRotation( h2o, 15, ranEndX, 'rotateX', xRot,RcoordsX)
                keyFullRotation( h2o, 15, ranEndY, 'rotateY', zRot,RcoordsY)

        print 'done'
        cmds.delete('H2O52')