Monday, June 15, 2009

week05_assignment_Masha















import maya.cmds as cmds
import random
import math
from random import *
from math import *


def Curve(numPoints):
#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = randint(0,3)
amp = randint(0,3)
#function for the spiral curve
a=i*0.3
x = cos(a)*amplitude
y = 0

z =-i
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

def Curve2(numPoints):
#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = randint(0,3)
amp = randint(0,3)
#function for the spiral curve
a = i*0.3
x = sin(a)*amplitude
y = i
z = amp*4
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

def tubulize (path, radius, tubeSections = 8):
"Function to create tubes out of curve"
#position on end of curve where i will put the circle profile
pos = cmds.pointOnCurve (path, position = 1, pr = 0.001, top = 1)
#get tangent of this point
tan = cmds.pointOnCurve (path, tangent = 1, pr = 0.001, top = 1)

#create the profile circle
profile = cmds.circle (c=pos, r = radius, normal = tan, s= tubeSections, ch = 1)
#center of circle pivot
cmds.xform (cp = 1)
#extrude the circle along path
tube =cmds.extrude (profile [0], path, ucp =1, upn=1,et=1,rb=1,dl=3,ch=1, n ="spiralTube" )
#returne values
return [tube[0],radius,profile]

radius = 6
numCurves = 200
myCrv = []
y1 = 0
angle = 360/numCurves
x1 = radius
z1 = 10

for i in range (0, numCurves+1, 1):
rad = randint(3,8)
r = rad/10.0

if i%2 == 0:
curve1 = Curve(50)

else:
curve1 = Curve2(50)

#cmds.move (0,0,10, curve1)
#cmds.rotate( 0, 0, 90, curve1, pivot=(0,0,0))
#curve1= Curve(30)
cmds.rotate( 0, 0, angle*i+i,curve1, pivot=(x1,y1,z1))
crv1 = tubulize (curve1, r, tubeSections = 8)
#cmds.move (j,j,0, curve1)
myCrv.append (curve1)

No comments:

Post a Comment