-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ztools_MultiMatteElement_Assistant_v1_0.mcr
250 lines (207 loc) · 4.68 KB
/
Ztools_MultiMatteElement_Assistant_v1_0.mcr
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
macroScript MultiMatteElement_Assistant
category:"Ztools"
toolTip:"MultiMatteElement_Assistant"
buttontext:"MultiMatteElement_Assistant"
Icon:#("ZMA", 1)
(
-- Ztool - Vray MultiMatteElement Assistant for 3ds Max
--Created by Jose Alejandro Enriquez
-- version 1.0
-- 26 / 01 / 2015
--seleccionar objetos por nombre
listName = ""
elements = #()
allObj = #()
autoselect = $*
elementName="Matte_"
listenerInfoChecker = 0
rule = ""
removeElements = 0
print elements.count
--add items to the allobj array if the pass the filter
fn filterElement =
(
for i in autoselect do
(
y = i.name
x = findString y rule
w = findString i.name "Target"
if x != undefined and superclassof i == GeometryClass and w == undefined then
(
append allObj i
)
else if superclassof i == GeometryClass then
(
if listenerInfoChecker == 1 then
(
errorMessage = "Sorry, the item doesn't match the requirements: " + y
print errorMessage
)
)
else
(
--errorMessage = "Item is not GeometryClass: " + y + ", Ignored"
--print errorMessage
--print i.name as string
)
)
)
--Crea el pase de acuerdo a elementName generado en nameCreation()
fn elementCreation elementName =
(
re = maxOps.GetCurRenderElementMgr()
pass = MultiMatteElement
adpElementName = replace elementName (elementName.count) 1 ""
re.addrenderelement (MultiMatteElement elementname:adpElementName)
)
--Filtra y crea una lista de acuerdo al nombre
fn executeClassification =
(
for i in allObj do
(
global listName, elements
objName = i.name
SplitName = filterstring objName rule
listName = SplitName[1]
appendIfUnique elements listName
indexObj = findItem elements listName
i.gbufferchannel = indexObj
)
)
--Crea nombres de pases, y agrega ID a los render elements
fn nameCreation elements =
(
elementName = "Matte_"
bufferCount = 0
elementCount = 1
elements.count
idAsigned = 0
for i in elements do
(
i as string
elementName += i + "_"
bufferCount += 1
secondVal = bufferCount - 2
if mod bufferCount 3 == 0 then
(
elementCreation(elementName)
re=maxOps.GetCurRenderElementMgr()
x = re.numrenderelements()
w = x - 1
k = re.GetRenderElement w
elementCount += 1
k.R_gbufID = bufferCount - 2
k.G_gbufID = bufferCount - 1
k.B_gbufID = bufferCount
idAsigned += 3
elementName = "Matte_"
)
else if mod secondVal 3 == 0 and elements.count - idAsigned == 2 then
(
x = elements.count - idAsigned
y = x as string + " este es"
print y
elementCreation(elementName)
re=maxOps.GetCurRenderElementMgr()
x = re.numrenderelements()
w = x - 1
k = re.GetRenderElement w
print k as string
elementCount += 1
k.R_gbufID = bufferCount - 1
k.G_gbufID = bufferCount
k.B_gbufID = 0
k.B_gbufIDOn = False
)
else if elements.count - idAsigned == 1 then
(
elementCreation(elementName)
re=maxOps.GetCurRenderElementMgr()
x = re.numrenderelements()
w = x - 1
k = re.GetRenderElement w
elementCount += 1
k.R_gbufID = bufferCount
k.G_gbufID = 0
k.G_gbufIDOn = False
k.B_gbufID = 0
k.B_gbufIDOn = False
)
else
(
)
)
)
rollout MME "Ztool - Vray MultiMatteElement Assistant " width: 300 height:120
(
global listenerInfoChecker, removeElements
checkbox listenerInfo "Print Log to MaxScript Listener" checked:False
on listenerInfo changed state do
if state == True then
(
listenerInfoChecker = 1
)
else
(
listenerInfoChecker = 0
)
checkbox deleteOld "Delete current Render Elements (All of them)"
on deleteOld changed state do
if state == True then
(
removeElements = 1
)
else
(
removeElements = 0
)
group "By Name"
(
edittext ruleBox "Name's rule(ex: - . _)" fieldwidth:50 labelOnTop: False
on ruleBox entered txt do
(
if txt != "" then
(
global rule
rule = txt as string
)
else
(
messagebox = "Missing Rule"
)
)
button btn1 "Execute" width: 100 height:25
)
on btn1 pressed do
(
if rule == ""then
(
messagebox "Missing Rule"
)
else
(
if removeElements == 1 then
(
re=maxOps.GetCurRenderElementMgr()
re.RemoveAllRenderElements()
)
else
(
)
filterElement()
executeClassification()
nameCreation(elements)
DestroyDialog MME
if renderSceneDialog.isOpen() then
(
renderSceneDialog.close()
renderSceneDialog.open()
)
else
(
)
)
)
)
createDialog MME
)