コード例 #1
0
    def _generateTerrain(self):
        cmds.polyPlane(n='terrain',
                       sx=self.size - 1,
                       sy=self.size - 1,
                       w=self.size,
                       h=self.size)
        shapes = cmds.ls("terrain", sl=True, fl=True)
        self.terrain = shapes[0]

        offset_magnitude = int(self.magnitude)
        self.setVertexHeight((0, 0),
                             randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((self.size - 1, 0),
                             randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((0, self.size - 1),
                             randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((self.size - 1, self.size - 1),
                             randint(-offset_magnitude, offset_magnitude))

        length = self.size - 1
        while length >= 1:
            half_length = length / 2
            for x in range(0, self.size - 1, length):
                for y in range(0, self.size - 1, length):
                    bottom_left = self.getVertexHeight((x, y))
                    bottom_right = self.getVertexHeight((x + length, y))
                    top_left = self.getVertexHeight((x, y + length))
                    top_right = self.getVertexHeight((x + length, y + length))
                    average = (top_left + top_right + bottom_left +
                               bottom_right) / 4.0
                    offset = randint(int(-offset_magnitude),
                                     int(offset_magnitude))
                    point = (x + half_length, y + half_length)
                    flat_index = self.getFlatIndex(point)
                    if 0 <= flat_index <= self.size * self.size:
                        self.setVertexHeight(point, average + offset)

            for x in range(0, self.size - 1, half_length):
                for y in range((x + half_length) % length, self.size - 1,
                               length):
                    left = self.getVertexHeight(
                        ((x - half_length + self.size) % self.size, y))
                    right = self.getVertexHeight(
                        ((x + half_length) % self.size, y))
                    top = self.getVertexHeight(
                        (x, (y + half_length + self.size) % self.size))
                    bottom = self.getVertexHeight(
                        (x, (y - half_length) % self.size))
                    average = (left + right + top + bottom) / 4
                    offset = randint(int(-offset_magnitude),
                                     int(offset_magnitude))
                    point = (x, y)
                    flat_index = self.getFlatIndex(point)
                    if 0 <= flat_index <= self.size * self.size:
                        self.setVertexHeight((x, y), average + offset)
            offset_magnitude /= 2.0
            length /= 2
        print "DONE!"
コード例 #2
0
ファイル: GundamWidget.py プロジェクト: cnbdragon/GundamPy
    def _handleInit(self):
        floor = mc.polyPlane(w=600,h=600)
        mc.move(0,-5,0)

        mc.ambientLight()
        mc.pointLight()
        mc.move(600,600,600)
コード例 #3
0
    def _handleBubblesButton(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
        #polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1;
        p = cmd.polyPlane(
            w=100, h=100, sx=10, sy=10, ax=y, cuv=3, ch=1,n='HotPlate')[0]
        cmd.select(p)
        cmd.move(0,2,0,r=True)
        cmd.setKeyframe()
        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()
        '''
        randBubbleCount = rand.choice(range(10,300)) #this should be set in the interface
        for i in range(0,100,1):
            randX = rand.choice(range(-50,50,1))
            randZ = rand.choice(range(-50,50,1))

            r = 2
            a = 2.0*r
            yUp = (0, 1, 0) # y up
            b = cmds.polySphere(
                r=r, sx=10, sy=10, ax=yUp, cuv=2, ch=1, n='Bubble')[0]
            cmds.select(b)


            startTime = rand.choice(range(1, 600, 1))
            cmd.currentTime(1)
            cmd.move(randX, 0, randZ, a=True)
            cmd.setKeyframe()
            for j in range(startTime, 600, 2):
                x = rand.choice(decRange)
                y = 5*rand.choice(decRange2)
                z = rand.choice(decRange)
                cmd.currentTime(j)
                cmd.move(x, y, z, r=True)
                cmd.setKeyframe()
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
コード例 #4
0
    def _generateTerrain(self):
        cmds.polyPlane(n='terrain', sx=self.size-1, sy=self.size-1, w=self.size, h=self.size)
        shapes = cmds.ls("terrain", sl=True, fl=True)
        self.terrain = shapes[0]

        offset_magnitude = int(self.magnitude)
        self.setVertexHeight((0, 0), randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((self.size - 1, 0), randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((0, self.size - 1), randint(-offset_magnitude, offset_magnitude))
        self.setVertexHeight((self.size - 1, self.size - 1), randint(-offset_magnitude, offset_magnitude))

        length = self.size - 1
        while length >= 1:
            half_length = length / 2
            for x in range(0, self.size - 1, length):
                for y in range(0, self.size - 1, length):
                    bottom_left = self.getVertexHeight((x, y))
                    bottom_right = self.getVertexHeight((x + length, y))
                    top_left = self.getVertexHeight((x, y + length))
                    top_right = self.getVertexHeight((x + length, y + length))
                    average = (top_left + top_right + bottom_left + bottom_right) / 4.0
                    offset = randint(int(-offset_magnitude), int(offset_magnitude))
                    point = (x + half_length, y + half_length)
                    flat_index = self.getFlatIndex(point)
                    if 0 <= flat_index <= self.size * self.size:
                        self.setVertexHeight(point, average + offset)

            for x in range(0, self.size - 1, half_length):
                for y in range((x + half_length) % length, self.size-1, length):
                    left = self.getVertexHeight(((x - half_length + self.size) % self.size, y))
                    right = self.getVertexHeight(((x + half_length) % self.size, y))
                    top = self.getVertexHeight((x, (y + half_length + self.size) % self.size))
                    bottom = self.getVertexHeight((x, (y - half_length) % self.size))
                    average = (left + right + top + bottom) / 4
                    offset = randint(int(-offset_magnitude), int(offset_magnitude))
                    point = (x, y)
                    flat_index = self.getFlatIndex(point)
                    if 0 <= flat_index <= self.size * self.size:
                        self.setVertexHeight((x, y), average + offset)
            offset_magnitude /= 2.0
            length /= 2
        print "DONE!"
コード例 #5
0
ファイル: GaitVisualizer.py プロジェクト: JenLM/Cadence
    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)
コード例 #6
0
 def _handleScene(self):
     cmds.polyPlane(w=25, h=25)
     self.createLight('spotlight1', [3.5, 6, 3.5], [-120, -180, -45])
     self.createLight('spotlight2', [-3.5, 6, 3.5], [-120, -180, 45])
     self.createLight('spotlight3', [3.5, 6, -3.5], [-120, 0, -45])
     self.createLight('spotlight4', [-3.5, 6, -3.5], [-120, 0, 45])
コード例 #7
0
def simulate(numFlockers, numFrames, alignmentWeight, cohesionWeight,
             separationWeight, speed, distance, in3D):

    # Create the flock
    flock = Flock(alignmentWeight, cohesionWeight, separationWeight, speed,
                  distance)

    cmds.shadingNode('phong', asShader=True, name='Redwax')
    cmds.select('Redwax')
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='RedwaxSG')
    cmds.connectAttr('Redwax.outColor', 'RedwaxSG.surfaceShader', f=True)
    cmds.setAttr('Redwax.color', 1, 0, 0, type='double3')
    cmds.setAttr('Redwax.cosinePower', 5)
    cmds.setAttr('Redwax.reflectivity', 0)
    cmds.setAttr('Redwax.specularColor', 1, 1, 1, type='double3')

    cmds.shadingNode('blinn', asShader=True, name='Plastic')
    cmds.select('Plastic')
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='PlasticSG')
    cmds.connectAttr('Plastic.outColor', 'PlasticSG.surfaceShader', f=True)
    cmds.setAttr('Plastic.color', 0.9, 0.9, 0.9, type='double3')
    cmds.setAttr('Plastic.eccentricity', 0.55)
    cmds.setAttr('Plastic.specularRollOff', 1)
    cmds.setAttr('Plastic.diffuse', 0.9)

    cmds.directionalLight(rotation=(-90, 0, 0))

    cmds.polyPlane(name='base')
    cmds.setAttr('base.scaleX', 25)
    cmds.setAttr('base.scaleZ', 25)
    cmds.setAttr('base.translateY', -15)
    cmds.select('base')
    cmds.sets(e=True, forceElement='PlasticSG')

    for i in range(numFlockers):
        xVel = random.randint(-9, 9)
        yVel = random.randint(-9, 9)
        zVel = random.randint(-9, 9)
        xPos = random.randint(-100, 100)
        yPos = random.randint(-100, 100)
        zPos = random.randint(-100, 100)
        fname = 'f' + str(i)
        if (in3D):
            flock.addFlocker(xVel, yVel, zVel, xPos, yPos, zPos, fname)
        else:
            flock.addFlocker(xVel, 0, zVel, xPos, 0, zPos, fname)

        cmds.polySphere(name=fname, radius=0.2)
        cmds.select(fname)
        cmds.sets(e=True, forceElement='RedwaxSG')

    # Initialize time
    time = 0
    endTime = numFrames
    cmds.currentTime(time)

    # Initialize flock member positions
    for flocker in flock.flockers:
        cmds.select(flocker.name)
        cmds.move(flocker.xPos, flocker.yPos, flocker.zPos)
        cmds.setKeyframe(flocker.name)

    while time < endTime:

        time += 12

        for flocker in flock.flockers:
            flocker.updateVelocity(flock)

        for flocker in flock.flockers:
            flocker.updatePostion()

        cmds.currentTime(time)
        for flocker in flock.flockers:
            fx = flocker.name + '.translateX'
            fy = flocker.name + '.translateY'
            fz = flocker.name + '.translateZ'
            cmds.setAttr(fx, flocker.xPos)
            cmds.setAttr(fy, flocker.yPos)
            cmds.setAttr(fz, flocker.zPos)
            cmds.setKeyframe(flocker.name)
コード例 #8
0
import nimble
import random as rand
import numpy as np
from nimble import cmds
from nimble import cmds as cmd
decRange = np.arange(-1, 1, .1)
decRange2 = np.arange(0, 1, .1)
r = 2
a = 2.0 * r
y = (0, 1, 0)  # y up
#polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1;
p = cmd.polyPlane(w=100, h=100, sx=10, sy=10, ax=y, cuv=3, ch=1,
                  n='HotPlate')[0]
cmd.select(p)
cmd.move(0, 2, 0, r=True)
cmd.setKeyframe()
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()
'''
randBubbleCount = rand.choice(range(10, 1000))
for i in range(0, 100, 1):