Render.ru

Как отDetach'ить все цельные элементы от объекта

Alteste

Активный участник
Рейтинг
5
#1
Подскажите, пожалуйста, есть ли такой скрипт, который бы позволял отсоединить отдельными объектами все цельные элементы (Elements) от одного объекта. Например у меня есть один объект в который заатачены множество других, так мне нужно сделать Detach всех элементов в отдельные объекты с отцентрованной привязкой (Pivot).
 

Savin Denis

Модератор форума
Команда форума
Рейтинг
138
#2
Код:
-- Detach Elements 

obj = $

totalMesh = editable_mesh transform:(obj.transform)

-- Get the complete mesh from the mesher
totalMesh.mesh = obj.mesh

i = 0
-- Repeat while there are still faces in the mesh 
while totalMesh.numfaces != 0 do
(

-- Get the mesh element the first face belongs to 
el = meshop.getelementsusingface totalMesh #{1}

fragmentMesh = editable_mesh transform:(obj.transform) name:(obj.name + "_element_" + (i as string) )

-- Detach the faces of the element 
tMesh = meshop.detachFaces totalMesh el delete:true asMesh:true

-- Set the mesh of the fragment Emesh to the element 
fragmentMesh.mesh = tMesh

-- Update the fragment Emesh 
update fragmentMesh

-- Get the center of the fragment mesh 
meshCenter = fragmentMesh.center

-- Move the pivot of the fragment to the original center 
-- of the fragment
fragmentMesh.pivot = meshCenter

update fragmentMesh

-- Increase the counter 
i += 1
)

if isValidNode totalMesh do delete totalMesh
 
Сверху