if mybox.height == 10 then mybox.width = 20 else mybox.width = 10 mybox.width = if mybox.height == 10then20else10--类似C++ 的 ?:
==
1 2 3 4 5 6 7 8 9 10 11
== --equal to
!= --not equal to
> --greater than
>= --greater than or equal to
< --less than
<= --less than or equal to
for
1 2 3
for var = value to array.count by -1 where (condition) do ( )
创建一堆box
1 2 3 4 5 6 7
mybox =box() for i = 1 to 10do ( copy_box=copy mybox copy_box.pos=[i*30,0,0] copy_box.wirecolor=[i*25,i*50,50] )
数组
1 2 3 4 5 6 7 8 9 10
arr = for i =1 to 5 collect i --#(1, 2, 3, 4, 5) arr2=#(1,2,3,555,44) --#(1, 2, 3, 555, 44) a = #()--空数组 a = #(1,2,3) joint a #(4,5,6)-- a数组加入4,5,6 a.count --数量 c=($box* as Array)+($Sphere* as Array) --把所有box和spehre名称的作为数组并且相加 append c ($Cone* as Array) --把所有Cone作为数组成员添加到c
( rollout rename_rollout "Enter New Base Name" ( edittext base_name "" button rename_them "RENAME" On rename_them pressed do ( if base_name.text!=""do ( for i in selection do i.name=uniquename base_name.text --uniquename保证不重名 ) ) ) CreateDialog rename_rollout 25050 )
macroscript MoveAllGeometryToLand category: "HowTo" ( fn g_filter o = superclassof o == Geometryclass fn getZ node_land= ( local testray=ray [0,0,-1000] [0,0,1] print(intersectRay node_land testray) )
on isEnabled return selection.count == 1 on Execute do ( target_mesh = pickObject message:"Pick Target LandMesh:" filter:g_filter if isValidNode target_mesh then ( undo "MoveAllGeometryToLand" on ( for i in geometry where((g_filter i)and i!=target_mesh) do ( local point=getZ selection[1] if point!=undefined then i.pos.z=point.pos.z
fn getTheVertexNormal processObject vertexIndex = ( normal = [0.0,0.0,0.0] if classof processObject.baseobject == Editable_Poly then ( vertexPolygons = polyOp.getFacesUsingVert processObject vertexIndex for i in vertexPolygons do ( normal+=in coordsys world polyOp.getFaceNormal processObject i ) ) else ( normal= getNormal processObject vertexIndex ) normal=normalize normal normal )
--遍历模型所有顶点 for j=1 to numberofVerts do ( oldnormal=((((normalize (getTheVertexNormal currentMorphTarget j))*[1.0,-1.0,1.0])+1.0)*0.5)*255.0 append CurrentMorphTargetNormalArray oldnormal originalVertPos=originalMeshVertPositions[j] currentModelVertPos=getVertPos currentMorphTarget j --得到顶点位置 if (captureAbsolutePositions.checked) then ( currentOffset=currentModelVertPos ) else ( currentOffset=(currentModelVertPos-originalVertPos)--如果不是绝对位置就要减去本地坐标来得到世界坐标 ) --反转Y轴 currentOffset=[currentOffset[1],-1.0*currentOffset[2],currentOffset[3]] currentOffset*=255.0--转成颜色 append currentMorphVertexOffsetArray currentOffset )
1 2 3 4 5 6 7 8 9 10
--从系统方法得到顶点位置 fn getVertPos model index= ( pos=[0,0,0] if classof model.baseobject == editable_poly then ( pos=in coordsys world polyop.getVert model index ) else ( pos=in coordsys world getVert model index ) pos )