1. string
string类型的变量是一个数组,下列操作合法:
strName = $.name -- output: "Shemmy_03"
strName[1] --得到字符串strName第一个元素 "S"
strName[3] --得到字符串strName第一个元素 "e"
strName.count --得到字符串strName的字符个数为 9
--交换最后两个数字的顺序
num = strName.count --记下该字符串中字符的个数
temp = strName[num-1] --记下倒数第二个的数字,这里是“0”
strName[num-1]=strName[num] --将字符串中最后一个字符赋给倒数第二个数字
strName[num]=temp --将保存下来的倒数第二个的数字给字符串最后一个字符
strName -- 输入变量名,得到:"Shemmy_30",可以看见最后两个数字顺序交换了
2. 相机绕圆形轨道旋转 - 路径约束
NowTime +=duration
animate on at time NowTime
(
cirCenter = $Camera01.target.pos
camPath = circle() --圆形轨道
camPath.center = cirCenter
camPath.center.z = $Camera01.pos.z --set path center
camPath.radius = distance cirCenter $Camera01.pos --set path radius
pc = path_constraint() --create a path constraint
pc.path = camPath --assign current path
$Camera01.pos.controller = pc -- attach obj with path
)
3. ---------导出场景中的物体到指定的文件夹下-------------
for obj in geometry do
(
select obj
exportFile ("E://Shemmy//Shemmy_Research//3DPuzzle//Oc29_animationSample_script//animation_text_list _withMtl//" + getFilenameFile (obj.name)+".obj") #noPrompt selectedOnly:true --将场景中的物体导出到默认的文件夹下
)
?1 将场景中的物体导出后,再导进来,法向发生了变化。
---- 导出obj时的选项,optimize的normal不用勾选;
?2 贴图导不出来
---- 版本的缘故,2010应该可以。
?3 场景中所有的piece都导入到一个文件中,因为有时候只需要导出选中的物体。
---- 先选中物体,对exportFile函数添加参数selectedOnly:true
4. 通过打开对话框,获得文件名称,而非路径
GetSaveFileName()
GetOpenFileName()
getFiles <wild_card_filename_string>
返回指定路径下所有文件的名称
getDir
获得默认路径
5. material:
--------------get and set material----------------------------
<node>.material Material default: undefined
Get or set the object's material.
---------------- meditMaterials -------------------
meditMaterials
Contains a virtual array of materials and root level maps corresponding to the slots in the material editor. You can access material editor materials and root level maps via array indexing and iterate over them in a for loop. The array can be indexed by number to specify slot number or name or string to select by material and root level map name.
eg:
$foo.material = meditMaterials[1]
meditMaterials["foo mat"].diffuse = red
for m in meditMaterials do print m.diffuseMap
meditMaterials[1]=standard()
print meditMaterials.count -- number of slots
6.
convertToMesh <node>; 可以将shape转化为网格曲面。
flagForeground <node> <boolean> -- mapped 设置前景
showclassid --显示物体所在的类
7. --------------- visibility的动画:-------------------------------
a.visibility = bezier_float() --create visibility controller track
at time (TheCurrentFrame + 1.0) a.visibility.controller.value = 1.0
at time (TheCurrentFrame) a.visibility.controller.value = 0.0
或者:
curObj.visibility = bezier_float()
k = addNewKey curObj.visibility.controller time1
k.value = 1
--k.inTangentType = #step
k = addNewKey curObj.visibility.controller time2
k.value = 0
8. -----设置文字的关键帧的tangent 类型为:step
for s in shapes do
(
for k in s.visibility.controller.keys do
(
k.inTangentType = k.outTangentType = #step
)
)
9. view > saveActivePerspectiveView/restoreActivePerspectiveView 可以用来锁定当前的视图
10. --------------maxScript 概念理解------------------------------
for obj in geometry do
for s in shapes do
geometry, shapes是场景中的两类物体,
shape 可以用该函数:convertToMesh <node> 转化为可编辑的网格,从而可以obj格式输出;
与动画相关的概念:
All animation in 3ds max is implemented using one of the many controller classes accesible in the track view and montion panel.
重要概念:
cotroller calsses
track view, motion panel
cotroller相当于是在track view中建立了一个track,如:
a.visibility = bezier_float() --create visibility controller track in track view
对于一般属性,如:position, scale, rotation 在track view中默认存在,它们分别都有三个轨道:X, Y, Z, 故访问其中一个轨道可以这样:
b.rotation.controller[1].controller.keys -- all keys on X rotation track
比如这样的操作:
for i = 1 to 3 do
(
for k in b.rotation.controller[i].controller.keys do
(
k.inTangentType = k.outTangentType = #step
)
) --rotation的三个轨道所有的关键帧的切向都设为:#step
copy, instance scene geometry的区别:
copy:复制一个物体,但是复制得到的物体与原来的物体之间是独立的。比如修改其中一个物体的属性,或者给它加个修改器,另一个物体仍然保持原来的。
instance: 复制一个物体,但是它得到的是原来物体的引用。即若修改其中一个物体的属性,或者给它加个修改器,另一个物体同时发生改变。
user interface items: command panels, rollouts, dialogs, commands, windows, viewport
By switching from one tabbed window to another in command panesl, different commands then become available to the user.For example, mesh editing commands are only available from the modify panel.
SetCommandPanelTaskMode [mode:] <panel name> --switch to current command panel
GetCommandPanelTaskMode() --get currently opened command panel
command panel names,such as #create, #modify, #hierarchy...
Understanding objects and classes
classOf obj/class name
11. maxScript 变换矩阵
tranM = obj.transform --得到物体的变换矩阵
obj.objecttransform --得到物体的变换矩阵,只读
obj.rotation
tranM.rotationpart --提取变换矩阵中的旋转部分,只读。 它的值与obj.rotation相同。
obj.pivot
obj.pos --
tranM.translationpart --提取变换矩阵中的平移部分,只读。它的值与obj.pos相同。
obj.scale --
tranM.scalepart --提取变换矩阵中的放缩部分,只读。它的值与obj.scale相同。
参考文件:
1. 在maxScript帮助文件中,找标题为:Matrix3 Values
2. 在maxScript帮助文件中,找标题为:Node Transform Properties
3. 在maxScript帮助文件中,找标题为:Using Node Transform Properties
改变物体的变换矩阵
tranM = $.transform
tranM.row1 =
tranM.row2 =
tranM.row3 =
tranM.row4 =
$.transform = tranM