-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mesh.py
85 lines (77 loc) · 3.39 KB
/
Mesh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Mesh.py
import maya.cmds as cmds
import math
from config import *
class Mesh():
def createNails(self):
x = -10
z = -10
for i in range(441):
height = 2
cmds.polyCylinder(n='nailt' + str(i), h=height, r=0.1, sz=1, sy=10)
cmds.move(0, 1, 0)
cmds.polyCylinder(n='nailb' + str(i), h=0.02, r=0.2)
cmds.polyCone(n='nailp' + str(i), h=0.5, r=0.1, sy=5)
cmds.move(0, 2.25, 0)
nail = 'nail' + str(i)
cmds.polyUnite('nailt' + str(i), 'nailb' + str(i), 'nailp' + str(i), n=nail)
cmds.move(x, 0, z)
cmds.nonLinear(type='bend', curvature=0.0, lowBound=0, highBound=2)
cmds.move(x, 0, z)
x += 1
if x == 11:
x = -10
z += 1
def deleteKeys(self):
for i in range(441):
cmds.cutKey('bend' + str(i + 1), time=(0, 200), at='curvature', option="keys")
def simpleBend(self):
self.deleteKeys()
for i in range(441):
name = 'bend' + str(i + 1)
cmds.setKeyframe(name, at='curvature', time=0, v=0)
cmds.setKeyframe(name, at='curvature', time=100, v=60)
cmds.setKeyframe(name, at='curvature', time=200, v=0)
def uniformWave(self):
self.deleteKeys()
for i in range(441):
name = 'bend' + str(i + 1)
cmds.setKeyframe(name, at='curvature', time=0, v=-60)
cmds.setKeyframe(name, at='curvature', time=100, v=60)
cmds.setKeyframe(name, at='curvature', time=200, v=-60)
def sineWave(self):
self.deleteKeys()
for row in range(21):
for col in range(21):
name = 'bend' + str((21 * col) + (row + 1))
v1t2 = (math.sin(row) + 1) * 30
t2 = 100 * ((60 - v1t2) / 60)
cmds.setKeyframe(name, at='curvature', time=0, v=v1t2)
cmds.setKeyframe(name, at='curvature', time=t2, v=60)
cmds.setKeyframe(name, at='curvature', time=(t2 + 100), v=0)
cmds.setKeyframe(name, at='curvature', time=200, v=v1t2)
cmds.keyTangent(name, itt='linear', ott='linear', t=(0, 200))
def simpleWave(self):
self.deleteKeys()
for row in range(21):
for col in range(21):
name = 'bend' + str((21 * col) + (row + 1))
cmds.setKeyframe(name, at='curvature', time=0, v=0)
cmds.setKeyframe(name, at='curvature', time=(row * 2), v=60)
cmds.setKeyframe(name, at='curvature', time=(row * 2) + 40, v=0)
cmds.setKeyframe(name, at='curvature', time=(row * 2) + 80, v=60)
cmds.setKeyframe(name, at='curvature', time=(row * 2) + 120, v=0)
cmds.setKeyframe(name, at='curvature', time=(row * 2) + 160, v=60)
def assignPewter(self):
shadingNode = cmds.shadingNode('blinn', asShader=True, name='blinnNew')
# find good values for the color:
cmds.setAttr(
shadingNode + '.color', 0.2, 0.2, 0.2, type="double3")
# find good values for the specular color:
cmds.setAttr(
shadingNode + '.specularColor', 100.0, 100.0, 100.0, type="double3")
for i in range(441):
name = 'nail' + str(i)
cmds.select(name)
cmds.hyperShade(assign=shadingNode)
cmds.select(clear=True)