[Closed] Another Mini Script Challenge
Аnd probably, you don’t want to share it?
Marius Silaghi have awesome scripts,
very useful but all his tools are commercial.
We all understand what’s the goal but it’s not so easy to achieve.
By the way, you post a good topic:thumbsup:
I will, but It wouldn’t be much of a challenge if I did it straight away.
i actually tried this a while back…
not perfect but does the job !?
delete obj
obj = convertToPoly (Box length:50 width:50 height:50 lengthsegs:5 widthsegs:5 heightsegs:5)
obj.surfSubDivide = on
obj.iterations = 3
convertToPoly obj
select obj
fn revSub obj = try (
specialEdges = for i = 1 to (polyOp.getNumVerts obj) where ( ( (polyop.GetEdgesUsingVert obj i).numberset ) == 4) collect i
subobjectlevel = 1
polyop.setVertSelection obj specialEdges
-- ::RappaTools3.Edgefunc ctrl:false shift:true -- to outer edges -- or
vertSel = polyOp.getVertSelection obj -- or
vertEdges = polyOp.getEdgesUsingVert obj vertSel -- or
edg = for i in vertEdges where ((polyOp.getVertsUsingEdge obj i) * vertSel).numberSet == 2 collect i -- or
polyOp.setEdgeSelection obj edg -- or
subobjectlevel = 2 -- or
max select invert -- or
macros.run "PolyTools" "DotRing"
obj.SelectEdgeLoop ()
max select invert -- or
obj.ConvertSelection #Edge #Vertex
obj.Remove selLevel:#Edge
obj.Remove selLevel:#Vertex
update $
)
catch ()
/*
for i=1 to 3 do ( revSub obj )
http://remusjuncu.com/
*/
(max 2012)
nice but no cigar, only seemed to work on quads, tried it on a subdivided GeoSphere and it didn’t work, it also didn’t work on faces with more the 4 sides.
here was my solution to the problem, it was used for making LOD terrain cells that still matched the higher detail LOD at the boundaries (code for this is removed for clarity (and it was a bit scruffy))
fn DeconstructSubdivisionLite obj =
(
f = 1;
edges = #{};
getvuf = polyop.getVertsUsingFace;
numfaces = polyop.getnumfaces obj;
while f < (numfaces - 2) do
(
-- this is the real trick to the whole routine, if this returns an empty bit array
-- the face is not the start of the subdivided face, if it returns a valid bit array
-- then the vert returned is the center vert of the subdivided face and the face is
-- the first face of the subdivided face. Getting the number of faces used by this vert
-- tells you how many sides the original face had.
vert = getvuf obj f * getvuf obj (f+1) * getvuf obj (f+2);
-- skip over "invalid" faces
if vert.numberSet == 0 then
f += 1;
else
(
-- collect the interior edges
edges += polyop.getEdgesUsingVert obj vert;
-- step to next "face" of the original mesh
f += (polyop.getFacesUsingVert obj vert).numberSet;
)
)
-- remember the verts the edges we collected are using
verts = polyop.getVertsUsingEdge obj edges;
-- cull the interior edges we collected
polyop.setEdgeSelection obj edges;
obj.Remove selLevel:#Edge;
-- get the remaining verts afer the center verts are removed, you've got to love bitarrays
verts *= #{1..polyop.getnumverts obj};
-- cull the verts
polyop.setVertSelection obj verts;
obj.Remove selLevel:#Vertex;
)
Hi claude666,
very nice approach.
Here’s what I noticed
I tested your code on a simple box object, with 10x10x10 segs
Then i select all faces and meshsooth them two times.
Now i run the code twice and it’s works as expected.
Boundaries are changed but it does not matter.
If i run the code again, nothing happens which is good
because i use meshsmooth operation two times only.
Now i test this on GeoSphere.
I apply the same procedure as I was on the box,
but when i run third time your code
all triangular polygons are deleted exept one.
Why it happens?
interesting, it was never designed to work on undivided geometry, and the way the geosphere is constructed from tris; that every 3 (1,2,3) faces share a vert means it passes the test, you could add an additional test to exclude any 3 sided faces.
You’re right.
When apply epoly meshsmooth operation (not modifier)
all triangles becom quads. And with your code i return quads to triangles.
Then i need to exclude any 3 sided faces from calculation.
By the way, thanks for sharing this nice function.
the thing that you are trying to do calls Reverse Catmull-Clark Subdivision. here is a good reference:
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CGIQFjAA&url=http%3A%2F%2Fwscg.zcu.cz%2Fwscg2006%2FPapers_2006%2FFull%2FB89-full.pdf&ei=5umoT6XxIISJgwfgoN20AQ&usg=AFQjCNGpr5JeDAgiAfMamkYY06JQbNGYAg&sig2=br5mkeQg4RTgBG8vd1b9AQ
it should be possible to find a c++ code of this algorithm. it’s not a secret.
Hi Denis.
Problem which we now discuss is shown on the page6
Figure 10. Reverse subdivision of the cat mesh at
the first subdivision level.