MAXScript笔记_Function函数

语法:
function <函数名> <参数1> <参数2>=(expr)

实例1:

function createSphere count growth =
(
for i in 1 to count do
sphere radius:(i*growth) pos:[i^2*growth,0,0] 
)

 函数的调用:

createSphere 5 10

 实例2:有返回参数

function cellMaterial baseColor cellSize = 
(
local mtl = standardMaterial specularLevel:55 glossiness:35,
map = cellular cellColor:baseColor size:cellSize fractal:on
mtl.diffuseMap = map
return mtl --返回该材质
)
$Sphere01.material = cellMaterial red 25
$Sphere02.material = cellMaterial blue 50
$Sphere03.material = cellMaterial red 25
$Sphere04.material = cellMaterial blue 5

该材质函数具有返回值,因此在函数调用时可以做右值赋予某一个变量

posted @ 2014-09-25 15:34  amixc  阅读(594)  评论(0编辑  收藏  举报