MAXScript101 3.2_Working With Controllers
-- Add & Delete key frames, manipulate key parameter
1. controller
【译】The track property is a simple synonym for controller. If an animatable property does not yet have a controller assigned, the isAnimated property returns false and the controller, track, and keys properties return undefined.
轨道(track)属性是控制器(controller)的别名。如果一个可动画属性还没有赋予控制器的话,<property>.isAnimated 返回false, controller, track, keys 返回undefined。
-- Controller Operation (1): assign a controller to a variable, any animatable property has controller
c = $Box01.height.controller -- return: undefined
-- Controller Operation (2): construct a path_constraint controller
pc = path_constraint follow: true bank: true path: $line01
$Box01.pos.controller = pc
-- Controller Operation (3): access and adjust controllers paramters
$Box01.pos.controller.bankAmount -=0.25
-- Controller Operation (4): copy controller instance using =, or copy
$Box01.scale.controller = $Box02.scale.controller
if $Box01.height.controller == undefined then
(
$Box01.height.controller = noise_float frequency: 0.74 fractal: false
$Sphere01.radius.controller = copy $Box01.height.controller
)
2. get keys
MAXScript有三类关键帧:
Bezier
TCB
Barycentric Morph
key有三个属性值:
.time -- which holds the time of the key
.value -- which holds the keys value, and
.selected -- which is true or false if the key is selected or not
eg.
animate on for i in 0 to 100 by 20 do
at time i
(
scale $Sphere01 [1.1, 1.1, 1.1]
)
keys = $Sphere01.scale.controller.keys -- #keys(0f, 20f, 40f, 60f, 80f, 100f)
keys[1] -- #Bezier Scale key(1 @ 0f)
-- can print or assign the property of keys
keys[1].time -- 0f
keys[1].value -- [1.77156,1.77156,1.77156]
keys[1].selected -- false
for k in keys do format "% at %/n" k.value k.time
--[1.77156,1.77156,1.77156] at 0f
--[1.94872,1.94872,1.94872] at 20f
--[2.14359,2.14359,2.14359] at 40f
--[2.35795,2.35795,2.35795] at 60f
--[2.59374,2.59374,2.59374] at 80f
--[2.85312,2.85312,2.85312] at 100f
3. 实例
1)物体的上方(即它的z轴方向)有一个圆形轨道;圆心为物体中心上方(与相机等高),半径为摆好初始位置时,相机的位置到圆心的距离;
2)在相机进行step 时,target位置始终在物体中心位置,相机step的位置为圆形轨道的lengthInterp点
3)该函数的使用比较一般性,当stepsNum个数较大时,变成了相机的旋转
4)lengthInterp点的个数等于关键帧的个数,在这里是stepsNum
4. 有关time, key, controller 操作,详细查询MAXScript Reference 相关主题:
. Controller Key Functions: eg. addNewKey ...
. Controller Time Functions: eg. getTimeRange ...
. Controller Common Properties, Operators and Methods: eg. <controller>.keys ...
. Controller Out-Of-Range Functions: eg. getBeforeORT...