Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. import maya.cmds as cmds
  2. import random
  3.  
  4. class CloudGenerator(object):
  5.    
  6.     def __init__(self):
  7.         print "objeto creado"
  8.        
  9.  
  10.     def Make_Clouds(self,numero):
  11.         #creamos Locator y grupo
  12.         locator = cmds.spaceLocator(name="Locator_Nubes")
  13.         grupo = cmds.group(em=True, name="Nubes")
  14.        
  15.         for i in xrange(numero):
  16.             #creamos esfera
  17.             ph = cmds.polySphere(r = .2, sa = 20, sh = 20, n = "Cloud001")[0]
  18.             #Cambiamos posicion
  19.             xValue = random.randrange(0, 5)
  20.             yValue = random.randrange(0, 5)
  21.             zValue = random.randrange(0, 5)
  22.             cmds.setAttr(ph +".translate", xValue, yValue, zValue, type="double3")
  23.             #cambiamos rotacion
  24.             xRotation = random.randrange(0, 360)
  25.             yRotation = random.randrange(0, 360)
  26.             zRotation = random.randrange(0, 360)
  27.             cmds.rotate(xRotation,yRotation,zRotation,ph)
  28.             #cambiamos tamaƱo
  29.             xSize = random.randrange(1,5)
  30.             ySize = random.randrange(1,5)
  31.             zSize = random.randrange(1,5)
  32.             cmds.scale(xSize,ySize,zSize,ph)
  33.             #ubicamos el locator con el ultim objeto creado
  34.             cmds.delete(cmds.parentConstraint(ph,locator,w=1,mo=0))
  35.             #metemos el objeto al grupo
  36.             cmds.parent(ph,grupo)
  37.         #ponemos constraint al grupo con el locator
  38.         cmds.parentConstraint(locator, grupo,w = 1, mo=0)
  39.        
  40.     def Replace_clouds(self):
  41.         print "ya"
  42.    
  43. test = CloudGenerator()
  44. test.Make_Clouds(5)
  45. test.Replace_clouds()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement