MaxScript 学习笔记【有转载】
MaxScript 學(xué)習(xí)筆記【有轉(zhuǎn)載】
1. string
string類型的變量是一個(gè)數(shù)組,下列操作合法:
strName = $.name -- output: "Shemmy_03"
strName[1] --得到字符串strName第一個(gè)元素 "S"
strName[3] --得到字符串strName第一個(gè)元素 "e"
strName.count --得到字符串strName的字符個(gè)數(shù)為 9
--交換最后兩個(gè)數(shù)字的順序
num = strName.count --記下該字符串中字符的個(gè)數(shù)
temp = strName[num-1] --記下倒數(shù)第二個(gè)的數(shù)字,這里是“0”
strName[num-1]=strName[num] --將字符串中最后一個(gè)字符賦給倒數(shù)第二個(gè)數(shù)字
strName[num]=temp --將保存下來的倒數(shù)第二個(gè)的數(shù)字給字符串最后一個(gè)字符
strName -- 輸入變量名,得到:"Shemmy_30",可以看見最后兩個(gè)數(shù)字順序交換了
?
2. 相機(jī)繞圓形軌道旋轉(zhuǎn) - 路徑約束
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. ---------導(dǎo)出場(chǎng)景中的物體到指定的文件夾下-------------
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 --將場(chǎng)景中的物體導(dǎo)出到默認(rèn)的文件夾下
)
?1 將場(chǎng)景中的物體導(dǎo)出后,再導(dǎo)進(jìn)來,法向發(fā)生了變化。?
---- 導(dǎo)出obj時(shí)的選項(xiàng),optimize的normal不用勾選;
?2 貼圖導(dǎo)不出來
---- 版本的緣故,2010應(yīng)該可以。
?3 場(chǎng)景中所有的piece都導(dǎo)入到一個(gè)文件中,因?yàn)橛袝r(shí)候只需要導(dǎo)出選中的物體。
---- 先選中物體,對(duì)exportFile函數(shù)添加參數(shù)selectedOnly:true
?
4. 通過打開對(duì)話框,獲得文件名稱,而非路徑
GetSaveFileName()
GetOpenFileName()
getFiles <wild_card_filename_string>
返回指定路徑下所有文件的名稱
?
getDir
獲得默認(rèn)路徑
?
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轉(zhuǎn)化為網(wǎng)格曲面。
flagForeground <node> <boolean> -- mapped 設(shè)置前景
showclassid? --顯示物體所在的類
?
7. --------------- visibility的動(dòng)畫:-------------------------------
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. -----設(shè)置文字的關(guān)鍵幀的tangent 類型為:step
for s in shapes do
(
?for k in s.visibility.controller.keys do
?(
??k.inTangentType = k.outTangentType = #step
?)
)
?
9. view > saveActivePerspectiveView/restoreActivePerspectiveView 可以用來鎖定當(dāng)前的視圖
?
10. --------------maxScript 概念理解------------------------------
for obj in geometry do
for s in shapes do
geometry, shapes是場(chǎng)景中的兩類物體,
shape 可以用該函數(shù):convertToMesh <node>? 轉(zhuǎn)化為可編輯的網(wǎng)格,從而可以obj格式輸出;
?
與動(dòng)畫相關(guān)的概念:
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相當(dāng)于是在track view中建立了一個(gè)track,如:
a.visibility = bezier_float() --create visibility controller track in track view
對(duì)于一般屬性,如:position, scale, rotation 在track view中默認(rèn)存在,它們分別都有三個(gè)軌道:X, Y, Z, 故訪問其中一個(gè)軌道可以這樣:
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的三個(gè)軌道所有的關(guān)鍵幀的切向都設(shè)為:#step
copy, instance scene geometry的區(qū)別:
copy:復(fù)制一個(gè)物體,但是復(fù)制得到的物體與原來的物體之間是獨(dú)立的。比如修改其中一個(gè)物體的屬性,或者給它加個(gè)修改器,另一個(gè)物體仍然保持原來的。
instance: 復(fù)制一個(gè)物體,但是它得到的是原來物體的引用。即若修改其中一個(gè)物體的屬性,或者給它加個(gè)修改器,另一個(gè)物體同時(shí)發(fā)生改變。
?
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 --提取變換矩陣中的旋轉(zhuǎn)部分,只讀。 它的值與obj.rotation相同。
obj.pivot
obj.pos --
tranM.translationpart --提取變換矩陣中的平移部分,只讀。它的值與obj.pos相同。
obj.scale --
tranM.scalepart --提取變換矩陣中的放縮部分,只讀。它的值與obj.scale相同。
參考文件:
1. 在maxScript幫助文件中,找標(biāo)題為:Matrix3 Values
2. 在maxScript幫助文件中,找標(biāo)題為:Node Transform Properties
3. 在maxScript幫助文件中,找標(biāo)題為:Using Node Transform Properties
?
改變物體的變換矩陣
tranM = $.transform
tranM.row1 =?
tranM.row2 =?
tranM.row3 =
tranM.row4 =?
$.transform = tranM
?
?
?
posted on 2018-01-04 17:54 時(shí)空觀察者9號(hào) 閱讀(...) 評(píng)論(...) 編輯 收藏
總結(jié)
以上是生活随笔為你收集整理的MaxScript 学习笔记【有转载】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LUA和C#关于字符串中\0的处理
- 下一篇: U3D中的又一个坑