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

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

转载于:https://www.cnblogs.com/amixc/p/3992915.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值