OneKeySetMat

	macroScript OneKeySetMat
	category:"HYQ SDTools"
	toolTip:"OneKeySetMat"

(--------------------------------------------------------------------------------
	
	global num=1						--材質名後綴
	global AllMats = scenematerials	--收集場景所有材質
	global MatIndex=1					--導入下一頁材質球 --材質球計數
	
	------------------------------------------------------------------------------------------------------------------------
	
	------------------------------------------------------------------------------------------------------------------------
	--導入下一頁材質球
	fn LoadNextMat =
	(
		AllMatsCount = AllMats.count	--場景材質球數量
		for j=1 to 24 do 
		(
			if AllMatsCount>0 and MatIndex<=AllMatsCount then
			(
				meditMaterials[j]=AllMats[MatIndex]	
				MatIndex = MatIndex+1
			)
			else meditMaterials[j]=Standard()
		
		)
	
	)
	
	------------------------------------------------------------------------------------------------------------------------
	--提取複合貼圖
	
	global GetComtexNum = 0
	global texsavepath = ""	--貼圖存放路徑
	global maxfiname = ""
	--拼接字符串數組
	fn str_join list perm =(
		st = ""	
		for i=1 to list.count do(	
			
			
			st = st + list[i]
			
			if i != list.count then st += perm
				
			)
		print st
		return st
		)
		
	--對判斷這個文件名是否存在
	fn IsTextureExist mapname = (
		
		texturepath = mapname
		
		while doesFileExist texturepath do (
			
			filename = getfilenamefile texturepath		--文件名
			filepath = getFilenamePath texturepath		
			filetype = getFilenameType texturepath		--後綴
			
			filename2 = filterString filename "_"
			int1 = filename2[filename2.count] as Integer
			int1 +=1
			
			GetComtexNum = int1	--更新全局記數GetComtexNum
			
			filename2[filename2.count] = int1 as string
			filename = str_join filename2 "_"
			
			texturepath = filepath + filename + filetype		
			
			)	
			
		return texturepath
		)
	fn GetTextureChannel mat = (
		case  classof mat of (
			Standardmaterial: return mat.diffuseMap
			VRayMtl: return mat.texmap_diffuse
			VRay2SidedMtl: GetTextureChannel mat.frontMtl
			VRayMtlWrapper: GetTextureChannel mat.baseMtl
			VRayOverrideMtl:GetTextureChannel mat.baseMtl
			VRayBlendMtl:GetTextureChannel mat.baseMtl
			Multimaterial: (
				messagebox "不支持的材質類型!"
				return undefined
				
				)
			)
		)

	fn GetComTexture = (
		
		--mfn = maxfiname
		--filepath = maxFilePath	
		filepath = texsavepath
		print filepath
		filename = getFileNameFile maxfiname
		mapname = filepath +"\\"+ filename +"_map_"+ (GetComtexNum as string) + ".jpg"
		mapname = IsTextureExist mapname
		
		
		--rm = renderMap $.material.texmap_diffuse size:[1024,1024] fileName: mapname
		print mapname
		--rm = rendermap meditmaterials[activemeditSlot].texmap_diffuse size:[1024,1024] filename: mapname
		needmap = GetTextureChannel(meditmaterials[activemeditSlot])
		print needmap
		if needmap != undefined then (
			rm = rendermap(needmap) size:[1024,1024] filename: mapname
			save rm
			close rm
			)		
		)
		
	--判斷文件是否存在,如果存在進進行文件名處理

		

	fn main_GetComTex= (
		
		GetComtexNum += 1
		GetComTexture()
		
		)
	------------------------------------------------------------------------------------------------------------------------
		--自定義結構體Mtl
struct HMtl(mtlDiffuse,mtlReflection,mtlRefraction,mtlBump,mtlOpacity)
struct MatColors(diffuse_col,reflection_col,refraction_col,fog_color,light_col)	
	------------------------------------------------------------------------------------------------------------------------
	--去重複
	fn RemoveTheSame List = 
	(
		try
			(
				local  Alist=#()
				
				if List.count>0 then
					(
						for i=1 to List.count do
						(
							local t = 1
							if Alist.count==0 then (append Alist List[i])
							--判斷Alist是否有這個List[i]相同的元素
							else if Alist.count>0 then
							(
								for j=1 to Alist.count do
								(
									if List[i]==Alist[j] then( t=0;exit)	--如果有相同元素則將t設爲0,並退出這次循環
									
								)
								--如果將List[i]和Alist裏的每一個元素對比完了,並沒有發現有相同元素,即t還是等於1,則將這個List[i]添加進Alist數組中
								if t==1 do append Alist List[i]
							)
						)						
					)
				--遍歷完了List裏的元素後返回Alist
				if (Alist.count>0) then  (sort Alist;return Alist)
			)
		catch()
		
	)	
		
	------------------------------------------------------------------------------------------------------------------------
	--通道過濾 --通道迭代找出貼圖路徑	
	--MapChannel 通道名
	--MapList 接受貼圖路徑的數組
	fn Get_MapChannel MapChannel =
	(
		--MapList = #() --清空數組
		--如果這個通道不爲空則進行下面的判斷
		if classof MapChannel != UndefinedClass do
		(
			
			filepath =case classof MapChannel of (
				--1 
				Bitmaptexture: if MapChannel.filename!=undefined then MapChannel.filename	
				--2
				falloff: Get_MapChannel MapChannel.map1
				--3
				Color_Correction: Get_MapChannel MapChannel.map
				--4
				Mask: Get_MapChannel MapChannel.map	
				
				Mix: Get_MapChannel MapChannel.mask	--20190423添加 
				CompositeTexturemap: Get_MapChannel MapChannel.mapList[1]	--20190424 合成材質通道
				VRayNormalMap:Get_MapChannel MapChannel.normal_map	--20192424VrayNormalMap
				VRayHDRI: if MapChannel.HDRIMapName!=undefined and MapChannel.HDRIMapName!= "" then MapChannel.HDRIMapName		--20190605對hdr貼圖的處理
			)
		)
	
	)
------------------------------------------------------------------------------------------------------------------------
--20190417 hyq添加 獲取材質的顏色信息
fn Get_Mat_Color Mat=
(
	local diffuse_col,reflection_col,refraction_col,fog_color,light_col
	case (classof Mat) of
	(
		VRayMtl:(			
			diffuse_col = Mat.diffuse
			reflection_col = Mat.reflection
			refraction_col = Mat.refraction
			fog_color = Mat.refraction_fogColor
			light_col =Mat.diffuse	-- 漫反射顏色作爲發光材質的顏色備用色
			
			)
		VRayLightMtl:(
			print "材質類型爲"
			print (classof Mat)
			----------如果想要獲取顏色的材質爲燈光材質
			--local default_col =(color 0 0 0)	--默認顏色
			
			--diffuse_col = undefined
			--reflection_col = undefined
			--refraction_col = undefined
			--fog_color = undefined
			diffuse_col = Mat.color
			light_col = Mat.color
			
			)
		Standardmaterial:(
			print "材質類型爲"
			print (classof Mat)
			diffuse_col = Mat.diffuse
			reflection_col=Mat.specular
			refraction_col=undefined
			fog_color =  undefined
			light_col =if (Mat.useSelfIllumColor == on) then Mat.selfIllumColor
			)
		--VRayMtlWrapper:Get_Mat_Color Mat.baseMtl	--有BUG,需要修改,提取了兩次,第一次是正確的,第二次就不行了。
		--VRayBlendMtl:Get_Mat_Color Mat.baseMtl	
		--VRay2SidedMtl:Get_Mat_Color Mat.frontMtl
		
		
		default:(
		--print "材質類型爲"
		--print "想要提取顏色的材質暫不支持"
		diffuse_col = undefined
		reflection_col = undefined
		refraction_col = undefined
		fog_color = undefined			
		light_col = undefined
		)
		
			
	)
	print("從原材質提取到的顏色有:")
	print ("diffuse_col:	"+diffuse_col as string)
	print ("reflection_col:	"+reflection_col as string)
	print ("refraction_col:	"+refraction_col as string)
	print ("fog_color:	"+ fog_color as string)
	print ("light_col:	"+light_col as string)
	MatColors_result = MatColors diffuse_col:diffuse_col reflection_col:reflection_col refraction_col:refraction_col fog_color:fog_color light_col:light_col
)
-------------------------------------------------------------------------------------------------------------------------

--201904182211--Set Color
--HMtl 獲取到的原材質球的貼圖信息
--MatColors 獲取到的原材質球的顏色信息
fn Set_Mat_Color HMtl MatColors Mat=
(
	--201904191209,添加判斷是特殊材質,抽取顏色,或者抽取漫反射顏色放到反射通道里
	--加多一個判斷,如果是falloff通道,而通道里以沒有貼圖,則將對應通道取的的顏色放到fallof裏的顏色裏
	--isSetColor = matchpattern Mat.name pattern:"YF_moshajinshu"
	case (classof Mat) of
	(
		VRayMtl:(
			print "目標材質類型爲:"
			print (classof Mat)
			if (HMtl.mtlDiffuse ==undefined AND MatColors.diffuse_col!=undefined)  then  Mat.diffuse = MatColors.diffuse_col
			--判斷,如果原材質沒有漫反射貼圖,目標材質的漫反射是falloff通道,則將原材質的漫反射顏色放到目標材質的漫反射顏色,並且目標材質的漫反射通道falloff的兩個顏色也設置成這個顏色
			if (HMtl.mtlDiffuse ==undefined AND MatColors.diffuse_col!=undefined AND classof Mat.texmap_diffuse==falloff) then 
			(
				--Mat.texmap_diffuse.color1=MatColors.diffuse_col
				--print "falloff Color"
				--print MatColors.diffuse_col as string
				Mat.texmap_diffuse.color1 = MatColors.diffuse_col
				Mat.texmap_diffuse.color2 = Mat.texmap_diffuse.color1
				)
			--if (HMtl.mtlReflection ==undefined AND  MatColors.reflection_col!=undefined AND Mat.reflection !=(Color 0 0 0) ) then  Mat.reflection = MatColors.reflection_col
			--if (HMtl.mtlRefraction ==undefined  AND  MatColors.refraction_col!=undefined AND Mat.refraction !=(Color 0 0 0)) then  Mat.refraction = MatColors.refraction_col
			--if (HMtl.mtlRefraction == undefined AND Mat.refraction !=(Color 0 0 0) )then  Mat.refraction_fogColor = MatColors.fog_color		--如果材質球的折射refraction 的顏色不等於純黑色,則將原始材質的fogcolor顏色抽取過來給目標新材質
			--  Mat.selfIllumination = MatColors.light_col		--標準VRayMtl不用抽取原材質的這個顏色,一切以模版裏的這個顏色的值爲準
		)
		VRayLightMtl:(
			print "材質類型爲"
			print (classof Mat)
			----------如果想要獲取顏色的材質爲燈光材質
			--local default_col =(color 0 0 0)	--默認顏色
			
			--diffuse_col = undefined
			--reflection_col = undefined
			--refraction_col = undefined
			--fog_color = undefined			
			if MatColors.light_col != undefined then Mat.color=MatColors.light_col
			
			)
		Standardmaterial:(
			print "材質類型爲"
			print (classof Mat)
			if (HMtl.mtlDiffuse ==undefined AND MatColors.diffuse_col!=undefined ) then Mat.diffuse = MatColors.diffuse_col
			if (HMtl.mtlDiffuse ==undefined AND MatColors.reflection_col!=undefined ) then Mat.specular =MatColors.reflection_col
			--refraction_col=undefined
			--fog_color =  undefined
			if MatColors.light_col != undefined then Mat.selfIllumColor =MatColors.light_col 
			)
	)
)
------------------------------------------------------------------------------------------------------------------------
	--獲取Mtl的貼圖
fn Get_Map Mtl =
	(	
		if ((superclassof Mtl)!=material) then return Mtl
		matClass= classof Mtl	--獲取選擇物體的材質類型	VR:VRayMtl; 標準:Standardmaterial;	多維子材質:Multimaterial ;混全材質:Blend
		case matClass of
			(
				--1
				VrayMtl:(					
					---漫反射通道
					mtlDiffuse =if Mtl.texmap_diffuse!=undefined then Get_MapChannel Mtl.texmap_diffuse 
					--print mtlDiffuseMap.count
					---凹凸通道			
					mtlBump = if Mtl.texmap_bump!=undefined then Get_MapChannel Mtl.texmap_bump 	
					--print mtlBump.count
					---反射通道
					mtlReflection = if Mtl.texmap_reflection!=undefined then  Get_MapChannel Mtl.texmap_reflection 
					--print mtlReflectionMap.count
					---折射通道
					mtlRefraction = if Mtl.texmap_refraction!=undefined then Get_MapChannel Mtl.texmap_refraction 
					--print mtlRefractionMap.count
					---鏤空通道
					mtlOpacity = if Mtl.texmap_opacity!=undefined then Get_MapChannel Mtl.texmap_opacity 
					--print mtlOpacity.count
					)
					
				-------------------------------------------------	
				Standardmaterial:(print "Standardmaterial:"
					---漫反射通道
					mtlDiffuse =if Mtl.diffuseMap!=undefined then Get_MapChannel Mtl.diffuseMap 
					--print mtlDiffuseMap.count
					---凹凸通道			
					mtlBump = if Mtl.bumpMap!=undefined then Get_MapChannel Mtl.bumpMap
					--print mtlBump.count
					---反射通道
					mtlReflection = if Mtl.reflectionMap!=undefined then  Get_MapChannel Mtl.reflectionMap
					--print mtlReflectionMap.count
					---折射通道
					mtlRefraction = if Mtl.refractionMap!=undefined then Get_MapChannel Mtl.refractionMap
					--print mtlRefractionMap.count
					---鏤空通道
					mtlOpacity = if Mtl.opacityMap!=undefined then Get_MapChannel Mtl.opacityMap
					
					
					)
				-------------------------------------------------
					
				VRayLightMtl:(print "VRayLightMtl:"
					mtlDiffuse =if Mtl.texmap!=undefined then Get_MapChannel Mtl.texmap 
					)
				-------------------------------------------------	
				Multimaterial:(messagebox "這是一個多維子材質,請處理後再給材質!")
				-------------------------------------------------	
				Blend:(messagebox "這是一個混合材質Blend,請處理後再給材質!")
				--VRayMtlWrapper:Get_Map Mtl.baseMtl
				--VRayBlendMtl:Get_Map Mtl.baseMtl
				--VRay2SidedMtl:Get_Map Mtl.frontMtl				
				default: return undefined				
			)
		print "原始材質的貼圖有:"
		print("mtlDiffuse:"+mtlDiffuse as string )
		print("mtlReflection:"+mtlReflection as string)
		print("mtlRefraction:"+mtlRefraction as string)
		print("mtlBump:"+mtlBump as string)
		print("mtlOpacity:"+mtlOpacity as string)
		HMtl2 = HMtl mtlDiffuse:mtlDiffuse mtlReflection:mtlReflection mtlRefraction:mtlRefraction mtlBump:mtlBump mtlOpacity:mtlOpacity		
	)
	
	
	-----------------------------------------------------------------------------------------------------------------------------
	------給通道賦貼圖
	--參數MapChannel	通道名 Mtl.texmap_diffuse 或者Mtl.texmap_refelection
	--filepath:	貼圖路徑
	fn SetMap MapChannel filepath = 
	(
		if filepath !=undefined then 
		(
			case classof MapChannel of
				(
					Bitmaptexture:MapChannel.filename = filepath
					
					falloff:(MapChannel.map1 = Bitmaptexture fileName:""; MapChannel.map2 = Bitmaptexture fileName:""; SetMap MapChannel.map1 filepath;MapChannel.map2=MapChannel.map1 )
					--Mask:
					
				)
		)

	)
	fn diffuseAndBump Mat = (
		if classof Mat ==VRayMtl and classof Mat.texmap_diffuse ==falloff and Mat.texmap_diffuse.map1!= undefined and Mat.texmap_diffuse.map1==Mat.texmap_diffuse.map2 and Mat.texmap_diffuse.map1==Mat.texmap_bump then return 1 
		else (return 0)
		)
	-----------------------------------------------------------------------------------------------------------------------------
	--對材質球的相關通道進行材質設置
	fn SetChannelMap Mat HMtl =
		(
		--print Mat
		--print (classof Mat)
		if Hmtl != OK do (
		local check1 = diffuseAndBump Mat
		case (classof Mat) of
			
			(
				VRayMtl: (
				--1,漫反射
				if (Mat.texmap_diffuse !=undefined ) then SetMap  Mat.texmap_diffuse  HMtl.mtlDiffuse	
				
				--4,凹凸 
				if (Mat.texmap_bump !=undefined and (classof Mat.texmap_bump == Bitmaptexture) and  (Mat.texmap_bump.filename ==undefined or Mat.texmap_bump.filename=="")) then 
					(
					if check1 ==1 then Mat.texmap_bump=Mat.texmap_diffuse.map1
					
					
					else (SetMap  Mat.texmap_bump  HMtl.mtlBump)		--20190423hyq 如果凹凸與diffuse關聯,當發現凹凸通道里有貼圖的時候就進行這一步賦貼圖的操作了
					)
						--5 鏤空
				if Mat.texmap_opacity != undefined  then SetMap  Mat.texmap_opacity  HMtl.mtlOpacity
				)
				Standardmaterial:(print "Standardmaterial:"
				--1,漫反射
				if (Mat.diffuseMap !=undefined ) then SetMap  Mat.diffuseMap  HMtl.mtlDiffuse 
								
				--4,凹凸 
				if Mat.bumpMap !=undefined  and classof Mat.bumpMap == Bitmaptexture and  Mat.bumpMap.filename ==""  then SetMap  Mat.bumpMap  HMtl.mtlBump	--20190423hyq 如果凹凸與diffuse關聯,當發現凹凸通道里有貼圖的時候就進行這一步賦貼圖的操作了
				
				--5 鏤空
				if Mat.opacityMap != undefined  then SetMap  Mat.opacityMap  HMtl.mtlOpacity	
					
				)
				VRayLightMtl:(if (Mat.texmap !=undefined ) then SetMap  Mat.texmap  HMtl.mtlDiffuse )
			)
		
		Mat.ShowInViewPort = true	--在場景中顯示這個材質球的shader效果		
		return Mat	
		)	
		)
	
	
	
	--特殊材質
	--透明玻璃,窗戶透明玻璃,亮光金屬,磨砂金屬

	fn 	SpecialMaterial Mtl_Tar = (
		IsNotSpecMat = false
		if (not matchpattern Mtl_Tar.name pattern:"YF_toumingboli*") and ( not matchpattern Mtl_Tar.name pattern:"YF_chuanghutoumingboli*" )\
		and ( not matchpattern Mtl_Tar.name pattern:"YF_liangguangjinshu*" ) and ( not matchpattern Mtl_Tar.name pattern:"YF_moshajinshu*" )\
		then IsNotSpecMat = true
		
		return IsNotSpecMat
		
		)

	--轉換程序A--一切參數以材質庫參數爲準,只抽取原材質球的貼圖放到相應的的位置	
	--傳入參數:原始材質,目標材質
	fn MatA_To_MatB Mtl_Org Mtl_Tar = (

		if Mtl_Org != OK do (
			--如果MatA與MatB不是材質類型則返回
			if (superclassof Mtl_Org)!=material and (superclassof Mtl_Tar)!=material then return #(Mtl_Org,Mtl_Tar)
				
			--MatOrg_params =if Mtl_Org!=undefined then getPropNames(classof Mtl_Org)	--原始材質球的屬性
			--MatTar_params = if Mtl_Tar !=undefined then getPropNames(classof Mtl_Tar)	--目標材質球的屬性
			
			orgi_Maps = Get_Map Mtl_Org		--getmaps 提取原始材質的貼圖信息
		
			--對目標材質Mtl_Tar的通道進行賦材質操作
			Mtl_Tar2 = copy Mtl_Tar		
			Mtl_Tar2 = SetChannelMap Mtl_Tar orgi_Maps		--對Mtl_Tar進行貼圖賦值
			
				
			--獲取Mtl_Org的顏色信息
			--如果是透明玻璃,窗戶透明玻璃,亮光金屬,磨砂金屬,則使用模板裏的顏色,不從原始材質裏獲取顏色
			if (SpecialMaterial Mtl_Tar2 ) do (
				Set_Mat_Color orgi_Maps (Get_Mat_Color Mtl_Org) Mtl_Tar2 	--對Mtl_Tar進行顏色賦值
			)
			--對目標材質進行必要的顏色設置
			if Mtl_Tar2==undefined then return messagebox "未成功生成材質!"
			return Mtl_Tar2
		)	
	)--方法結束	
	--refs.dependents <MAXWrapper_object>  --返回一個與其相關聯的物體的Name 類數組	
		
--從所選擇的物體裏抽取材質,然後查找所有使用到這個材質的物體,以數組的形式返回這些物體
fn GetObjsFromSelect  = 
(
	local Mtls = #()	--所選物體的材質名集合	
	local resultObjs=#()
	local noMatObj = #()
	
	--選擇物體沒有材質,直接直接返回選擇的物體
	--選擇的物體有材質
	--返回與這個材質相關聯的所有物體
	
--判斷選擇的物體是否只有一個材質
	Objs = selection as Array
	--Mtls = for obj in Objs where obj.material != undefined  collect obj.material.name
	for obj in Objs do (if obj.material == undefined then (append noMatObj obj) else append Mtls obj.material.name)
	-------------------------------------------
	if Mtls.count>0 then Mtls = RemoveTheSame Mtls		--清洗材質球
	if Mtls.count>1 then messagebox "所先物體有多個材質球,請確認!"		
	else if Mtls.count==1 and SceneMaterials[Mtls[1]]!=undefined then 
		
	( matname = Mtls[1]
	  mat =SceneMaterials[matname] 
	  refs_objs =refs.dependents mat 	--正常返回的是一個包含材質與物體的數組,但有些材質不知道什麼原因,沒包含到物體
	  resultObjs = for obj in refs_objs where superclassof obj == GeometryClass collect obj
	  --21090422添加	  
	  --如果這個objs =refs.dependents mat沒有GeometryClass類的物體,則是直接將選擇的物體返回給resultObjs
	  if resultObjs.count==0 then resultObjs = Objs
	)
	resultOjbs = join resultObjs  noMatObj
	return resultOjbs
--如果有多個材質,提示
--如果只有一個材質,遍歷物體,將它們的材質指定爲MatTemp	
)
--從選擇的材質球裏獲取物體
fn GetObjsFromActiveMat  = 
(
	--local Mtls = #()	--所選物體的材質名集合	
	local resultObjs=#()
	local noMatObj = #()	
	
	mat =meditmaterials[activeMeditSlot] 
	refs_objs =refs.dependents mat 	--正常返回的是一個包含材質與物體的數組,但有些材質不知道什麼原因,沒包含到物體
	resultObjs = for obj in refs_objs where superclassof obj == GeometryClass collect obj
	  
	--如果這個objs =refs.dependents mat沒有GeometryClass類的物體,則是直接將選擇的物體返回給resultObjs
	if resultObjs.count==0 then resultObjs = Objs
	
	resultOjbs = if resultObjs != undefined then ( join resultObjs  noMatObj)
	return resultOjbs

)
--------------------------------------------------------------------------------
--獲取選擇物體的材質,如果有多個材質,提示
fn GetMatFromSelect  = 
(local objs = selection as array
 local mats = for obj in objs where (obj.material!=undefined ) collect obj.material
 mats[1]	--只取第一個材質

  
)
--------------------------------------------------------------------------------
--設置材質 
--MatTemp材質 --目標材質類型
fn Set_Mat MatTemp =
(
	matTar = MatTemp
	matTar.name = matTar.name+"_a"+num as string
	
	local mtl = undefined	--所選物體的材質球
	
	global objs = if (GetObjsFromSelect() !=undefined )do GetObjsFromSelect() 	--獲取與選擇物體同材質的所有obj物體,如果些物體沒有給材質,則直接返回這些物體
	print "Set OBJ:"
	print objs		
	mtl = if ($ ==undefined )then messagebox "請選擇物體" else  (GetMatFromSelect())	--所選物體的材質,如果有多個材質,則直接取第一個材質	
	
	print "原始材質爲:"
	print mtl	
	
	MatTemp2 =if mtl==undefined then matTar else ( MatA_To_MatB mtl matTar)
	print "目標材質:"
	print MatTemp2
	for obj in objs do  (obj.material=MatTemp2)
	
	num+=1		
)
-------------
fn Set_Mat_B MatTemp =
(
	matTar = MatTemp
	matTar.name = matTar.name+"_a"+num as string
	
	global objs = if (GetObjsFromActiveMat() !=undefined )do GetObjsFromActiveMat() 	--獲取與選擇物體同材質的所有obj物體,如果些物體沒有給材質,則直接返回這些物體
	print "Set OBJ:"
	print objs	
	
	mtl = meditMaterials[activeMeditSlot] --材質編輯器中激活的材質球	20191212hyq添加,以激活材質球爲原替換材質
	
	print "原始材質爲:"
	print mtl
		
	
	MatTemp2 = MatA_To_MatB mtl matTar
	print "目標材質:"
	print MatTemp2
	
	for obj in objs do  (obj.material=MatTemp2)
	
	meditMaterials[activeMeditSlot]=MatTemp2
	-------20191212新修改
	num+=1		
)
--與上面的Set_Mat結合,這裏是以名稱爲源然後從材質庫裏找到其對應的材質,將這個材質作爲參數傳給Set_Mat 方法
--MatName 準備指定的材質的材質類型
fn SetMat_FromName MatName = copy  currentMaterialLibrary[MatName]
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------

--try(closeRolloutFloater YFMat);catch()
--try(destroydialog YFMat);catch()
--------------------------------------------------------------------------
--include 

---------------------------------------------------------------------------

	
---------------------------------------------------------------------------
fn ShowRollout = 
	(
	try(closeRolloutFloater YFMat);catch()	
	YFMat = newRolloutFloater "一鍵給材質" 468 420
	--include "OneKeySetMat_M.ms"
	scriptfile="OneKeySetMat_M.ms" 
	fileIn scriptfile	
		
	IsMatLibIn = loadMaterialLibrary ((GetDir #scripts)+"\YF_Vary.mat")	--加載YF_Vary.mat
	if (not IsMatLibIn) then messagebox ("請將材質庫YF_Vray.mat放在scripts文件夾中")
	
	addRollout hyq2 YFMat rolledUp:false	
	addRollout YFDefaultRlt YFMat rolledUp:true
	addRollout YFMat1Rlt YFMat rolledUp:true
	addRollout YFMat2Rlt YFMat rolledUp:true
	addRollout YFMat3Rlt YFMat rolledUp:true
	addRollout YFMat4Rlt YFMat rolledUp:true
	addRollout YFMat5Rlt YFMat rolledUp:true		
	--print YFMat.size
	--YFMat.size = [YFMat.size[1],YFDefaultRlt.size[2]]	
	)
------------------------------------------------------------------------
rollout hyq2 "SetMaterial" width:464 height:27
(
	materialButton btn9 "一鍵給材質" pos:[20,4] width:85 height:17
	
	button btn17 "將材質導入編輯器/下一屏" pos:[297,4] width:145 height:17
	button btn5 "SelectByMaterial" pos:[153,4] width:85 height:17
		
		----------------------------------------------------------------------------
	on btn5 pressed do
	(
		
		objByMaterials = if (GetObjsFromActiveMat() !=undefined )do GetObjsFromActiveMat()
		try(select objByMaterials);catch(messagebox "空材質,請重新選擇材質球")					
			
	)	
		
		
	on btn9 picked MatTemp do
	(
		
		Set_Mat MatTemp	--調用OneKeySetMat_M.ms 裏的Set_Mat 方法
					
			
	)
	on btn17 pressed do
	(
	if MatIndex>AllMats.count then MatIndex=1	--如果將所有的材質都導入一遍之後再按此按扭,將重新導入一次
	LoadNextMat()
		
	)
)
------------------20191216hyq------------------------------------------------------
rollout GetComMap "提取複合貼圖" width:464 height:161
(
	GroupBox grp1 "提取複合貼圖" pos:[0,2] width:373 height:117
	edittext edt1 "" pos:[83,36] width:284 height:19
	button btn1 "貼圖存放路徑" pos:[4,34] width:80 height:22	
	button btn2 "提取漫反射貼圖" pos:[262,83] width:100 height:30
	--------------------------------------------------------------------------
	on btn1 pressed do ( 
		try(
		edt1.text = getSavePath()
		)catch()
		)
	
	on btn2 pressed do ( 
		mfname = MaxFileName	--獲取max文件名
		if mfname == "" then (mfname = "Untitled.max")
		if (maxfiname != mfname) then ( GetComtexNum=0;maxfiname = mfname )
		
		texsavepath = edt1.text
		main_GetComTex()
		)
)
------------------------------------------------------------------------
rollout YFDefaultRlt "常用材質球" width:464 height:264
(
	button YF_taoci "陶瓷" pos:[11,9] width:100 height:20
	button YF_dalishi "大理石" pos:[123,9] width:100 height:20
	button YF_dengzhaobutouming "燈罩不透明" pos:[235,9] width:100 height:20
	button YF_dengdai "燈帶" pos:[347,9] width:100 height:20
	button YF_yaguangmucai "啞光木材" pos:[12,40] width:100 height:20
	
	button YF_toumingboli "透明玻璃" pos:[124,40] width:100 height:20
	button YF_baijing "白鏡" pos:[236,39] width:100 height:20
	button YF_shui "水" pos:[348,40] width:100 height:20
	button YF_moshajinshu "磨砂金屬" pos:[12,72] width:100 height:20
	button YF_liangguangjinshu "亮光金屬" pos:[124,72] width:100 height:20
	
	button YF_jinsemoshajinshu "金色磨砂金屬" pos:[236,72] width:100 height:20
	button YF_jinshujianmoshajinshu "金屬件磨砂金屬" pos:[348,72] width:100 height:20
	button YF_yaguangsuliao "啞光塑料" pos:[13,103] width:100 height:20
	button YF_yaguangpige "啞光皮革" pos:[125,103] width:100 height:20
	button YF_pingmu "屏幕" pos:[237,103] width:100 height:20
	
	button YF_heipingmu "黑屏幕" pos:[349,103] width:100 height:20
	button YF_buyi "布藝" pos:[13,134] width:100 height:20
	button YF_rongbu "絨布" pos:[125,134] width:100 height:20
	button YF_chutao "粗陶" pos:[237,134] width:100 height:20
	button YF_kaoqi "烤漆" pos:[349,134] width:100 height:20
	
	button YF_shufengmian "書封面" pos:[14,165] width:100 height:20
	button YF_guahua "掛畫" pos:[126,165] width:100 height:20
	button YF_hongjiu "紅酒" pos:[238,165] width:100 height:20
	button YF_hongjiuping "紅酒瓶" pos:[350,165] width:100 height:20
	button YF_zhiwuhua "植物花" pos:[14,197] width:100 height:20
	
	button YF_zhiwuyezhi "植物葉子" pos:[126,197] width:100 height:20
	button YF_zhiwushupi "植物樹皮" pos:[238,197] width:100 height:20
	button YF_tuliao "塗料" pos:[350,197] width:100 height:20
	button btn102 "Button" pos:[15,228] width:100 height:20
	button btn103 "Button" pos:[127,228] width:100 height:20
	
	button btn104 "Button" pos:[239,228] width:100 height:20
	button btn105 "Button" pos:[351,228] width:100 height:20
	------------------------------------------------------------------------
	on YF_taoci pressed do ( Set_Mat (SetMat_FromName "YF_taoci"))
	on YF_dalishi pressed do ( Set_Mat (SetMat_FromName "YF_dalishi"))
	on YF_dengzhaobutouming pressed do ( Set_Mat (SetMat_FromName "YF_dengzhaobutouming"))
	on YF_dengdai pressed do ( Set_Mat (SetMat_FromName "YF_dengdai"))
	on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	
	on YF_toumingboli pressed do ( Set_Mat (SetMat_FromName "YF_toumingboli"))
	on YF_baijing pressed do ( Set_Mat (SetMat_FromName "YF_baijing"))
	on YF_shui pressed do ( Set_Mat (SetMat_FromName "YF_shui"))
	on YF_moshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_moshajinshu"))
	on YF_liangguangjinshu pressed do ( Set_Mat (SetMat_FromName "YF_liangguangjinshu"))
	
	on YF_jinsemoshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_jinsemoshajinshu"))
	on YF_jinshujianmoshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_jinshujianmoshajinshu"))
	on YF_yaguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_yaguangsuliao"))
	on YF_yaguangpige pressed do ( Set_Mat (SetMat_FromName "YF_yaguangpige"))
	on YF_pingmu pressed do ( Set_Mat (SetMat_FromName "YF_pingmu"))
	
	on YF_heipingmu pressed do ( Set_Mat (SetMat_FromName "YF_heipingmu"))
	on YF_buyi pressed do ( Set_Mat (SetMat_FromName "YF_buyi"))
	on YF_rongbu pressed do ( Set_Mat (SetMat_FromName "YF_rongbu"))
	on YF_chutao pressed do ( Set_Mat (SetMat_FromName "YF_chutao"))
	on YF_kaoqi pressed do ( Set_Mat (SetMat_FromName "YF_kaoqi"))
	
	on YF_shufengmian pressed do ( Set_Mat (SetMat_FromName "YF_shufengmian"))
	on YF_guahua pressed do ( Set_Mat (SetMat_FromName "YF_guahua"))
	on YF_hongjiu pressed do ( Set_Mat (SetMat_FromName "YF_hongjiu"))
	on YF_hongjiuping pressed do ( Set_Mat (SetMat_FromName "YF_hongjiuping"))
	on YF_zhiwuhua pressed do ( Set_Mat (SetMat_FromName "YF_zhiwuhua"))
	
	on YF_zhiwuyezhi pressed do ( Set_Mat (SetMat_FromName "YF_zhiwuyezhi"))
	on YF_zhiwushupi pressed do ( Set_Mat (SetMat_FromName "YF_zhiwushupi"))
	on YF_tuliao pressed do ( Set_Mat (SetMat_FromName "YF_tuliao"))
	--on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	--on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	
	--on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	--on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	
	
)
------------------------------------------------------------------------
rollout YFMat1Rlt "木材" width:456 height:141
(
	GroupBox grp_wood "木材" pos:[8,2] width:432 height:118
	button YF_yaguangmucai "啞光木材" pos:[40,23] width:100 height:20
	button YF_loukongliangguangmucai "鏤空亮光木材" pos:[173,56] width:100 height:20
	button YF_yaguangshimu "啞光實木" pos:[306,24] width:100 height:20
	button YF_loukongyaguangmucai "鏤空啞光木材" pos:[40,55] width:100 height:20	
	button YF_liangguangmucai "亮光木材" pos:[173,24] width:100 height:20
	button YF_loukongzhiwu "鏤空植物" pos:[306,56] width:100 height:20
	button YF_zhiwuyezhi "植物葉子" pos:[173,88] width:100 height:20
	button YF_zhiwushupi "植物樹皮" pos:[40,87] width:100 height:20
	button YF_zhiwuhua "植物花" pos:[306,88] width:100 height:20
	
	------------------------------------------------------------------------------
	on YF_yaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_yaguangmucai"))
	on YF_loukongliangguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_loukongliangguangmucai"))
	on YF_yaguangshimu pressed do ( Set_Mat (SetMat_FromName "YF_yaguangshimu"))
	on YF_loukongyaguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_loukongyaguangmucai"))
	on YF_liangguangmucai pressed do ( Set_Mat (SetMat_FromName "YF_liangguangmucai"))
	on YF_loukongzhiwu pressed do ( Set_Mat (SetMat_FromName "YF_loukongzhiwu"))
	on YF_zhiwuyezhi pressed do ( Set_Mat (SetMat_FromName "YF_zhiwuyezhi"))
	on YF_zhiwushupi pressed do ( Set_Mat (SetMat_FromName "YF_zhiwushupi"))
	on YF_zhiwuhua pressed do ( Set_Mat (SetMat_FromName "YF_zhiwuhua"))
	
)
------------------------------------------------------------------------

rollout YFMat2Rlt "金屬" width:456 height:104
(
	GroupBox grp_wood "金屬" pos:[8,2] width:432 height:87
	button YF_moshajinshu "磨砂金屬" pos:[40,23] width:100 height:20
	button YF_loukongmoshajinshu "鏤空磨砂金屬" pos:[173,56] width:100 height:20
	button YF_jinsemoshajinshu "金色磨砂金屬" pos:[306,24] width:100 height:20
	button YF_jinshujianmoshajinshu "金屬件磨砂金屬" pos:[40,55] width:100 height:20
	button YF_liangguangjinshu "亮光金屬" pos:[173,24] width:100 height:20
	button YF_loukongliangguangjinshu "鏤空亮光金屬" pos:[306,56] width:100 height:20
	
	------------------------------------------------------------------------------
	on YF_moshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_moshajinshu"))
	on YF_loukongmoshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_loukongmoshajinshu"))
	on YF_jinsemoshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_jinsemoshajinshu"))
	on YF_jinshujianmoshajinshu pressed do ( Set_Mat (SetMat_FromName "YF_jinshujianmoshajinshu"))
	on YF_liangguangjinshu pressed do ( Set_Mat (SetMat_FromName "YF_liangguangjinshu"))
	on YF_loukongliangguangjinshu pressed do ( Set_Mat (SetMat_FromName "YF_loukongliangguangjinshu"))
)
------------------------------------------------------------------------

rollout YFMat3Rlt "塑料-皮革-布-紗" width:456 height:256
(
	GroupBox grp_wood "塑料" pos:[8,2] width:432 height:86
	button YF_yaguangsuliao "啞光塑料" pos:[40,23] width:100 height:20
	button YF_toumingliangguangsuliao "透明亮光塑料" pos:[173,56] width:100 height:20
	button YF_toumingloukongyaguangsuliao "透明鏤空啞光塑料" pos:[306,24] width:100 height:20
	button YF_liangguangsuliao "亮光塑料" pos:[40,55] width:100 height:20		
		
	button YF_toumingyaguangsuliao "透明啞光塑料" pos:[173,24] width:100 height:20
	button YF_toumingloukongliangguangsuliao "透明鏤空亮光塑料" pos:[306,56] width:100 height:20
	button YF_liangguangpige "亮光皮革" pos:[173,117] width:100 height:20
	button YF_yaguangpige "啞光皮革" pos:[40,116] width:100 height:20
	button YF_sichou "絲綢" pos:[306,117] width:100 height:20
	GroupBox grp11 "皮革-布藝" pos:[8,97] width:432 height:143
	button YF_dengzhaotouming "燈罩透明" pos:[173,204] width:100 height:20
	button YF_dengzhaobutouming "燈罩不透明" pos:[40,203] width:100 height:20
	button YF_ruanbao "軟包" pos:[306,204] width:100 height:20
	button YF_rongbu "絨布" pos:[173,145] width:100 height:20
	button YF_buyi "布藝" pos:[40,144] width:100 height:20
	button YF_loukongbuyi "鏤空布藝" pos:[306,145] width:100 height:20
	button YF_tuansha "圖案紗" pos:[173,174] width:100 height:20
	button YF_sha "紗" pos:[40,173] width:100 height:20
	button YF_ditan "地毯" pos:[306,174] width:100 height:20
	------------------------------------------------------------------------------
	on YF_yaguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_yaguangsuliao"))	
	on YF_toumingliangguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_toumingliangguangsuliao"))
	on YF_toumingloukongyaguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_toumingloukongyaguangsuliao"))
	on YF_liangguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_liangguangsuliao"))
		
	on YF_toumingyaguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_toumingyaguangsuliao"))
	on YF_toumingloukongliangguangsuliao pressed do ( Set_Mat (SetMat_FromName "YF_toumingloukongliangguangsuliao"))	
	on YF_liangguangpige pressed do ( Set_Mat (SetMat_FromName "YF_liangguangpige"))
	on YF_yaguangpige pressed do ( Set_Mat (SetMat_FromName "YF_yaguangpige"))
	on YF_sichou pressed do ( Set_Mat (SetMat_FromName "YF_sichou"))
	on YF_dengzhaotouming pressed do ( Set_Mat (SetMat_FromName "YF_dengzhaotouming"))
	on YF_dengzhaobutouming pressed do ( Set_Mat (SetMat_FromName "YF_dengzhaobutouming"))
	on YF_ruanbao pressed do ( Set_Mat (SetMat_FromName "YF_ruanbao"))
	on YF_rongbu pressed do ( Set_Mat (SetMat_FromName "YF_rongbu"))
	on YF_buyi pressed do ( Set_Mat (SetMat_FromName "YF_buyi"))
	on YF_loukongbuyi pressed do ( Set_Mat (SetMat_FromName "YF_loukongbuyi"))
	on YF_tuansha pressed do ( Set_Mat (SetMat_FromName "YF_tuansha"))
	on YF_sha pressed do ( Set_Mat (SetMat_FromName "YF_sha"))
	on YF_ditan pressed do ( Set_Mat (SetMat_FromName "YF_ditan"))
)
------------------------------------------------------------------------

rollout YFMat4Rlt "玻璃-水-鏡子-屏幕" width:456 height:264
(
	GroupBox grp_wood "玻璃" pos:[13,8] width:432 height:118
	GroupBox grp13 "水-鏡子-屏幕" pos:[13,134] width:432 height:118
	
	button YF_toumingboli "透明玻璃" pos:[44,29] width:100 height:20
	button YF_heiboli "黑玻璃" pos:[180,62] width:100 height:20
	button YF_butoummoshaboli "不透明磨砂玻璃" pos:[316,30] width:100 height:20
	button YF_chuanghutoumingboli "窗戶透明玻璃" pos:[44,61] width:100 height:20		
	button YF_moshaboli "磨砂玻璃" pos:[180,30] width:100 height:20
	
	button YF_zhezhaoboli "遮罩玻璃" pos:[316,62] width:100 height:20	
	button YF_chajiboli "茶几玻璃" pos:[44,93] width:100 height:20
	button YF_caiseboli "彩色玻璃" pos:[180,94] width:100 height:20	
	button YF_baijing "白鏡" pos:[44,151] width:100 height:20
	button YF_chajing "茶鏡" pos:[316,151] width:100 height:20
	
	button YF_heijing "黑鏡" pos:[180,151] width:100 height:20
	button YF_shui "水" pos:[44,182] width:100 height:20
	button YF_shuijing "水晶" pos:[316,94] width:100 height:20
	button YF_hongjiu "紅酒" pos:[180,182] width:100 height:20
	button YF_hongjiuping "紅酒瓶" pos:[316,182] width:100 height:20
	
	button YF_pingmu "屏幕" pos:[180,214] width:100 height:20
	button YF_heipingmu "黑屏幕" pos:[316,214] width:100 height:20
	button YF_dengdai "燈帶" pos:[44,214] width:100 height:20
	------------------------------------------------------------------------------
	on YF_toumingboli pressed do ( Set_Mat (SetMat_FromName "YF_toumingboli"))
	on YF_heiboli pressed do ( Set_Mat (SetMat_FromName "YF_heiboli"))
	on YF_butoummoshaboli pressed do ( Set_Mat (SetMat_FromName "YF_butoummoshaboli"))
	on YF_chuanghutoumingboli pressed do ( Set_Mat (SetMat_FromName "YF_chuanghutoumingboli"))
	on YF_moshaboli pressed do ( Set_Mat (SetMat_FromName "YF_moshaboli"))
		
	on YF_zhezhaoboli pressed do ( Set_Mat (SetMat_FromName "YF_zhezhaoboli"))		
	on YF_chajiboli pressed do ( Set_Mat (SetMat_FromName "YF_chajiboli"))
	on YF_caiseboli pressed do ( Set_Mat (SetMat_FromName "YF_caiseboli"))
	on YF_baijing pressed do ( Set_Mat (SetMat_FromName "YF_baijing"))
	on YF_chajing pressed do ( Set_Mat (SetMat_FromName "YF_chajing"))
		
	on YF_heijing pressed do ( Set_Mat (SetMat_FromName "YF_heijing"))
	on YF_shui pressed do ( Set_Mat (SetMat_FromName "YF_shui"))
	on YF_shuijing pressed do ( Set_Mat (SetMat_FromName "YF_shuijing"))
	on YF_hongjiu pressed do ( Set_Mat (SetMat_FromName "YF_hongjiu"))
	on YF_hongjiuping pressed do ( Set_Mat (SetMat_FromName "YF_hongjiuping"))
		
	on YF_pingmu pressed do ( Set_Mat (SetMat_FromName "YF_pingmu"))
	on YF_heipingmu pressed do ( Set_Mat (SetMat_FromName "YF_heipingmu"))
	on YF_dengdai pressed do ( Set_Mat (SetMat_FromName "YF_dengdai"))
	

)
------------------------------------------------------------------------

rollout YFMat5Rlt "硬裝材質" width:456 height:376
(
	GroupBox grp_wood "石材" pos:[8,2] width:432 height:150
	GroupBox grp20 "其它" pos:[8,297] width:432 height:71
	GroupBox grp22 "牆-地板" pos:[8,152] width:432 height:144
	
	button YF_taoci "陶瓷" pos:[40,23] width:100 height:20
	button YF_masaike "馬賽克" pos:[173,55] width:100 height:20
	button YF_wenhuashi "文化石" pos:[306,24] width:100 height:20
	button YF_dalishi "大理石" pos:[40,54] width:100 height:20
	button YF_chutao "粗陶" pos:[173,24] width:100 height:20
	
	button YF_putongcizhuan "普通瓷磚" pos:[306,55] width:100 height:20
	button YF_paoguangzhuan "拋光磚" pos:[173,87] width:100 height:20
	button YF_yaguangzhuan "啞光磚" pos:[40,86] width:100 height:20
	button YF_gaofanshezhuan "高反射磚" pos:[306,87] width:100 height:20
	button YF_kaoqi "烤漆" pos:[173,312] width:100 height:20
	
	button YF_guahua "掛畫" pos:[40,311] width:100 height:20
	button YF_yaguangshufengmian "啞光書封面" pos:[173,343] width:100 height:20
	button YF_shufengmian "書封面" pos:[40,342] width:100 height:20
	button YF_guizaoni "硅藻泥" pos:[40,201] width:100 height:20
	button YF_fudiao "浮雕" pos:[306,116] width:100 height:20
	
	button YF_tuliao "塗料" pos:[173,119] width:100 height:20
	button YF_yaguangqiangzhi "啞光牆紙" pos:[173,171] width:100 height:20
	button YF_putongqiangzhi "普通牆紙" pos:[40,170] width:100 height:20
	button YF_fansheqiangzhi "反射牆紙" pos:[306,171] width:100 height:20
	button YF_fansheguizaoni "反射硅藻泥" pos:[306,202] width:100 height:20
	
	button YF_aotuguizaoni "凹凸硅藻泥" pos:[173,201] width:100 height:20
	button YF_baiqiang "白牆" pos:[40,120] width:100 height:20
	button YF_liangguangdiban "亮光地板" pos:[173,231] width:100 height:20
	button YF_zidingyi "自定義" pos:[306,312] width:100 height:20
	button YF_yaguangdiban "啞光地板" pos:[40,231] width:100 height:20
	
	button YF_yaguangkouban "啞光扣板" pos:[173,262] width:100 height:20
	button YF_liangguangkouban "亮光扣板" pos:[306,261] width:100 height:20
	button YF_yaguangqiangban "啞光牆板" pos:[40,262] width:100 height:20
	button YF_liangguangqianban "亮光牆板" pos:[306,231] width:100 height:20
	
	------------------------------------------------------------------------------
	on YF_taoci pressed do ( Set_Mat (SetMat_FromName "YF_taoci"))
	on YF_masaike pressed do ( Set_Mat (SetMat_FromName "YF_masaike"))
	on YF_wenhuashi pressed do ( Set_Mat (SetMat_FromName "YF_wenhuashi"))
	on YF_dalishi pressed do ( Set_Mat (SetMat_FromName "YF_dalishi"))
	on YF_chutao pressed do ( Set_Mat (SetMat_FromName "YF_chutao"))
		
	on YF_putongcizhuan pressed do ( Set_Mat (SetMat_FromName "YF_putongcizhuan"))
	on YF_paoguangzhuan pressed do ( Set_Mat (SetMat_FromName "YF_paoguangzhuan"))
	on YF_yaguangzhuan pressed do ( Set_Mat (SetMat_FromName "YF_yaguangzhuan"))
	on YF_gaofanshezhuan pressed do ( Set_Mat (SetMat_FromName "YF_gaofanshezhuan"))
	on YF_kaoqi pressed do ( Set_Mat (SetMat_FromName "YF_kaoqi"))
	
	on YF_guahua pressed do ( Set_Mat (SetMat_FromName "YF_guahua"))
	on YF_yaguangshufengmian pressed do ( Set_Mat (SetMat_FromName "YF_yaguangshufengmian"))
	on YF_shufengmian pressed do ( Set_Mat (SetMat_FromName "YF_shufengmian"))
	on YF_guizaoni pressed do ( Set_Mat (SetMat_FromName "YF_guizaoni"))
	on YF_fudiao pressed do ( Set_Mat (SetMat_FromName "YF_fudiao"))
	
	on YF_tuliao pressed do ( Set_Mat (SetMat_FromName "YF_tuliao"))
	on YF_yaguangqiangzhi pressed do ( Set_Mat (SetMat_FromName "YF_yaguangqiangzhi"))
	on YF_putongqiangzhi pressed do ( Set_Mat (SetMat_FromName "YF_putongqiangzhi"))
	on YF_fansheqiangzhi pressed do ( Set_Mat (SetMat_FromName "YF_fansheqiangzhi"))
	on YF_fansheguizaoni pressed do ( Set_Mat (SetMat_FromName "YF_fansheguizaoni"))
	
	on YF_aotuguizaoni pressed do ( Set_Mat (SetMat_FromName "YF_aotuguizaoni"))
	on YF_baiqiang pressed do ( Set_Mat (SetMat_FromName "YF_baiqiang"))
	on YF_liangguangdiban pressed do ( Set_Mat (SetMat_FromName "YF_liangguangdiban"))
	on YF_zidingyi pressed do ( Set_Mat (SetMat_FromName "YF_zidingyi"))
	on YF_yaguangdiban pressed do ( Set_Mat (SetMat_FromName "YF_yaguangdiban"))
	
	on YF_yaguangkouban pressed do ( Set_Mat (SetMat_FromName "YF_yaguangkouban"))
	on YF_liangguangkouban pressed do ( Set_Mat (SetMat_FromName "YF_liangguangkouban"))
	on YF_yaguangqiangban pressed do ( Set_Mat (SetMat_FromName "YF_yaguangqiangban"))
	on YF_liangguangqianban pressed do ( Set_Mat (SetMat_FromName "YF_liangguangqianban"))
	
)
------------------------------------------------------------------------
	try closeRolloutFloater YFMat catch()

	YFMat = newRolloutFloater "一鍵給材質" 468 420
	--include "OneKeySetMat_M.ms"
	IsMatLibIn = loadMaterialLibrary ((GetDir #scripts)+"\YF_Vary.mat")	--加載YF_Vary.mat
	if (not IsMatLibIn) then messagebox("請將材質庫YF_Vray.mat放在scripts文件夾中")
	
	addRollout hyq2 YFMat rolledUp:false
	addRollout GetComMap YFMat rolledUp:true
	addRollout YFDefaultRlt YFMat rolledUp:true
	addRollout YFMat1Rlt YFMat rolledUp:true
	addRollout YFMat2Rlt YFMat rolledUp:true
	addRollout YFMat3Rlt YFMat rolledUp:true
	addRollout YFMat4Rlt YFMat rolledUp:true
	addRollout YFMat5Rlt YFMat rolledUp:true
--ShowRollout()
)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章