Home Technical Talk

Geo-loop

1
polycounter lvl 19
Offline / Send Message
poopinmymouth polycounter lvl 19
Anyone familiar with Geo poly from polyboost? You select a face, of any number of sides, hit it, and it makes the poly perfectly planar and equi-angular. So an 8 sides face becomes a perfect octagon. This is handy for extruding perfect cylinders that will smooth into perfect cylinders.

But, I want a geo loop tool. Let's say you have a tree branch, and you create it out of an 8 sided cylinder, but you want the tip to be 4 sides, and have it taper down in between. After collapsing edges, you're left with an odd cross section that isn't as round as it could be. I want a geo loop tool that let's you select an edge loop, and it will make it planar and equi angular.

Does one exist? If not, will a kind soul attempt to create one?

Replies

  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    would you mind making a screenshot for this, i dont get it
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Yeah I think I know what you mean, but a quick screenshot/paintover would definitely help illustrate what you want out of this.

    I thought you were a technical artist anyway, can't you script this? :D
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    In Maya, sure - piece of cake. (you didn't mention what software....)
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    MoP wrote: »
    Yeah I think I know what you mean, but a quick screenshot/paintover would definitely help illustrate what you want out of this.

    I thought you were a technical artist anyway, can't you script this? :D

    Not anymore, I'm a level artist, and the second my title changed, all my skills disappeared!

    Wharghoul, in Max.
  • mLink
    Offline / Send Message
    mLink polycounter lvl 10
    Whargoul wrote: »
    In Maya, sure - piece of cake. (you didn't mention what software....)

    Polyboost is a Max exclusive plugin.
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    While I can't speak much to the script you are looking for and far be it from me to teach the poopmeister, I can say that I might approach this differently...?

    I would remove the faces of your branch cylinder so that you only have the two end-cap polygons, then border select them and use the bridge tool. From here you can use the bridge options to modify segments, taper, bias, etc to get a really nice transition from an 8-sided polygon a 4-sided one, that has a good organic curve to it and everything. You can even throw some twist in there if you like.

    Depending on your branch you might do this in two sections or per sub-branch or something, but using this basic technique and some soft-select afterwards I'd think you could get some decent results pretty quickly.

    also HELL YEAH LEVEL ARTIST WELCOME TO THE CLUB BUDDY.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I need to post an image, I'll do it shortly. That would work Cman, but it would take a lot longer than having a script.
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    Yeah, I was just being an ass. Most people don't say what they want it for (even though it's assumed it's Max). I just like quoting "what software" because so many noobs some in here and ask a question, and people always have to ask what software in the next post. And poop is such a noob :)

    Also, he could have been referencing a tool, and asking for something like that, ie. XSI has this cool mumbojumbo tool, I want something similar in Lightwave, can anyone help?

    But the idea is cool, and I probably will make one for Maya - the math seems fairly easy, except for a little bit of "best fit" stuff. I already have one I wrote for fitting things to the best plane (great for capping off a wrist for example) - but adding something to "cylinderize" it shouldn't be too tough.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Gotta run, but here's what I mean:

    geo_edge.jpg
  • Jesse Moody
    Offline / Send Message
    Jesse Moody polycounter lvl 18
    Does loops set flow work? I know I have had some luck and also not so much luck with that method.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Something my counterpart here at SD wrote for Maya was an "un-bevel" script which you'd use instead of Collapse in this case - basically it finds the incoming edge angles of the edge you're trying to collapse, and reconstructs the "correct" vertex position from this, and collapses to that position, retaining the volume of the shape.

    It's a python script, so maaaaybe portable to Max fairly easily, but I dunno if I have the time/inclination to look into that yet :)
  • Mark Dygert
    Geo Loop? That would be handy. +1
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    That would be a nifty tool. Sometimes I will ask our artists to up res a cylindrical model like a barrel which looks too faceted. It would be great if they could just add the extra edge loops click the button and have a perfect cylinder at a higher res. Cody let me know when you have finished writing this.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    If you maya users get this before me when I went and made that jpeg, i will shake my fist at you over the internet SO HARD!!!!
  • Jesse Moody
    Offline / Send Message
    Jesse Moody polycounter lvl 18
    malcolm wrote: »
    That would be a nifty tool. Sometimes I will ask our artists to up res a cylindrical model like a barrel which looks too faceted. It would be great if they could just add the extra edge loops click the button and have a perfect cylinder at a higher res. Cody let me know when you have finished writing this.

    you can already do that with polyboost in max... it is very handy indeed...
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    How do you want it to work? I'm figuring out the logic and came to a couple of questions:

    Is every vertex in the edge loop modified to fit the regular shape, or is there a fixed point and the other just slide around? I guess it's easier to have a fixed point to start the calculation. How do you like it? Do you want to take the radius form the average distance from loop center, or prefer to take it from the chosen fixed point?

    What if vertexes in the loop don't lie on a plane? Do you want them to be flattened on the average plane, or do you prefer them to keep the same projection distance from the average plane?

    I may code such tool in forthcoming IC.Shape 2.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I'd prefer to take from loop center, and to be flattened to an average plane. It would probably need to be made planar first, or I imagine the angles would be really difficult to figure out.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    To get the average plane I think to get the average center, then edge by edge do a cross product between edge vector and the vector from the center to the edge, then get the average normal from all cross products, it should be the average plane normal, the same used in flatten. I'm not completely sure, haven't tested it yet, but should work. I'm just asking myself how is calculated the average plane between bare verts...

    (after a quick test...)

    ...Well, it seems it's not calculated at all. If you try a "Make Planar" on bare isolated verts it makes them planar in X.

    EDIT
    (after other quick tests...)

    It seems "Make Planar" fails badly even on an edge loop in a cylinder. Again it makes verts flat along one axis.
  • jerry
    It works if you cap it first.

    Edit: So what i thought was actually true. Once you collapse vertices the original center of the circle is lost. The center calculated from all vertices at least. How do you construct a cicle without knowing the correct centerpoint? Some testing code:
    (
        --If there is anything selected?
            local sel = getCurrentSelection()
            if sel.count != 0 then
            (
                --Get the current modifier.
                local theObject = modPanel.GetCurrentObject()
                
                if(classof theObject == Editable_Poly)then
                (
                    if(subobjectlevel == 1)then
                    (
                        local verts = (polyOp.getVertSelection theObject) as array
                        
                        if verts.count != 0 then
                        (
                            local amount = verts.count
                            local centerpos = [0,0,0]
                            for i in verts do
                            (    
                                centerpos += polyOp.getVert theObject i node:$
                            )--end for
                            
                            centerpos = centerpos / amount
                            
                            message = ""
                            message += "---Centerpos is:" + centerpos as string
                            print message
                            
                        )--end if
                    )--end if
                )
            )
    )
    
  • Mark Dygert
    I think the fastest way, without fancy math would be to collapse edges and spherify the ugly loop as selection. I'm not sure if you can do that without adding a modifier though...

    EDIT: Never mind that doesn't work that well at all.
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    simple and dull algorithm
    1. get average center point
    2.get average plane
    3. get average radius
    4.create n sided circle with radius and center point
    5 move vertexes to their counterpart in the circle
    6.delete circle
    7. rotare vertexes relative to the centerpoint until the hull is convex

    even easyer script way slice edgeoop, cap edgeloop,geopoly, delete cap, move ugly verts to beaty verts and collapse
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    If you maya users get this before me when I went and made that jpeg, i will shake my fist at you over the internet SO HARD!!!!

    we already have it, i use it all the time...

    http://www.creativecrash.com/maya/downloads/scripts-plugins/modeling/c/equalize-continuous-edges?software_version=2009


    the example pic is doing it a different way, but it also has the functionality your looking for, if you select a loop is going around the tube and not down it.. it basically spaces everything out equally, so if you do it to a round loop it becomes a circle..

    SHAKE IT!!!
  • mLichy
    Geo poly will equalize this stuff in max if you have it capped, but not for edges. I'm trying to see if the new tools in max 2010 will do that same thing. I know it's polyboost, but maybe something will work.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I realize I could cap, geopoly and reweld, but sometimes I'm wanting to do this on several edges down a tube, like on tree branches or tentacles, and it's just not as efficient as a script, which is why I asked. I already have access to the cap/geopoly method now.

    *shakes fist at arshlevon*
  • CodeFather
    Offline / Send Message
    CodeFather polycounter lvl 15
    Polyboost has such feature, under "loop tools" there is a "circle" command.
    The only problem is that it doesn't work right if there are any poles on the loop(vertices with more than 4 edges connected to them). So , in the case of callapsed edges, it won't work.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    CodeFather wrote: »
    Polyboost has such feature, under "loop tools" there is a "circle" command.
    The only problem is that it doesn't work right if there are any poles on the loop(vertices with more than 4 edges connected to them). So , in the case of callapsed edges, it won't work.

    I guess it is because it cannot read the closed edge loop, since poles stop it.
  • mLichy
    Well can't you just manually select the edges and click on circle, or no?
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    arshlevon, I tried creating 6 sided cylindar into an 8 sided and it made jumbled mess. Now the script doesn't even work.
    CompleteCurrentTool;
    ctxCompletion;
  • Mark Dygert
    mLichy wrote: »
    Well can't you just manually select the edges and click on circle, or no?
    Circle?

    What about about relax, then scale it back up a bit, or is it important to have all edges be equal lengths?
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    relax doesnt work and i found out that the german version of max 2010 is so aweful, that i instandly had to deinstall it, luckily it was just the demo, imagine i would have paid money for this, i would die
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    malcolm wrote: »
    arshlevon, I tried creating 6 sided cylindar into an 8 sided and it made jumbled mess. Now the script doesn't even work.
    CompleteCurrentTool;
    ctxCompletion;


    what exactly are you doing? i don't understand this part..
    "I tried creating 6 sided cylindar into an 8 sided"
    it doesn't do that, it spaces things out evenly..


    i use the script on a regular basis so if you show me what you are trying to do then maybe i can help... just select one loop and run: mm_equalizeEdges;
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I just read my own post and it sounds like broken english from a eastern european. Sorry I have the flu right now. So I created a 6 sided cylinder, deleted the top and the bottom cap face. Now I add two more edge loops to make it an 8 sided cylinder, then I select the top edge loop to make it into a symmetrical 8 sided cylinder instead of a wonky 6 sided cylinder. I run the script and it makes a garbled mess and then no longer works? I tried it in maya2009 maybe that is the problem?
  • mLichy
    Yeah, I tried relax as well, but that doesn't work. Prob. have to make a custom script to average each edges lengths or something.
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    renderjhs made that for a spine but in flash, he could esily make a maxscript for that, but he refused until his project is finished
  • System
    Offline / Send Message
    System admin
    Spherify works on subobject types and doesn't seem to get stuck with poles or closed loops but as with relax the edges aren't equal length. Still though, when used with relax and make planar function you can obtain a near perfect result.
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    renderjhs made that for a spine but in flash, he could esily make a maxscript for that, but he refused until his project is finished
    that was spline (I knew already the order) and 2d specific (just easier).

    Anyway if I were more comfortable with normals and matrix stuff I would do it like this:
    geo_loop_script_concept.gif
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Isn't the point of this script request also to preserve (inflate?) the volume though? Or am I wrong? Is merely aligning the verts and spreading them out with equal edge length and distance from centre enough?
  • mLichy
    I think just getting even sides would be good, even if it inflates it a tiny bit. Then you could just scale it back down a tiny bit. But having it not inflate at all would be ideal.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    @rhjs another thing to consider is where to start the new vertices, ie one should go for a energy minimizing setup, so that vertices are placed in fashion with minimal distances to original vertices. what is "most average distance" ?

    @mop, if you have just a cross section it's area preserving, ie one could deduce the radius from the original cross surface. (area = pi r², r = root(area/pi)). but maybe you meant the shrink due to subdiv?
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    @rhjs another thing to consider is where to start the new vertices, ie one should go for a energy minimizing setup, so that vertices are placed in fashion with minimal distances to original vertices. what is "most average distance" ?
    d1 = distance(  vtx1 center);
    d2 = distance(  vtx2 center);
    ...
    average_distance = (d1+d2+d3+...) / amountOfVerts;
    
    something like that. As for starting point - thats perhaps a bit more tricky maybe the one with the longest edges or the one closest to the current view (ray distance), otherwise just 1 to to start- one can always twist the whole loop to adjust things anyway.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Ah after looking at the example images again I see that this proposed script would solve that issue without losing too much volume.

    I was more thinking along the lines of the problem where, if you go from a 12-sided cylinder and "collapse" every other edge (instead of "removing" every other vertex), the Collapse action actually loses volume since it averages the edge's vertex positions. So going from 12-sided to 6-sided using Collapse operations (which are better in these cases than remove since it deals with the cylinder connections nicely) inherently reduces the radius of the mesh at that point.

    Edit: Then again, I don't really understand poopinmymouth's original post, since he says "going from 8 sided, collapsing to 4 sided" and then requests the script to make it as close to a circle as possible - surely if you have collapsed a regular 8 sided cylinder down to 4 sided then the result is a perfect square anyway?
    The example image he gives later is more accurate, in that just the top 2 edges are collapsed so you end up with an irregular 7-sided shape instead of a 12-sided shape. Going from 8 to 4 (or 12 to 6, 16 to 8 or whatever) doesn't have this problem if you're collapsing regularly.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Sorry I wasn't clear. Say I make a tree out of splines made visible. They are 8 sided from base to tip. Now because they taper, I want to taper the polycount. So maybe the first 3 cross sections would stay 8 sides, then the next 2 would be 7, the next 6, etc till it's down to 4.

    This is why a script would be nice, because the tentacle like limbs will prevent a more standard solution. Of course I know that collapsing every other edge evenly doesn't need this type of fixing.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    @rhjs, okay I took the "most" too literal, as I wondered what other average distance can exist ;)
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi guys,
    here it is: IC.GeoEdgeLoop! Get it from IllusionCatalyst website, under Script section in MaxScript Page.

    It works on closed edge loops in Editable Poly objects with two algorithms: refit by vertex and average.
    • Refit by vertex ask for a vertex as fixed starting point for calculation. Its position is preserved, while other vertexes slide around.
    • Refit average works iteratively every vertex until a regular polygon is shaped by subsequent shifts. It checks for edge length and angle between edges.
    In both cases the edge loop is flattened on the average plane.

    I hope you enjoy it, please report any issue. Now back to workshop Wrench!
  • robioto
    Offline / Send Message
    robioto polycounter lvl 19
    Wow thanks for the hard work, you're a maxscript machine!
  • Mark Dygert
    NICE! I'll give it a try in a bit.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    OMG yes! Polycount delivers. Thanks for the PM, I had given up on getting this, but you rock.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Ok, so I just tried running it in 2009, and it works great when I select a vertice, but when I click to choose Average, it freezes max and I have to end via the task manager.

    One other feature that would be nice, currently you must do one ring at a time. It would be good if you have more than one selected, if it auto chooses the average feature and does it to each of them.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Thanks for the report. Have you tried to press ESC when it seems frozen? The average function has got a "while loop" that keeps going until angles and edges reach the defined tolerance to be considered regular. There's an ESC condition that allows to exit from the loop and abort the command. The script has been developed and tested on Max 9, but should work on every newer version.

    Does the Average function lock Max on every kind of geometry, or is it a particular case? Would you mind posting an OBJ for testing purposes?

    I'm not sure about it, but it could be a simple tolerance issue, if you are comfortable with code, try to rise fLengthEpsi and fAngleEpsi from 1e-4 to 1e-3 in function refitLoopByAvg.

    About the multi loop feature, I think it would be quite handy. Right now I guess it would require quite a heavy edge sorting and loop testing, but should be possible to implement. Thanks for the tip.
  • Mark Dygert
    Works great!

    As long as the mesh is "Editable Poly". It took me a while to figure out it won't work on an Edit Poly modifier only a Editable Poly object. It would crash and highlight line 292.

    Having it work on edit poly would awesome since its not always possible to collapse the stack down to editable poly. Or maybe just having a check and error message would be nice.

    Thanks again this rocks x10!
1
Sign In or Register to comment.