您的位置:首页 > 产品设计 > UI/UE

ui 界面美观化 (多维子材质脚本)

2011-04-08 17:29 267 查看
--2011.4.8 去除注解 项目用
---**********************************************************************************************************************
---************************************************************************************************************************

stand_mat = #()
nostand_mat = #()
map_preparation =#()
material_map_map =#()
fn clmedit_add =
(
oop_array = selection as array
meditMaterials[1] = oop_array[1].Material
)

fn or_or num =
(
if classof $.material == Multimaterial then
(
clmedit_add()

shu = meditMaterials[num].materialIDList. count
return shu
)else
(
return false
)
)

fn check_unm =
(
unm = or_or 1
if unm == undefined then
(
return false
)

list_mat = meditMaterials[1].materialIDList
stand_mat=#()
for i in 1 to unm do
(

if classof meditMaterials[1][list_mat[i]] == Standardmaterial then
(

append stand_mat list_mat[i]

)
else
(

append nostand_mat list_mat[i]

if nostand_mat.count >0 then
(

if AboutRollout != undefined then destroydialog AboutRollout
rollout AboutRollout "About"
(
label lbl5 "选择物体的多维材质中" pos:[10,10]
label lbl3 "有不是标准子材质的材质"
timer tmclose "" interval:2000 active:true
on AboutRollout rbuttonup press do destroydialog AboutRollout ------ 右键进行消除
on tmclose tick do destroydialog AboutRollout --时间按点到消除 给我提供了思路。
)createdialog AboutRollout 200 100 modal:true style:#(#style_border,#style_sysmenu,#style_sunkenedge)

clearListener()
setListenerSel #(0,-1)
for i in nostand_mat do
(
format "不是标准材质的有: meditMaterials[1][%]\n" i Listener()
)
)
)
)

)

fn cle_mat_id_face =
(

met_obj_face =#()

met_obj_face_id =#()

check_unm()
comparison = stand_mat

for i in comparison do
(
channel_num = 24

for n in 1 to channel_num do
(

the_prop = getSubTexmap MeditMaterials[1][i] n

if the_prop != undefined then
(
if findItem map_preparation i ==0 then
(

append map_preparation i
)

)
)

)

for each in comparison do
(

if findItem map_preparation each ==0 then
(
append met_obj_face_id each
)

)

return met_obj_face_id
)

fn cle_mat_id_face_add =
(

clear_array_mat = cle_mat_id_face ()
meditMaterials[1].materialIDList = map_preparation
select_one = $selection [1]
max modify mode

if classof select_one.baseobject== Editable_mesh then
(
convertTo select_one PolyMeshObject
)

if classof select_one.baseobject== Editable_Poly then

( --

dat_num = #{}

modPanel.setCurrentObject $.baseObject

subobjectLevel = 4

for i in clear_array_mat do
(

select_one.EditablePoly.selectByMaterial i
dat_num += polyop.getfaceselection $
)

polyop.setfaceselection select_one (dat_num )
nodeInvalRect select_one
)
)

fn mat_modifiers_mane prefix name_n suffix =
(

or_or 1

if or_or 1 ==false then return false

list_mat = meditMaterials[1].materialIDList

for i in list_mat do
(
if name_n=="" then
(
meditMaterials[1][i].name =prefix + meditMaterials[1][i].name +suffix
)else
(
meditMaterials[1][i].name =prefix + name_n+i as string +suffix
)

)

)

fn multimaterial_mat nums prefix name_n suffix =
(
or_or 1

if or_or 1 ==false then return false

if classof meditMaterials[1][nums] ==Standardmaterial then
(

chenk = getnumsubtexmaps meditMaterials[1][nums]

for each in 1 to chenk do
(

the_prop = getSubTexmap MeditMaterials[1][nums] each

if the_prop!= undefined then
( --

if name_n== "" then
(--

kl = (getSubTexmap MeditMaterials[1][nums] each ) .name

(getSubTexmap MeditMaterials[1][nums] each ) .name = prefix+ kl+suffix
)else
(

(getSubTexmap MeditMaterials[1][nums] each ) .name= prefix+ name_n+ nums as string +suffix

)
)

)

)

)---end fn

fn multimaterial_mat_all prefix name_n suffix =
(

check_unm ()

mat_array = stand_mat

if mat_array.count == 0 then return false
for i in mat_array do
(

if classof meditMaterials[1][i] == Standardmaterial then
( --
chenk = getnumsubtexmaps meditMaterials[1][i]

for each in 1 to chenk do
(

the_prop = getSubTexmap MeditMaterials[1][i] each

if the_prop!= undefined then
( --

if name_n== "" then
(--
kl = (getSubTexmap MeditMaterials[1][i] each ) .name

(getSubTexmap MeditMaterials[1][i] each ) .name = prefix+ kl+suffix
)else
(
(getSubTexmap MeditMaterials[1][i] each ) .name= prefix+ name_n +each as string +suffix
)
)---end if the_prop!= undefined then

)---end for each

)---end if
)---end for

)---end fn

fn Fixed_point_color unm cloor_id =
(

check_unm ()

mat_array = stand_mat

if mat_array.count == 0 then return false

--(
if classof meditMaterials[1][unm] == Standardmaterial then
(
meditMaterials[1][unm].diffuse =cloor_id

)---end if

-- )---end for

)---end fn

fn dingdianclor objID clort =
(

check_unm ()

mat_array = stand_mat

if classof meditMaterials[1][objID] == Standardmaterial then
(

select_one = $selection [1]
max modify mode

if classof select_one.baseobject== Editable_mesh then
(
-- 转多边行
convertTo select_one PolyMeshObject
)

dat_num = #()
if classof select_one.baseobject== Editable_Poly then

(
modPanel.setCurrentObject select_one.baseObject

subobjectLevel = 4
select_one.EditablePoly.selectByMaterial objID
--polyop.getfaceselection 这里用顶点选择、
select_one.EditablePoly.ConvertSelection #Face #Vertex
subobjectLevel = 1
dat_num = polyop.getVertSelection select_one

polyop.setVertColor select_one 0 dat_num clort

)
)----end if

)-----end fn

tietushouji_map_id =#()
fn Map_collection =
(

check_unm ()
mat_array = stand_mat

for i in mat_array do
( --

for each in 1 to 24 do --这里其实直接就可以写成24 算法就更快了。 我把 这里的chenk 改成24 了 2011.4.7
(

the_prop = getSubTexmap MeditMaterials[1][i] each

if the_prop!= undefined then
(

if findItem tietushouji_map_id i ==0 then
append tietushouji_map_id i

)---end if then_prop

)---end for each
)----end for
return tietushouji_map_id

)----end fn

bmp_zhuan_string =#()
fn map_map_compared =
(
map_array_com = Map_collection ()
if map_array_com.count ==0 then return false

for i in 1 to map_array_com.count do
(
linshi_add_array =""
try chenk = getnumsubtexmaps meditMaterials[1][(map_array_com[i])] catch()

for each in 1 to chenk do
(
the_prop = getSubTexmap MeditMaterials[1][(map_array_com[i])] each

if classof the_prop == Bitmaptexture then
(
str = the_prop.fileName ---分出来要最后一个。

oop = filterString str "\\" --分组

add_array = oop[(oop.count)]

append linshi_add_array add_array

)

)

bmp_zhuan_string[i] = linshi_add_array as string
)--end for

return bmp_zhuan_string

)----end fn

--***************************************************************************
zhuan_string =#()
fn map_compared =
(
map_array_com = Map_collection ()

if map_array_com.count ==0 then return false

for i in 1 to map_array_com.count do
(
linshi_add_array =""
try chenk = getnumsubtexmaps meditMaterials[1][(map_array_com[i])] catch()

for each in 1 to chenk do
(
the_prop = getSubTexmap MeditMaterials[1][(map_array_com[i])] each

the_prop =the_prop as string

append linshi_add_array the_prop

)

zhuan_string[i] = linshi_add_array as string
--*********************************************************************************************

--*****************************************************************************************
)--end for

return zhuan_string

)----end fn
--
global add_mat_num =#()
add_mat_dao =#()

fn array_mat_compared hanshu =
(

art_map_ch = hanshu --map_compared()

if art_map_ch == false then return false
if ( art_map_ch.count==0 and art_map_ch.count==1 ) then return false
kl=0
oop_oo =""
global gt_aryu =#()
global aty_1 =#()
xin=#()
for i in 1 to (art_map_ch.count-1) do
(

each =i+1 ---自增的比较项。
oop_oo=i as string
for m in each to art_map_ch.count do
(
-- 比较
if art_map_ch[i] == art_map_ch[m] then
( oop_oo+= "-"+ m as string

)else
(
--oop_oo+=""
)

if (filterString oop_oo "-" ).count >1 then
(

add_mat_num[i] = oop_oo

)
)

)---end for

add_mat_num

if add_mat_num.count <1 then return false
for i in 1 to add_mat_num.count do
(
if add_mat_num [i] == undefined then
(
add_mat_num [i] = "undefined"

append gt_aryu (add_mat_num [i] )

)---end if --deleteItem add_mat_num i
)
for i in add_mat_num do
(

if findItem gt_aryu i ==0 then append aty_1 i
)

add_mat_num = aty_1

--*****************************************************
if add_mat_num.count >1 then
(
yytadd_mat_dao=#()
map_ = add_mat_num.count-1
map__= add_mat_num.count
-- print (add_mat_num as string )
for m in 1 to map_ do
(
ecct= m+1
for each in ecct to map__ do
(
if( findString add_mat_num[m] add_mat_num[each] != undefined ) then
(
-- yytadd_mat_dao[m] = add_mat_num[each]

append yytadd_mat_dao add_mat_num[each]
)
)

)

for nu in add_mat_num do
(
if findItem yytadd_mat_dao nu ==0 then
append xin nu

) ----上面是新算法,还是用的递归。

add_mat_num = xin
)

return add_mat_num

)---rnd fn

fn gt_selctt =
(
kol =1
if $selection.count >1 then
(
if AboutRollout != undefined then destroydialog AboutRollout
rollout AboutRollout "About"
(
label lbl5 "选择数量大于1 将不执行," pos:[10,10]
label lbl3 "以此提醒。"
timer tmclose "" interval:1000 active:true
on AboutRollout rbuttonup press do destroydialog AboutRollout ------ 右键进行消除
on tmclose tick do destroydialog AboutRollout --时间按点到消除 给我提供了思路。
)createdialog AboutRollout 200 100 modal:true style:#(#style_border,#style_sysmenu,#style_sunkenedge)

kol+=1
return kol
)else ( return kol )

)
--
--并且是标准材质的id 。
--
-- )
try ( destroydialog gt_unnamedRollout) catch ()
rollout gt_unnamedRollout "多维材质工具" width:184 height:414
(

local bm = bitmap 192 48 color:red

button name_but "移除空map通道并选面" pos:[6,3] width:166 height:24 toolTip:"清除没有材质的面。"
--imgTag bmp1 "Bitmap" pos:[8,8] width:192 height:48 bitmap:bm

edittext nameedt1 "前缀:" pos:[8,47] width:160 height:16
edittext nameedt2 "名字:" pos:[8,71] width:160 height:16
edittext nameedt3 "后缀:" pos:[8,93] width:160 height:16

button matbtn2 "子材质命名" pos:[10,112] width:72 height:24 toolTip:"对于多维子材质中标准材质的命名。"
button matbtn3 "子贴图命名" pos:[88,112] width:80 height:24 toolTip:"对于多维子材质中标准材质的贴图的命名。"

dropdownList ddl1 "" pos:[16,140] width:40 height:10
checkbutton metckb1 "收子材质id" pos:[88,140] width:80 height:24 --checked:false

colorPicker cp1 "" pos:[11,185] width:32 height:24
dropdownList metddl4 "" pos:[56,187] width:56 height:10

checkbutton shoujibtn11 "颜色id" pos:[120,187] width:48 height:24 toolTip:"点击按钮在对应\
的下拉表中收集id号。。"

button btn12 "子固有色" pos:[16,214] width:64 height:24 toolTip:"第一步先选择id 指定相应的颜色,对固有色进行更改。"
button btn13 "子顶点色" pos:[104,214] width:64 height:24 toolTip:"第一步先选择id 指定相应的颜色,对顶点颜色进行更改\
,在这里对顶点颜色的更改应是poly。"

checkbox myCheckBox "图" pos:[8,385] width:40 height:15

listbox lbx2 "子材质同贴图列表:" pos:[6,244] width:168 height:6

button btn14 "收集顺序" pos:[8,353] width:80 height:24

button btn15 "有map收集" pos:[96,353] width:80 height:24

button btn16 "执行" pos:[96,385] width:80 height:24 toolTip:" 执行\
贴图id合并"
label lab1 "号数:--" pos:[48,387] width:42 height:13
GroupBox grp1 "命名:" pos:[4,28] width:174 height:140
GroupBox grp2 "ID操作" pos:[3,168] width:174 height:73

on lbx2 selected arg do ---这里是临时不上,非常方便。
(
lab1.text = arg as string +"号"
)

on name_but pressed do with undo on
(
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
cle_mat_id_face_add ()
)

on matbtn2 pressed do with undo on
(
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。

mat_modifiers_mane nameedt1.text nameedt2.text nameedt3.text

)

-- stand_mat
on metckb1 changed state do
(
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
check_unm()
if state==true then
(
lingshi =#()
if stand_mat.count<1 then return false
for i in 1 to stand_mat.count do
(
date_state =((stand_mat[i]) as string )
append lingshi date_state

)
gt_unnamedRollout.ddl1.items = lingshi
)
else
(
gt_unnamedRollout.ddl1.items =#()
)---end else
)---end on
--
on shoujibtn11 changed state do
(

gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
check_unm()
if state==true then
(
lingshi =#()
if stand_mat.count<1 then return false
for i in 1 to stand_mat.count do
(
date_state =((stand_mat[i]) as string )
append lingshi date_state

)
gt_unnamedRollout.metddl4.items = lingshi
)
else
(
gt_unnamedRollout.metddl4.items =#()
)---end else
)---end on
-- 下面就是多维材质的,单独指导与多选的操作。
--
on matbtn3 pressed do with undo on
(

gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
if metckb1.checked ==true and gt_unnamedRollout.ddl1.selected != undefined then
(
date_h =gt_unnamedRollout.ddl1.selected as integer
multimaterial_mat date_h nameedt1.text nameedt2.text nameedt3.text

)---end if
else
(
multimaterial_mat_all nameedt1.text nameedt2.text nameedt3.text
)---end else

)---end pressed

on btn12 pressed do with undo on
(

gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
if shoujibtn11.checked ==true and gt_unnamedRollout.metddl4.selected != undefined then
(
clor = gt_unnamedRollout.cp1.color
date_h =gt_unnamedRollout.metddl4.selected as integer

Fixed_point_color date_h clor

)---end if
)---end on
on btn13 pressed do with undo on
(
--cle_mat_id_face()
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。

-- cle_mat_id_face()

if shoujibtn11.checked ==true and gt_unnamedRollout.metddl4.selected != undefined then
(
clor = gt_unnamedRollout.cp1.color
date_h =gt_unnamedRollout.metddl4.selected as integer

dingdianclor date_h clor

)---end if
)---end on

on btn14 pressed do with undo on
(

gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
if gt_unnamedRollout.myCheckBox.checked ==false then
(

stand_mat = #()
nostand_mat = #()
map_preparation =#()
material_map_map =#()
tietushouji_map_id =#()
zhuan_string =#()
add_mat_num =#()
add_mat_dao =#()
bmp_zhuan_string=#()

Map_collection()
cle_mat_id_face()

date_gt = array_mat_compared (map_compared()) --其实在里面已经运行了 Map_collection() 上面不用也行 这样只会增加计算量
--其实最节约时间的不是这些算多少遍 而是我们要用什么样的算法。
if date_gt == false then
gt_unnamedRollout.lbx2.items = #()
else
(
gt_unnamedRollout.lbx2.items=#()---先叫他等于空,这个很是有用。
gt_unnamedRollout.lbx2.items = date_gt
gt_unnamedRollout.lbx2.selection=1
)

) else
(
stand_mat = #()
nostand_mat = #()
map_preparation =#()
material_map_map =#()
tietushouji_map_id =#()
zhuan_string =#()
add_mat_num =#()

add_mat_dao =#()
bmp_zhuan_string=#()
--
--开始的组必须初始化要不对
--

check_unm () -- 这个其实没有必要要。 应为在下面的函数中我已经有了相关的操作。2011.4.7
Map_collection()
cle_mat_id_face()

kkl = map_map_compared()
date_gt = array_mat_compared (kkl) --其实在里面已经运行了 Map_collection() 上面不用也行 这样只会增加计算量
--其实最节约时间的不是这些算多少遍 而是我们要用什么样的算法。
if date_gt == false then
gt_unnamedRollout.lbx2.items = #()
else
(
gt_unnamedRollout.lbx2.items=#()---先叫他等于空,这个很是有用。
gt_unnamedRollout.lbx2.items = date_gt
gt_unnamedRollout.lbx2.selection=1
)

)----end checks

)---end pressed

on btn15 pressed do with undo on
(
gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。

stand_mat = #()
nostand_mat = #()
map_preparation =#()
material_map_map =#()
tietushouji_map_id =#()
zhuan_string =#()
add_mat_num =#()
--
--开始的组必须初始化要不对
--

check_unm ()
Map_collection()
cle_mat_id_face()
--
--收集有贴图的map
--
lingshi =#()
date_gt= Map_collection()
if date_gt.count<1 then return false
for i in 1 to date_gt.count do
(
date_state =((date_gt[i]) as string )
append lingshi date_state

)
gt_unnamedRollout.lbx2.items=#()
gt_unnamedRollout.lbx2.items =lingshi

)---end on

on btn16 pressed do --with undo on 不知道为甚不能用undo
(
try (gt_oo = gt_selctt()
if gt_oo ==2 then return false ---看来我要到处用到这两句了。
)catch ()

-- if myCheckBox.checked ==false then

obj_id =#()--把字符串转成 数组数组。
date_gt=""
gt_date=""
if (gt_unnamedRollout.lbx2.selected != undefined )then
(
gt_date =gt_unnamedRollout.lbx2.selected

if (filterString gt_date "-" ).count >1 then
(
uiop =filterString gt_date "-"

for i in uiop do
(
ui = i as integer -- 转成整数

append obj_id ui

)---end for

)else
(
messageBox "请用**收集顺序**" title:"盖天编写"
return false

)

stand_mat = #()
nostand_mat = #()
map_preparation =#()
material_map_map =#()
tietushouji_map_id =#()
zhuan_string =#()
add_mat_num =#()
--
--开始的组必须初始化要不对
--
list_matsrray =#()
global list_matsrrayone =#()

check_unm ()
Map_collection()
cle_mat_id_face()

lingshi =#()
date_gt= Map_collection()

gt_zhenzheng_date =#()
for i in obj_id do
(
append gt_zhenzheng_date date_gt [i]

)

gt_int_num = gt_zhenzheng_date[1]

---**************************************************************
select_one = selection as array
select_one =select_one[1]
max modify mode
--
-- 先判断 Editable_mesh 装ploy 是ploy在往下进行处理。
--
if classof select_one.baseobject== Editable_mesh then
(
-- 转多边行
macros.run "Modifier Stack" "Convert_to_Poly"
-- convertTo select_one PolyMeshObject
)else (print "no ploy")
if classof select_one.baseobject== Editable_Poly then

(
dat_num = #{}

modPanel.setCurrentObject $.baseObject

subobjectLevel = 4

for i in gt_zhenzheng_date do
(

select_one.EditablePoly.selectByMaterial i
dat_num += polyop.getfaceselection $

)

polyop.setfaceselection select_one (dat_num )
nodeInvalRect select_one

try (select_one.EditablePoly.setMaterialIndex gt_zhenzheng_date[1] 1 )catch ()

subobjectLevel = 0

)else (print "no execution ")

list_mat = meditMaterials[1].materialIDList
for i in 2 to gt_zhenzheng_date.count do
(
if findItem list_mat gt_zhenzheng_date[i] != 0 then
(
append list_matsrray gt_zhenzheng_date[i]
)
-- print list_matsrray
)----end for

print ( list_matsrray as string)
for m in list_mat do
(
if findItem list_matsrray m ==0 then
(
append list_matsrrayone m
)---end if

)---end for
paichuwannan =#()
for ru in list_mat do
(
if findItem list_matsrrayone ru ==0 then
(
append paichuwannan ru
)
)
for i in paichuwannan do
(
meditMaterials[1][i] =Standardmaterial ()
)
meditMaterials[1].materialIDList =list_matsrrayone

gt_unnamedRollout.btn14.pressed()

)else (print "")

) ----end pressed

on gt_unnamedRollout open do
(

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

for i in gt_unnamedRollout.controls do
(
i.enabled =false
)
Callbacks.AddScript #SelectionSetChanged "Fn_CallBack_duoweicazhi()" ID:#gt_mat_met
)---end on
on gt_unnamedRollout close do
(
callbacks.removescripts #selectionSetChanged ID:#gt_mat_met
)---end on

)
createDialog gt_unnamedRollout

callbacks.removescripts #selectionSetChanged ID:#gt_mat_met
fn Fn_CallBack_duoweicazhi =
(

TheSelection = Selection as array

if $== undefined then
(
for i in gt_unnamedRollout.controls do
(
i.enabled =false
)
)else
(

if (classof TheSelection[1].Material) == Multimaterial then
(
for i in gt_unnamedRollout.controls do
(
i.enabled =true
)

)else
(
for i in gt_unnamedRollout.controls do
(
i.enabled =false
)

) --end else
)---end else

)
Callbacks.AddScript #SelectionSetChanged "Fn_CallBack_duoweicazhi()" ID:#gt_mat_met
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: