QQ聊天

MaxScript创建十二面体的代码

有网友问我如何使用脚本来创建十二面体,因为时间不多,所以只是用了顶点列表的方式。代码如下

View Code
plugin simpleObject DodecahedronGeometryPlugin
name:"Dodecahedron"
classID:#(0x1e73aacc, 0x54773e26)
category:"ScriptedGeometry"
(
parameters main rollout:params
(
size type:#worldUnits ui:size default:0
)

rollout params "Parameters"
(
spinner size "size" type:#worldunits range:[0,1000,10]
)

on buildMesh do
(
num = 1.61803
vertexList = #(
[1/num,num,0],[-1/num,num,0],[1/num,-num,0],[-1/num,-num,0],
[num,0,1/num],[-num,0,1/num],[num,0,-1/num],[-num,0,-1/num],
[0,1/num,num],[0,-1/num,num],[0,1/num,-num],[0,-1/num,-num],
[1,1,1],[1,-1,1],[1,1,-1],[-1,1,1],[-1,-1,1],[-1,1,-1],[-1,-1,-1],[1,-1,-1]
)
for i = 1 to vertexList.Count do vertexList[i] = vertexList[i] * size
faceList = #(
#(14,10,17,4,3),
#(6,8,19,4,17),
#(9,16,6,17,10),
#(5,13,9,10,14),
#(14,3,20,7,5),
#(3,4,19,12,20),
#(8,18,11,12,19),
#(16,2,18,8,6),
#(7,20,12,11,15),
#(2,1,15,11,18),
#(13,5,7,15,1),
#(9,13,1,2,16)
)

setMesh mesh verts:vertexList
for faceSet in faceList do
(
meshop.createPolygon mesh faceSet
)
)

tool create
(
on mousePoint click do
case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
on mouseMove click do
case click of
(
2: size = length gridDist
)
)

)

运行后就会在这里出现新的几何体

posted @ 2011-11-08 16:58  SITT  阅读(720)  评论(0编辑  收藏  举报
QQ聊天