一、
utility fu61 "卷展栏浮动窗口"
(
slider lian "LILIANFU" orient:#vertical across:3
slider zhi "制作" orient:#vertical
slider fu "石家庄" orient:#vertical
)
--创建一个垂直放置三个slider滑条的卷展栏
二、
utility fu66 "我的卷展栏"
(
local pot
rollout lifu "about my utility"
(
button aboutme "about" width:45 height:20
on aboutme pressed do
messagebox "我的实用工具\nby LILIANFU\nVersion1.01"\
title:"about my utility"
)
rollout creator "茶壶"
(
group "object creator"
(
button tea "teapot"
spinner rad "Radius" range:[10,50,20] type:#integer
spinner seg "segments" range:[4,32,12] type:#integer scale:1
)
on tea pressed do
(
pot=teapot radius:rad.value
pot.name="TestPot"
pot.segs=seg.value
)
on rad changed value do
pot.radius=value
on seg changed value do
pot.segs=seg.value
)
on fu66 open do
(
addRollout lifu
addrollout creator
)
on fu66 close do
(
removeRollout lifu
removerollout creator
)
)
三、
utility fu62 "调用函数"
(
local log --申明一个局部变量log
button jian "创建茶壶"
fn hanshu=
(
for i in 1 to 3 do
teapot pos:[i*60,i*30,0]
)
--建立一个创建茶壶的函数
on jian pressed do
(
hanshu()
format "selection frabbed at %n" localTime to:log
--将localtime输出袄log文件
)
on fu62 open do log=createFile "frabulator.log"
--打开实用程序时创建名为"frabulator.log"的文件
on fu62 close do close log--关闭实用程序时关闭文件
)
四、
plugin simpleObject tower --插件超类名称
name:"Tower" --新类名
category:"my box" --UI界面显示的名称
classID:#(145345,543211)--加载场景时用来识别插件类的
--可以在监听器中利用GenclassID()的方法来得到新 唯一的ID号。
(
parameters main rollout:params
(--脚本插件将它的参数保存在参数块中
height type:#worldUnits ui:height default:0
width type:#worldUnits ui:width default:0
depth type:#worldUnits ui:depth default:0
)
rollout params "two face parameters"
(--创建一个卷展栏
spinner height "Height" type:#worldunits range:[-1000,1000,0]
spinner width "Width" type:#worldunits range:[-1000,1000,0]
spinner depth "Depth" type:#worldunits range:[-1000,1000,0]
)
on buildMesh do--创建mesh节点
(
setmesh mesh\
verts:#([0,0,0],[width,0,0],[width,depth,0],[0,depth,0])\
faces:#([3,2,1],[1,4,3])
extrudeface mesh #(1,2) (height*0.5) 40 dir:#common
-- extrudeface mesh #(1,2) (height*0.5) 50 dir:#common
)
tool create --创建对象时用鼠标控制
(
on mousePoint click do
case click of
(
1:(nodeTM.translation=gridPoint)
3:#stop
)
on mouseMove click do
case click of
(
2:(width=griddist.x;depth=griddist.y)--第二次单击鼠标时
3:(height=griddist.z)--第三次单击鼠标时
)
)--end create
)--end plugin
五、
lugin simpleObject squareTube --插件超类名称
name:"squareTube" --新类名
category:"my box" --UI界面显示的名称
classID:#(63445,55332)
(
local box1,box2
parameters main rollout:params
(--脚本插件将它的参数保存在参数块中
length type:#worldUnits ui:length default:1e-3
height type:#worldUnits ui:height default:1e-3
width type:#worldUnits ui:width default:1e-3
)
rollout params "squaretube"
(--创建一个卷展栏
spinner height "Height" type:#worldunits range:[1e-3,1e9,1e-3]
spinner width "Width" type:#worldunits range:[1e-3,1e9,1e-3]
spinner length "Length" type:#worldunits range:[1e-3,1e9,1e-3]
)
on buildMesh do--创建mesh节点
(
if box1==undefined then
(box1=createInstance box;box2=createInstance box)
box1.height=height; box2.height=height
box1.width=width; box2.width=width*2
box1.length=length; box2.length=length*2
mesh=box2.mesh-box1.mesh
)
tool create --创建对象时用鼠标控制
(
on mousePoint click do
case click of
(
1:(nodeTM.translation=gridPoint)
3:#stop
)
on mouseMove click do
case click of
(
2:(width=abs griddist.x;length=abs griddist.y)--第二次单击鼠标时
3:(height=griddist.z)--第三次单击鼠标时
)
)--end create
)--end plugin
六、
plugin textureMap Dalmatian --纹理贴图
name:"Dalmatian" --新类名,是map bowser中显示的名称
classID:#(0x7f14579d,0x5caf6eb8)
--利用监听器GenclassID()的方法来得到唯一的ID号
extends:Cellular--此插件是Cellular类的扩展类
replaceUI:true--要复位UI,原始的将不再显示
(
parameters main rollout:params
(
DColor1 type:#color default:(color 255 255 255) ui:color1
DColor2 type:#color default:(color 0 0 0) ui:color2
Dsize type:#float default:30.0 ui:dot_size--控制点的大小
Dspread type:#float default:10.0 ui:dot_spread--控制点的分布
Dsmooth type:#float default:20.0 ui:dot_smooth--控制点的滤波
on DColor1 set val do delegate.divColor1=delegate.divColor2=val
--每次参数改变都要调用这个受柄,delegate代表主贴图。
on DColor2 set val do delegate.cellcolor=val
on Dsize set val do delegate.size=val
on Dspread set val do delegate.spread=val/100.0
on DSmooth set val do
(
delegate.lowthresh=1.0-(val/50.0)
delegate.midthresh=1.0-(val/100.0)
delegate.highthresh=1.0
)
)--end params
rollout params "TeXing"
(--与参数块2各自的参数相连
colorpicker color1 "base color" align:#right fieldwidth:48
colorpicker color2 "dots color" align:#right fieldwidth:48
spinner dot_smooth "Smoothing" range:[0,100,20] align:#left fieldwidth:40 across:3
spinner dot_spread "Spread" range:[0,100,10] align:#center fieldwidth:40
spinner dot_size "Size" range:[0,100,30] align:#right fieldwidth:40
)
)--end plugin
七、
plugin RenderEffect MonoChrome
name:"MonoChrome" --新类名
classID:#(0x9e6e9e77,0xbe815df4)
(
rollout about_rollout "about..."
(
label about_label "MonoChrome Filter"
)
on apply r_image progressCB:do
(
progressCB.setTitle "MonoChrome Effect"
local oldEscapeEnable=EscapeEnable
EscapeEnable=false
bmp_w=r_image.width
bmp_h=r_image.height
for y=0 to bmp_h-1 do
(
if progressCB.progress y (bmp_h-1) then exit
pixel_line=getpixels r_image [0,y] bmp_w
for x=1 to bmp_w do
(
p_v=pixel_line[x].value
pixel_line[x]=color p_v p_v p_v pixel_line[x].alpha
)--end x loop
setPixels r_image [0,y] pixel_line
)--end y loop
EscapeEnable=oldEscapeEnable
)--end on apply
)--end plugin