1/******************************************************************************
2	NintendoWare for CTR Maya Plugin
3
4	File:         NW4C_SetMaterialAttr.mel
5	Description:  set material attribute
6	Date:         2010/02/12
7	Author:       Takashi Endo
8
9	Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved.
10******************************************************************************/
11
12// UpdateWindow DoSearch
13// FaceCulling FragLighting VtxLighting NoCompress
14
15/******************************************************************************
16	get selected SG
17
18		return SG size
19******************************************************************************/
20proc int GetSelectedSG(string $sgs[])
21{
22	$sgs = `ls -sl -typ shadingEngine`;
23	if (size($sgs) == 0)
24	{
25		// get SG from selected material
26		string $mats[] = `ls -sl -mat`;
27		for ($mat in $mats)
28		{
29			if (!`attributeQuery -n $mat -ex "oc"`)
30			{
31				continue;
32			}
33			string $connectedSgs[] =
34				`listConnections -s 0 -d 1 -type shadingEngine ($mat + ".oc")`;
35			for ($sg in $connectedSgs)
36			{
37				if ($sg != "initialParticleSE" &&
38					$sg != "swatchShadingGroup")
39				{
40					$sgs[size($sgs)] = $sg;
41				}
42			}
43		}
44	}
45	return size($sgs);
46}
47
48/******************************************************************************
49	Face Culling
50******************************************************************************/
51proc int ConvertFaceCulling_ToGUI(int $val)
52{
53    // �A�g���r���[�g�l���� GUI �̃C���f�b�N�X�ɕϊ�����
54    //             Attr     GUI
55    // Front Face   0  ����  1
56    // Back Face    1  ����  0
57    // Always       2  ����  3
58    // Never        3  ����  2
59    int $faceExchangTable[4] = { 1, 0, 3, 2 };
60    return $faceExchangTable[$val];
61}
62
63proc int ConvertFaceCulling_ToAttr(int $val)
64{
65    // GUI �̃C���f�b�N�X����A�g���r���[�g�l�ɕϊ�����
66    //             GUI      Attr
67    // Back Face    0  ����  1
68    // Front Face   1  ����  0
69    // Never        2  ����  3
70    // Always       3  ����  2
71    int $faceExchangTable[4] = { 1, 0, 3, 2 };
72    return $faceExchangTable[$val];
73}
74
75global proc int nw4cSetMaterialAttr_Get_FaceCulling(string $node)
76{
77	return (`attributeQuery -n $node -ex "nw4cFaceCulling"`) ?
78                        `getAttr ($node + ".nw4cFaceCulling")` : 1;
79}
80
81global proc nw4cSetMaterialAttr_Add_FaceCulling(string $node)
82{
83	if (!`attributeQuery -n $node -ex "nw4cFaceCulling"`)
84	{
85		addAttr -ln "nw4cFaceCulling" -at "enum"
86		    -en "Front Face=0:Back Face=1:Always=2:Never=3" -dv 1 -h 1 $node;
87	}
88}
89
90global proc nw4cSetMaterialAttr_Set_FaceCulling(string $node, int $val)
91{
92	nw4cSetMaterialAttr_Add_FaceCulling($node);
93	setAttr ($node + ".nw4cFaceCulling") $val;
94}
95
96proc SetJob_FaceCulling(string $node)
97{
98	if (!`attributeQuery -n $node -ex "nw4cFaceCulling"`)
99	{
100		return;
101	}
102	scriptJob -p nw4cSetMaterialAttr_FaceCulling -rp -ac ($node + ".nw4cFaceCulling")
103		("optionMenuGrp -e -sl (ConvertFaceCulling_ToGUI(`nw4cSetMaterialAttr_Get_FaceCulling "
104			+ $node + "` + 1)) nw4cSetMaterialAttr_FaceCulling");
105}
106
107global proc nw4cSetMaterialAttr_FaceCullingCB(string $mainNode)
108{
109	string $sgs[];
110	GetSelectedSG($sgs);
111
112	int $val = `optionMenuGrp -q -sl nw4cSetMaterialAttr_FaceCulling` - 1;
113	for ($node in $sgs)
114	{
115		nw4cSetMaterialAttr_Set_FaceCulling($node, ConvertFaceCulling_ToAttr($val));
116	}
117
118	SetJob_FaceCulling($mainNode);
119}
120
121/******************************************************************************
122	fragment lighting
123******************************************************************************/
124global proc int nw4cSetMaterialAttr_Get_FragLighting(string $node)
125{
126	return (`attributeQuery -n $node -ex "nw4cFragLighting"`) ?
127		`getAttr ($node + ".nw4cFragLighting")` : 1;
128}
129
130global proc nw4cSetMaterialAttr_Add_FragLighting(string $node)
131{
132	if (!`attributeQuery -n $node -ex "nw4cFragLighting"`)
133	{
134		addAttr -ln "nw4cFragLighting" -at "bool" -dv 1 -h 1 $node;
135	}
136}
137
138global proc nw4cSetMaterialAttr_Set_FragLighting(string $node, int $val)
139{
140	nw4cSetMaterialAttr_Add_FragLighting($node);
141	setAttr ($node + ".nw4cFragLighting") $val;
142}
143
144proc SetJob_FragLighting(string $node)
145{
146	if (!`attributeQuery -n $node -ex "nw4cFragLighting"`)
147	{
148		return;
149	}
150	scriptJob -p nw4cSetMaterialAttr_FragLighting -rp -ac ($node + ".nw4cFragLighting")
151		("checkBoxGrp -e -v1 `nw4cSetMaterialAttr_Get_FragLighting "
152			+ $node + "` nw4cSetMaterialAttr_FragLighting");
153}
154
155global proc nw4cSetMaterialAttr_FragLightingCB(string $mainNode, int $val)
156{
157	string $sgs[];
158	GetSelectedSG($sgs);
159
160	for ($node in $sgs)
161	{
162		nw4cSetMaterialAttr_Set_FragLighting($node, $val);
163	}
164
165	SetJob_FragLighting($mainNode);
166}
167
168/******************************************************************************
169	vertex lighting
170******************************************************************************/
171global proc int nw4cSetMaterialAttr_Get_VtxLighting(string $node)
172{
173	return (`attributeQuery -n $node -ex "nw4cVtxLighting"`) ?
174		`getAttr ($node + ".nw4cVtxLighting")` : 0;
175}
176
177global proc nw4cSetMaterialAttr_Add_VtxLighting(string $node)
178{
179	if (!`attributeQuery -n $node -ex "nw4cVtxLighting"`)
180	{
181		addAttr -ln "nw4cVtxLighting" -at "bool" -dv 0 -h 1 $node;
182	}
183}
184
185global proc nw4cSetMaterialAttr_Set_VtxLighting(string $node, int $val)
186{
187	nw4cSetMaterialAttr_Add_VtxLighting($node);
188	setAttr ($node + ".nw4cVtxLighting") $val;
189}
190
191proc SetJob_VtxLighting(string $node)
192{
193	if (!`attributeQuery -n $node -ex "nw4cVtxLighting"`)
194	{
195		return;
196	}
197	scriptJob -p nw4cSetMaterialAttr_VtxLighting -rp -ac ($node + ".nw4cVtxLighting")
198		("checkBoxGrp -e -v1 `nw4cSetMaterialAttr_Get_VtxLighting "
199			+ $node + "` nw4cSetMaterialAttr_VtxLighting");
200}
201
202global proc nw4cSetMaterialAttr_VtxLightingCB(string $mainNode, int $val)
203{
204	string $sgs[];
205	GetSelectedSG($sgs);
206
207	for ($node in $sgs)
208	{
209		nw4cSetMaterialAttr_Set_VtxLighting($node, $val);
210	}
211
212	SetJob_VtxLighting($mainNode);
213}
214
215/******************************************************************************
216	Blend Mode
217******************************************************************************/
218
219global proc int nw4cSetMaterialAttr_Get_BlendMode(string $node)
220{
221	return (`attributeQuery -n $node -ex "nw4cBlendMode"`) ?
222		`getAttr ($node + ".nw4cBlendMode")` : 0;
223}
224
225global proc nw4cSetMaterialAttr_Add_BlendMode(string $node)
226{
227	if (!`attributeQuery -n $node -ex "nw4cBlendMode"`)
228	{
229		addAttr -ln "nw4cBlendMode" -at "enum"
230		    -en "Auto=0:Opaque=1:Alpha Test=2:Translucent=3:Add=4:Sub=5:Multiply=6" -dv 0 -h 1 $node;
231	}
232}
233
234global proc nw4cSetMaterialAttr_Set_BlendMode(string $node, int $val)
235{
236	nw4cSetMaterialAttr_Add_BlendMode($node);
237	setAttr ($node + ".nw4cBlendMode") $val;
238}
239
240proc SetJob_BlendMode(string $node)
241{
242	if (!`attributeQuery -n $node -ex "nw4cBlendMode"`)
243	{
244		return;
245	}
246	scriptJob -p nw4cSetMaterialAttr_BlendMode -rp -ac ($node + ".nw4cBlendMode")
247		("optionMenuGrp -e -sl (`nw4cSetMaterialAttr_Get_BlendMode "
248			+ $node + "` + 1) nw4cSetMaterialAttr_BlendMode");
249}
250
251global proc nw4cSetMaterialAttr_BlendModeCB(string $mainNode)
252{
253	string $sgs[];
254	GetSelectedSG($sgs);
255
256	int $val = `optionMenuGrp -q -sl nw4cSetMaterialAttr_BlendMode` - 1;
257	for ($node in $sgs)
258	{
259		nw4cSetMaterialAttr_Set_BlendMode($node, $val);
260	}
261
262	SetJob_BlendMode($mainNode);
263}
264
265/******************************************************************************
266	no compress
267******************************************************************************/
268global proc int nw4cSetMaterialAttr_Get_NoCompress(string $node)
269{
270	return (`attributeQuery -n $node -ex "nw4cNoCompressMat"`) ?
271		`getAttr ($node + ".nw4cNoCompressMat")` : 0;
272}
273
274global proc nw4cSetMaterialAttr_Add_NoCompress(string $node)
275{
276	if (!`attributeQuery -n $node -ex "nw4cNoCompressMat"`)
277	{
278		addAttr -ln "nw4cNoCompressMat" -at "bool" -dv 0 -h 1 $node;
279	}
280}
281
282global proc nw4cSetMaterialAttr_Set_NoCompress(string $node, int $val)
283{
284	nw4cSetMaterialAttr_Add_NoCompress($node);
285	setAttr ($node + ".nw4cNoCompressMat") $val;
286}
287
288proc SetJob_NoCompress(string $node)
289{
290	if (!`attributeQuery -n $node -ex "nw4cNoCompressMat"`)
291	{
292		return;
293	}
294	scriptJob -p nw4cSetMaterialAttr_NoCompress -rp -ac ($node + ".nw4cNoCompressMat")
295		("optionMenuGrp -e -sl (`nw4cSetMaterialAttr_Get_NoCompress "
296			+ $node + "` + 1) nw4cSetMaterialAttr_NoCompress");
297}
298
299global proc nw4cSetMaterialAttr_NoCompressCB(string $mainNode)
300{
301	string $sgs[];
302	GetSelectedSG($sgs);
303
304	int $val = `optionMenuGrp -q -sl nw4cSetMaterialAttr_NoCompress` - 1;
305	for ($node in $sgs)
306	{
307		nw4cSetMaterialAttr_Set_NoCompress($node, $val);
308	}
309
310	SetJob_NoCompress($mainNode);
311}
312
313/******************************************************************************
314	get SG name with material
315******************************************************************************/
316proc string GetSGNameWithMat(string $sg)
317{
318	string $name = "( " + $sg + " )";
319	string $ins[] = `listConnections -s 1 -d 0 ($sg + ".ss")`;
320	if (size($ins))
321	{
322		$name = $ins[0] + " " + $name;
323	}
324	return $name;
325}
326
327/******************************************************************************
328	update window
329******************************************************************************/
330global proc nw4cSetMaterialAttr_UpdateWindow()
331{
332	//-----------------------------------------------------------------------------
333	// get selection
334	string $sgs[];
335	int $enableFlag = (GetSelectedSG($sgs) > 0);
336
337	//-----------------------------------------------------------------------------
338	// set node name
339	string $nodesName;
340	if ($enableFlag)
341	{
342		$nodesName = GetSGNameWithMat($sgs[0]);
343		int $nodeSize = size($sgs);
344		for ($inode = 1; $inode < $nodeSize; ++$inode)
345		{
346			if ($inode == 3)
347			{
348				$nodesName += ", ... (" + $nodeSize + ")";
349				break;
350			}
351			$nodesName += ",  " + GetSGNameWithMat($sgs[$inode]);
352		}
353	}
354	else
355	{
356		$nodesName = "(None)";
357	}
358	text -e -l $nodesName nw4cSetMaterialAttr_NodeName;
359
360	//-----------------------------------------------------------------------------
361	// set current attr & change command
362	if ($enableFlag)
363	{
364		string $node = $sgs[0];
365
366		int $faceCulling = `nw4cSetMaterialAttr_Get_FaceCulling $node`;
367		optionMenuGrp -e -sl (ConvertFaceCulling_ToGUI($faceCulling) + 1)
368			-cc ("nw4cSetMaterialAttr_FaceCullingCB " + $node)
369			nw4cSetMaterialAttr_FaceCulling;
370
371		checkBoxGrp -e -v1 `nw4cSetMaterialAttr_Get_FragLighting $node`
372			-cc ("nw4cSetMaterialAttr_FragLightingCB " + $node + " #1")
373			nw4cSetMaterialAttr_FragLighting;
374
375		checkBoxGrp -e -v1 `nw4cSetMaterialAttr_Get_VtxLighting $node`
376			-cc ("nw4cSetMaterialAttr_VtxLightingCB " + $node + " #1")
377			nw4cSetMaterialAttr_VtxLighting;
378
379		optionMenuGrp -e -sl (`nw4cSetMaterialAttr_Get_BlendMode $node` + 1)
380			-cc ("nw4cSetMaterialAttr_BlendModeCB " + $node)
381			nw4cSetMaterialAttr_BlendMode;
382
383		optionMenuGrp -e -sl (`nw4cSetMaterialAttr_Get_NoCompress $node` + 1)
384			-cc ("nw4cSetMaterialAttr_NoCompressCB " + $node)
385			nw4cSetMaterialAttr_NoCompress;
386
387		// setAttr �ȂǂŕύX���ꂽ�ꍇ�ɃR���g���[���̒l���X�V���邽��
388		SetJob_FaceCulling($node);
389		SetJob_FragLighting($node);
390		SetJob_VtxLighting($node);
391		SetJob_NoCompress($node);
392	}
393
394	//-----------------------------------------------------------------------------
395	// set enable state
396	control -e -en $enableFlag nw4cSetMaterialAttr_FaceCulling;
397	control -e -en $enableFlag nw4cSetMaterialAttr_FragLighting;
398	control -e -en $enableFlag nw4cSetMaterialAttr_VtxLighting;
399	control -e -en $enableFlag nw4cSetMaterialAttr_BlendMode;
400	control -e -en $enableFlag nw4cSetMaterialAttr_NoCompress;
401}
402
403/******************************************************************************
404	search check CB
405******************************************************************************/
406global proc nw4cSetMaterialAttr_SearchCheckCB()
407{
408	control -e -en
409		(`checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchFaceCulling` ||
410		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchFaceCulling` ||
411		 `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchFaceCulling` ||
412		 `checkBoxGrp -q -v4 nw4cSetMaterialAttr_SearchFaceCulling` ||
413		 `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchFragLighting` ||
414		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchFragLighting` ||
415		 `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchVtxLighting`  ||
416		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchVtxLighting`  ||
417		 `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchBlendMode1` ||
418		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchBlendMode1` ||
419		 `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchBlendMode1` ||
420		 `checkBoxGrp -q -v4 nw4cSetMaterialAttr_SearchBlendMode1` ||
421		 `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchBlendMode2` ||
422		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchBlendMode2` ||
423		 `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchBlendMode2` ||
424		 `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchNoCompress`   ||
425		 `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchNoCompress`)
426		nw4cSetMaterialAttr_SearchBtn;
427}
428
429/******************************************************************************
430	do search
431******************************************************************************/
432global proc nw4cSetMaterialAttr_DoSearch()
433{
434	int $searchFaceCull1 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchFaceCulling` ?
435		0 : -1; // Front Face
436	int $searchFaceCull2 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchFaceCulling` ?
437		1 : -1; // BackFace
438	int $searchFaceCull3 = `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchFaceCulling` ?
439		2 : -1; // Always
440	int $searchFaceCull4 = `checkBoxGrp -q -v4 nw4cSetMaterialAttr_SearchFaceCulling` ?
441		3 : -1; // Never
442
443	int $searchFragLit1 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchFragLighting` ?
444		0 : -1; // off
445	int $searchFragLit2 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchFragLighting` ?
446		1 : -1; // on
447
448	int $searchVtxLit1 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchVtxLighting` ?
449		0 : -1; // off
450	int $searchVtxLit2 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchVtxLighting` ?
451		1 : -1; // on
452
453	int $searchBlendMode1 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchBlendMode1` ?
454		0 : -1; // Auto
455	int $searchBlendMode2 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchBlendMode1` ?
456		1 : -1; // Opaque
457	int $searchBlendMode3 = `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchBlendMode1` ?
458		2 : -1; // Alpha Test
459	int $searchBlendMode4 = `checkBoxGrp -q -v4 nw4cSetMaterialAttr_SearchBlendMode1` ?
460		3 : -1; // Translucent
461	int $searchBlendMode5 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchBlendMode2` ?
462		4 : -1; // Add
463	int $searchBlendMode6 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchBlendMode2` ?
464		5 : -1; // Sub
465	int $searchBlendMode7 = `checkBoxGrp -q -v3 nw4cSetMaterialAttr_SearchBlendMode2` ?
466		6 : -1; // Multiply
467
468	int $searchNoCompress1 = `checkBoxGrp -q -v1 nw4cSetMaterialAttr_SearchNoCompress` ?
469		0 : -1; // compress
470	int $searchNoCompress2 = `checkBoxGrp -q -v2 nw4cSetMaterialAttr_SearchNoCompress` ?
471		1 : -1; // no compress
472
473	int $andFlag = (`radioButtonGrp -q -sl nw4cSetMaterialAttr_SearchLogic` == 1);
474
475	int $nodeCount = 0;
476	select -cl;
477	string $sgs[] = `ls -typ shadingEngine`;
478	for ($node in $sgs)
479	{
480		if ($node == "initialParticleSE" || $node == "swatchShadingGroup")
481		{
482			continue;
483		}
484
485		int $faceCull = ConvertFaceCulling_ToGUI(nw4cSetMaterialAttr_Get_FaceCulling($node));
486		int $faceCullMatch =
487			$faceCull == $searchFaceCull1 ||
488			$faceCull == $searchFaceCull2 ||
489			$faceCull == $searchFaceCull3 ||
490			$faceCull == $searchFaceCull4 ||
491			($andFlag && $searchFaceCull1 == -1 && $searchFaceCull2 == -1 &&
492			 $searchFaceCull3 == -1 && $searchFaceCull4 == -1);
493
494		int $fragLit = nw4cSetMaterialAttr_Get_FragLighting($node);
495		int $fragLitMatch =
496			$fragLit == $searchFragLit1 ||
497			$fragLit == $searchFragLit2 ||
498			($andFlag && $searchFragLit1 == -1 && $searchFragLit2 == -1);
499
500		int $vtxLit = nw4cSetMaterialAttr_Get_VtxLighting($node);
501		int $vtxLitMatch =
502			$vtxLit == $searchVtxLit1 ||
503			$vtxLit == $searchVtxLit2 ||
504			($andFlag && $searchVtxLit1 == -1 && $searchVtxLit2 == -1);
505
506		int $blendMode = nw4cSetMaterialAttr_Get_BlendMode($node);
507		int $blendModeMatch =
508			$blendMode == $searchBlendMode1 ||
509			$blendMode == $searchBlendMode2 ||
510			$blendMode == $searchBlendMode3 ||
511			$blendMode == $searchBlendMode4 ||
512			$blendMode == $searchBlendMode5 ||
513			$blendMode == $searchBlendMode6 ||
514			$blendMode == $searchBlendMode7 ||
515			($andFlag && $searchBlendMode1 == -1 && $searchBlendMode2 == -1 &&
516			 $searchBlendMode3 == -1 && $searchBlendMode4 == -1 &&
517			 $searchBlendMode5 == -1 && $searchBlendMode6 == -1 &&
518			 $searchBlendMode7 == -1);
519
520		int $noCompress = nw4cSetMaterialAttr_Get_NoCompress($node);
521		int $noCompressMatch =
522			$noCompress == $searchNoCompress1 ||
523			$noCompress == $searchNoCompress2 ||
524			($andFlag && $searchNoCompress1 == -1 && $searchNoCompress2 == -1);
525
526		int $match = ($andFlag) ?
527			($faceCullMatch && $fragLitMatch && $vtxLitMatch && $blendModeMatch && $noCompressMatch):
528			($faceCullMatch || $fragLitMatch || $vtxLitMatch || $blendModeMatch || $noCompressMatch);
529		if ($match)
530		{
531			select -add -ne $node; // shadingEngine
532			string $ins[] = `listConnections -s 1 -d 0 ($node + ".ss")`;
533			if (size($ins))
534			{
535				select -add $ins[0]; // material
536			}
537			select -add $node; // shape or face
538			++$nodeCount;
539		}
540	}
541
542	if ($nodeCount == 0)
543	{
544		print "Not found\n";
545	}
546	else
547	{
548		string $msg = "Found: " + $nodeCount + " shadingEngine node";
549		if ($nodeCount >= 2)
550		{
551			$msg += "s";
552		}
553		print ($msg + "\n");
554	}
555}
556
557/******************************************************************************
558	main
559******************************************************************************/
560global proc NW4C_SetMaterialAttr()
561{
562	//-----------------------------------------------------------------------------
563	// create window
564	int $winW = 600;
565	int $winH = 448;
566	if (!`window -ex nw4cSetMaterialAttr_Win`)
567	{
568		window -t "NW4C Set Material Attribute" -wh $winW $winH -mxb 0 -mb 1
569			nw4cSetMaterialAttr_Win;
570		menu -l "Help";
571		menuItem -l ("Help on " + `window -q -t nw4cSetMaterialAttr_Win` + "...")
572			-c "NW4C_ShowHelp \"html/NW4C_SetMaterialAttr.html\" \"\"";
573
574		columnLayout -adj 1 -cat "both" 4 -cal "center" -rs 4;
575
576		//-----------------------------------------------------------------------------
577		// node name
578		frameLayout -l "Selected Material ( Shading Group )" -cll 0 -cl 0 -bv 1 -bs "etchedIn";
579			columnLayout -adj 1 -cal "center" -rs 8;
580
581			text -l "" nw4cSetMaterialAttr_NodeName;
582
583			setParent ..; // columnLayout
584		setParent ..; // formLayout
585
586		//-----------------------------------------------------------------------------
587		// set
588		frameLayout -l "Set" -cll 0 -cl 0 -bv 1 -bs "etchedIn";
589			columnLayout -adj 1 -rs 8;
590
591			rowColumnLayout -nc 4 -cw 1 10 -cw 2 210 -cw 3 140 -cw 4 150;
592				text -l ""; // dummy
593
594				optionMenuGrp -l "Face Culling" -cw 1 70  -cal 1 "right"
595					nw4cSetMaterialAttr_FaceCulling;
596					menuItem -l "Back Face Culling";
597					menuItem -l "Front Face Culling";
598					menuItem -l "Never";
599					menuItem -l "Always Culling";
600
601				checkBoxGrp -ncb 1 -l ""
602					-l1 "Fragment Lighting" -v1 1
603					-cw2 10 130
604					nw4cSetMaterialAttr_FragLighting;
605
606				checkBoxGrp -ncb 1 -l ""
607					-l1 "Vertex Lighting" -v1 0
608					-cw2 10 130
609					nw4cSetMaterialAttr_VtxLighting;
610			setParent ..; // rowColumnLayout
611
612			rowColumnLayout -nc 4 -cw 1 10 -cw 2 210 -cw 3 250 -cw 4 100;
613				text -l ""; // dummy
614
615				optionMenuGrp -l "Blend Mode"
616					-cw 1 70 -rat 1 "both" 4 -cal 1 "right"
617					nw4cSetMaterialAttr_BlendMode;
618					menuItem -l "Auto";
619					menuItem -l "Opaque";
620					menuItem -l "Alpha Test";
621					menuItem -l "Translucent";
622					menuItem -l "Add";
623					menuItem -l "Sub";
624					menuItem -l "Multiply";
625
626				optionMenuGrp -l "Compress"
627					-cw 1 70 -rat 1 "both" 4 -cal 1 "right"
628					nw4cSetMaterialAttr_NoCompress;
629					menuItem -l "Compress if possible";
630					menuItem -l "Don't compress";
631
632				text -l ""; // dummy
633			setParent ..; // rowColumnLayout
634
635			setParent ..; // columnLayout
636		setParent ..; // formLayout
637
638		//-----------------------------------------------------------------------------
639		// search
640		frameLayout -l "Search" -cll 0 -cl 0 -bv 1 -bs "etchedIn";
641			columnLayout -adj 1 -rs 8;
642
643			checkBoxGrp -l "Face Culling" -ncb 4 -cw5 110 120 120 120 120
644				-la4 "Back Face Culling" "Front Face Culling" "Never" "Always Culling"
645				-cc "nw4cSetMaterialAttr_SearchCheckCB"
646				nw4cSetMaterialAttr_SearchFaceCulling;
647
648			checkBoxGrp -l "Fragment Lighting" -ncb 2 -cw3 110 120 120
649				-la2 "Off" "On"
650				-cc "nw4cSetMaterialAttr_SearchCheckCB"
651				nw4cSetMaterialAttr_SearchFragLighting;
652
653			checkBoxGrp -l "Vertex Lighting" -ncb 2 -cw3 110 120 120
654				-la2 "Off" "On"
655				-cc "nw4cSetMaterialAttr_SearchCheckCB"
656				nw4cSetMaterialAttr_SearchVtxLighting;
657
658			checkBoxGrp -l "Blend Mode" -ncb 4 -cw5 110 120 120 120 120
659				-la4 "Auto" "Opaque" "Alpha Test" "Translucent"
660				-cc "nw4cSetMaterialAttr_SearchCheckCB"
661				nw4cSetMaterialAttr_SearchBlendMode1;
662
663			checkBoxGrp -l "          " -ncb 3 -cw4 110 120 120 120
664				-la3 "Add" "Sub" "Multiply"
665				-cc "nw4cSetMaterialAttr_SearchCheckCB"
666				nw4cSetMaterialAttr_SearchBlendMode2;
667
668			checkBoxGrp -l "Compress" -ncb 2 -cw3 110 120 120
669				-la2 "Compress" "No Compress"
670				-cc "nw4cSetMaterialAttr_SearchCheckCB"
671				nw4cSetMaterialAttr_SearchNoCompress;
672
673			rowColumnLayout -nc 2 -cw 1 315 -cw 2 150;
674				radioButtonGrp -l "" -nrb 2 -cw3 202 50 50
675					-rat 2 "both" 0
676					-rat 3 "both" 0
677					-la2 "and" "or" -sl 1
678					nw4cSetMaterialAttr_SearchLogic;
679				button -l "Search"
680					-c "nw4cSetMaterialAttr_DoSearch"
681					nw4cSetMaterialAttr_SearchBtn;
682			setParent ..; // rowColumnLayout
683
684			setParent ..; // columnLayout
685		setParent ..; // formLayout
686
687		//-----------------------------------------------------------------------------
688		// close button
689		string $closeCmd = "deleteUI nw4cSetMaterialAttr_Win";
690		string $form = `formLayout -nd 100`;
691			string $closeBtn = `button -h 26 -l "Close" -c $closeCmd`;
692			formLayout -e
693				-af $closeBtn "top" 0
694				-af $closeBtn "left" 0
695				-af $closeBtn "bottom" 0
696				-af $closeBtn "right" 0
697				$form;
698		setParent ..; // formLayout
699
700		setParent ..; // columnLayout
701
702		setFocus $closeBtn;
703
704		//-----------------------------------------------------------------------------
705		// set selection change job
706		scriptJob -p nw4cSetMaterialAttr_Win
707			-e "SelectionChanged" "nw4cSetMaterialAttr_UpdateWindow";
708	}
709	if (`window -q -w nw4cSetMaterialAttr_Win` < $winW)
710	{
711		window -e -w $winW nw4cSetMaterialAttr_Win;
712	}
713	if (`window -q -h nw4cSetMaterialAttr_Win` < $winH)
714	{
715		window -e -h $winH nw4cSetMaterialAttr_Win;
716	}
717	//window -e -wh $winW $winH nw4cSetMaterialAttr_Win;
718
719	//-----------------------------------------------------------------------------
720	// update window
721	nw4cSetMaterialAttr_UpdateWindow;
722	nw4cSetMaterialAttr_SearchCheckCB;
723
724	//-----------------------------------------------------------------------------
725	// show window
726	showWindow nw4cSetMaterialAttr_Win;
727}
728