--随机树角度
oArray = $selection as array
clearSelection()
for i in oArray do
(
--随机角度
angleValue = (random 5 30) *3
--format "角度:% /n" angleValue
rotate i (angleaxis (random 0 90) [0,0,1])
)
--合并树递归方法
function attachTree oArray isRandHeight =
(
if oArray.count < 2 then
(
return "选择合并数量必须大于等于2"
)
step = 50
if oArray.count>step then
(
oArray2 = getCurrentSelection()
for i =1 to oArray.count by step do
(
j = i
k = i+step
l = i
while (l+1)<k do
(
--format "TTT:% , % /n" l oArray.count
if l>=oArray.count then
(
exit
)
oArray[j].attach oArray[l+1] oArray[j]
format "第一组合并进度:% , % ,%/n " l k oArray.count
l+=1
)
--print isRandHeight
if isRandHeight then
(
max modify mode
modPanel.setCurrentObject oArray[j]
subOjbectlevel = 1
--当前选择的点总数
faceCount = polyop.getNumVerts oArray[j]
--format "顶点总数:% /n" faceCount
for i = 0 to (faceCount-8) by 8 do
(
--随机高度值
heightValue = (random -.5 .5)*3
--format "高度值:% ,i 值:%/n" heightValue i
vertArray = #{i+3,i+4,i+7,i+8}
oArray[j].EditablePoly.SetSelection #Vertex vertArray
move oArray[j].selectedverts [0,heightValue,0]
)
modPanel.setCurrentObject oArray[j].baseObject
clearSelection()
)
--isRandHeight = false
append oArray2 oArray[j]
)
--print oArray2.count
--print oArray2
attachTree oArray2 false
)
else
(
--print oArray
oArrayCount = oArray.count
for i = 2 to oArrayCount do
(
format "第二组合并进度:% ,%/n" i oArray.count
oArray[1].attach oArray[i] oArray[1]
)
)
select oArray[1]
)
--合并树
attachTree oArray true