我的MAXSCRIPT笔记
生活随笔
收集整理的這篇文章主要介紹了
我的MAXSCRIPT笔记
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
我的MAXSCRIPT筆記
1 1 getnodebyname "circle01" 2 2 for o in objects do 3 if o.name == "circle01" then 4 3 select $Box* – select any objects with the name box at the beginning of them. 5 4 move, scale rotate 6 move obj [x,y,z] 7 scale obj [x,y,z] 8 rotate obj (eulerangles x y z) 9 rot = eulerangles x y z --建立一個四元數(shù)旋轉(zhuǎn),可以在需要地方使用 10 5 max commands in maxscript 11 n addition to controlling modeling and animation, MAXScript scripts can invoke 3ds Max menu and toolbar commands. You do this using the "max" keyword. 12 for example: 13 max file open 14 max unhide all 15 max quick render 16 help: 17 max time ? 18 max sel ? 19 max ? 20 21 6 select 22 select obj --單選,選擇當(dāng)前,之前的被釋放 23 selectmore obj --多選 24 deselect obj 25 deselectNode node 26 27 clearselection() --清空所有 28 29 max select all 30 max select child --每調(diào)用一次,選中一個節(jié)點(diǎn) 31 7 show class "*" 32 show class "box" 33 show class "box.*" 34 8 --exit 跳出循環(huán),而不是使用break 35 9 --函數(shù) 36 function myFunc x y = () --普通函數(shù),調(diào)用: myFunc 3 4 37 function myFunc x y:20 = () --帶默認(rèn)參數(shù)的函數(shù),調(diào)用:myFunc 3或 myFunc 3 y:4 38 function myFunc x:10 y:20 = () --全默認(rèn)參數(shù)函數(shù),調(diào)用: myFunc x:3 y:4或myFunc y:4 x:3 39 10 --文件操作相關(guān) 40 getFilenamePath "c:/test/abc.txt" --"c:\test\" 41 getOpenFileName 42 caption:"Render To Texture Object Presets Open" 43 filename:(getDir #renderPresets + @"") 44 types:"Object Preset(*.rtp)|*.rtp" 45 historyCategory:"RTTObjectPresets" 46 getSavePath caption:"my title" initialDir:"$scripts" 47 file="g:\\subdir1\\subdir2\\myImage.jpg" 48 49 filenameFromPath file -- returns: "myImage.jpg" 50 getFilenamePath file -- returns: "g:\subdir1\subdir2\" 51 getFilenameFile file -- returns: "myImage" 52 getFilenameType file -- returns: ".jpg" 53 pathIsNetworkPath "c:\\temp\\test.txt" --returns: false 54 pathIsNetworkPath "\\\\someserver\\temp\\test.txt" --returns: true 55 11 --string 56 findString "Thanks for all the fish!" "all" -- returns 12 57 filterString "MAX Script, is-dead-funky" ", -" --#("MAX","Script","is","dead","funky") 58 s1=replace "1234567890" 5 3 "inserted string" --"1234inserted string890" 59 60 s ="Balerofon" 61 ss = substring s 5 3-- returns "rof" 62 ss = substring s 5 -1-- returns "rofon" 63 ss = substring s 5 100-- returns "rofon" 64 65 s="text1" 66 matchPattern s pattern:"text?"-- returns true 67 matchPattern s pattern:"T*"-- returns true 68 matchPattern s pattern:"T*"ignoreCase:false-- returns false 69 matchPattern s pattern:"s*"-- returns false 70 71 trimright "MAXScript \n " --spaces and new line trimmed 72 --"MAXScript" 73 trimright "$Teapot0911" "1234567890" --remove trailing numbers 74 --"$Teapot" 75 76 12 --Working with Values 77 -------------------------------------------------------- 78 ClassOf SuperClassOf 79 -------------------------------------------------------- 80 b Box GeometryClass 81 box GeometryClass Node 82 GeometryClass Node MAXWrapper 83 Node MAXWrapper Value 84 MAXWrapper Value Value 85 Value Value Value 86 -------------------------------------------------------- 87 88 --FOR EXAMPLE 89 --either of the following will collect all objects of class box into variable allBoxes : 90 allBoxes=for obj in $* where (isKindOf obj box) collect obj 91 allBoxes=#() 92 for obj in $* do (if classOf obj == box then append allBoxes obj) 93 94 --the following function limits the choices to shape objects: 95 fn shape_filt obj = isKindOf obj Shape 96 13 --數(shù)組相關(guān)操作 97 --賦值 98 arr = #() 99 append arr 3 100 append arr "hello" 101 arr[3] = 12.2 102 103 --遍歷 104 for o in arr do print o 105 for i=1 to arr.count print arr[i] 106 107 14 --maxscript language reference -collections 108 --ObjectSets represent the main scene object categories in 3ds Max. 109 objects --all the objects 110 geometry --the standard 3ds Max categories... 111 lights 112 cameras 113 helpers 114 shapes 115 systems 116 spacewarps 117 selection --the current selection 118 119 --for example 120 for s in shapes do print s 121 for i=1 to geometry.count do print geometry[i] 122 15 --rootscene 與 rootnode 123 rootNode 124 ------------------------------------------------------------------------------------------ 125 Contains a Node value that defines the root node of the scene. 126 The root node does not physically exist in the scene, rather it is a special node that is the parent node of all nodes that are not linked to another node. 127 The scene objects can be enumerated by accessing the children property of the root node. 128 A run-time error is generated if you try to perform other node operations on the root node. 129 130 rootScene 131 ------------------------------------------------------------------------------------------ 132 Represents the scene root in scripts and Macro Recorder output. 133 The subAnims of rootScene include the node hierarchy, the Material Editor, Track View, Scene Material Library etc 134 135 --遍歷場景中最頂級的物體 136 for o in rootNode.children do 137 ( 138 print o 139 print o.parent --undefined 140 ) 141 142 --注意,MAX場景是以樹結(jié)構(gòu)來組織的,一個場景可以多個不相連的子樹,也就是有多個根結(jié)點(diǎn) 143 --這些子樹都以rootnode為根,但parent卻是undefined,如上 144 145 --導(dǎo)出FBX模型與動畫 146 --1,導(dǎo)出模型和骨骼層級 147 --注意:骨骼層級必須和模型一起導(dǎo)出,否則對它設(shè)置動畫無效果,這個很容易忽視 148 149 --等價于 select geometry 150 for o in objects do 151 ( 152 cls = classof o 153 if cls == Biped_Object or cls == BoneGeometry or cls == PolyMeshObject then 154 (--選擇所有網(wǎng)格,和所有骨骼(biped_object, boneGeometry) 155 selectmore o 156 ) 157 158 ) 159 160 --2,導(dǎo)出不帶模型的純動畫 161 for o in objects do 162 ( 163 cls = classof o 164 if cls == Biped_Object or cls == BoneGeometry then 165 (--所有骨骼(biped_object, boneGeometry) 166 selectmore o 167 ) 168 ) 169 16 --material 170 ------------------------------------------------------------------------------------------ 171 --The following will render the diffuse map assigned to the material of object $foo 172 -- to a bitmap of size 640x480 and save it to the file "foodif.bmp" 173 ------------------------------------------------------------------------------------------ 174 rm = renderMap $foo.material.diffuseMap size:[640,480] \ 175 fileName:"foodif.bmp" 176 save rm 177 close rm 178 179 ------------------------------------------------------------------------------------------ 180 --材質(zhì),每個模型只有一個material,但這個material可以是單材質(zhì)或多重材質(zhì) 181 --每個材質(zhì)可以有多個貼圖,對應(yīng)各種顏色: 182 --diffusemap :漫反射 183 --不透明貼圖:不透明度 184 --高光貼圖:高光顏色 185 --光澤度貼圖:光澤度 186 --自發(fā)光貼圖:自發(fā)光 187 --凹凸貼圖,反射貼圖,折射貼圖,置換貼圖。。。。 188 ------------------------------------------------------------------------------------------ 189 showTextureMap $foo.material $foo.material.diffuseMap on 190 tm = checker() 191 mat = standardMaterial diffuseMap:tm 192 mm = multimaterial() --多重材質(zhì) 193 mm[1] = mat 194 $box01.material = mm 195 showTextureMap mm[1] tm on 196 197 getnumsubmtls --獲取子材質(zhì)數(shù)量 198 199 ----------------------------------------------------------- 200 --如何獲取模型上的貼圖 201 b = box() 202 b.material.diffuseMap.filename --或 203 b.material.diffuseMap.bitmap 204 17 --show properites 205 b = box() 206 showproperties b.material 207 18 --external command 208 --注意,DOS命令是WINDOWS網(wǎng)格的分割符,是下坡線,maxscript是上坡線,必須轉(zhuǎn)換 209 doscommand "copy f:\\abc.fbx f:\\test" --將 f:\abc.fbx拷貝到f:\test文件夾下 View Code?
posted on 2018-01-31 11:13 時空觀察者9號 閱讀(...) 評論(...) 編輯 收藏
總結(jié)
以上是生活随笔為你收集整理的我的MAXSCRIPT笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AnimatorController即动
- 下一篇: 【转】正则表达式简介及在C++11中的简