[Closed] getting newly added vertex
(
gc()
delete objects
obj = converttopoly (geosphere segments:2 smooth:off)
offset = 10
numverts = obj.numverts
numfaces = obj.numfaces
obj.tesselateBy = 0
norms = for f=1 to obj.numfaces collect (polyop.getfacenormal obj f) * offset
polyop.tessellateByFace obj #all
obj.selectedverts = #{obj.numverts-numfaces+1..obj.numverts}
polyop.movevert obj #selection norms
for v in #{1..numverts} do
(
d = normalize (polyop.getvert obj v - obj.center) * offset * 2
polyop.movevert obj v -d
)
)
let’s make anything cool even if it’s senseless
Thanks again guys. Your scripts are great. Starting the count from the last face instead of the first is a great idea, simple when you know it, but I guess hard to think about it My problem is that I want to be able to tessellate some of the faces, not all of them, so even this way it doesn’t work for .tesselateBy = 1. It looks that the best way is first to define in one loop the faces that I actually want to tessellate and collect them in a list, and then tessellate all of them. Or the process I described, with which I still have some issues, but I am getting there.
As to what it is for… well, I guess it is about “make anything cool even if it’s senseless”. Well, not exactly, but it doesn’t have any specific aim as to the shape yet. The general aim is to make models that will be eventually 3d printed and will become part of jewellery/clothing. But the project is just starting, so I am looking for interesting shapes. Tessellation can give some very complex results, that’s why I am looking at it. Look at what this guy is doing. I don’t think that 3ds can handle that amount of polygons of course, but for now I am just exploring ideas…
so… these processes work fine for tessellateBy = 1, but if tessellateBy = 0 then I have some problems if I don’t want to tessellate all the faces (in my previous post I meant to say “it doesn’t work for .tesselateBy = 0”) Consider the script posted by PolyTools3D edited this way:
(
gc()
delete objects
obj = converttopoly (box lengthsegs:1 widthsegs:1 heightsegs:1)
polyop.meshsmoothbyface obj #all
offset = 10
obj.tesselateby = 0
for j = obj.numfaces to 1 by -1 do
(
if ((random 0 1) == 0) do
(
normal = polyop.getfacenormal obj j
obj.selectedfaces = #{j}
obj.editablepoly.tessellate #face
polyop.movevert obj obj.numverts (normal*offset)
)
)
)
when the script tries to tessellate a face that borders with one that is already tessellated, then it creates more faces than needed (that is actually true also for PolyTools3D’s original script for tessellateBy=0). So what I do is collect all the faces that I want to tessellate in one list and then tessellate them in one go like this:
obj.selectedFaces = listOfFacesToTessellate
obj.EditablePoly.tessellate #face
which works great for the tessellation. But then I have a hard time finding the vertex in the center of the face that I want to move, because when tessellateBy = 0 you as many new vertices as the edges of each face + 1 in the center. So I am trying to move those of the new vertices that have more that two edges, but I don’t see any way to get the number of edges that end in a vertex (I think I will make a new post for that part). Any other ideas?
look at my example above. it tessellates by edge all specified faces (in my example #all, but you can specify a list).
(
delete objects
p = plane width:100 length:100 widthsegs:10 lengthsegs:10
converttopoly p
faces = #{12..19, 22..29, 32..33, 38..39, 42..43, 48..49, 52..53, 58..59, 62..63, 68..69, 72..79, 82..89}
p.tesselateBy = 0
norms = for f in faces collect (polyop.getfacenormal p f) * 10
polyop.tessellateByFace p faces
verts = #{p.numverts-faces.numberset+1..p.numverts}
polyop.movevert p verts norms
update p
)
Here is another example:
(
-- Create a test object
gc()
delete objects
obj = converttopoly (torus())
-- Collect some random faces
faces = #{}
for j = 1 to obj.numfaces by 3 do faces[random 1 obj.numfaces] = true
obj.selectedfaces = faces -- Just for visualization
normals = for j in faces collect polyop.getfacenormal obj j
obj.tesselateby = 0
polyop.tessellatebyface obj faces
verts = for j = obj.numverts - normals.count+1 to obj.numverts collect j
obj.selectedverts = verts as bitarray -- Just for visualization
offset = 10
for j = 1 to verts.count do polyop.movevert obj verts[j] (normals[j]*offset)
)
mmm, that is working perfectly… I don’t understand the ‘verts = #{p.numverts-faces.numberset+1…p.numverts}’ part, but it is too late here, I have to test it in my script tomorrow!
thanks again
newly created ‘center’ verts are last N verts after creation where N is the number of faces used for tessellation
Oh… I see now. I assumed that whenever a face is tessellated all new vertices in relation to that face are added in the end of the vertex list, then the vertices of the next face etc. Instead it adds the vertices on the edges first, and then all the central vertices. I guess I should never assume things
Thanks again guys!