Home Technical Talk

Average to Planar ?

1
CreativeSheep
polycounter lvl 8
Offline / Send Message
CreativeSheep polycounter lvl 8
How do you average polygons if they are not perfectly flat so that they are all planar ? 

Replies

  • MmAaXx
    Options
    Offline / Send Message
    MmAaXx polycounter lvl 10
    in Blender  just turn on the Looptools from the addon list. that select your polygons >>> W >>> looptools >>> flatten
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I forgot to mention, Maya ! 
    This forum needs an option where as you can have in the corner the software you primarily use.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    In 3dsmax - edit poly -> select some faces -> make planar
  • musashidan
    Options
    Offline / Send Message
    musashidan high dynamic range
    Also, in Max you can make planar to specific axis: x/y/z

    Or select the verts/edges/faces and scale until flat.

    In Zbrush you can also scale until flat with the transpose line or transpose move along the local normal and use the clipping brush.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Are we talking about averaging selected vertices in one specified axis?
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    Are we talking about averaging selected vertices in one specified axis?

    Yes ? I hope that is the correct terminology.

  • musashidan
    Options
    Offline / Send Message
    musashidan high dynamic range

    Well then all the options posted above will do that, either based on viewing angle or x/y/z

    what software specifically?

  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    It's Maya so options in Max and ZBrush don't really apply.

    Scaling doesn't give an average, it gives a mid point between min and max.
  • Eric Chadwick
    Options
    Offline / Send Message
    I forgot to mention, Maya ! 
    This forum needs an option where as you can have in the corner the software you primarily use.
    You could easily put this in your signature.
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    I forgot to mention, Maya ! 
    This forum needs an option where as you can have in the corner the software you primarily use.
    You could easily put this in your signature.
    Or the thread title...
  • demigodssw
    Options
    Offline / Send Message
    demigodssw greentooth
    u can snap all vertice to the position of single vertice by holding v first the moving on a single axis
    (holding v is shortcut to some snap setting i forgot what it was)
    be sure to try it with a simple box first than u will get the concept
     just dont select the vertices u want to snap to
  • m4dcow
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    EDIT: List comprehensions to reduce amount of rows. I.e. a bit prettier ^^
    ----------------------------------------------------------------------------------------------------------
    I couldn't resist :smile: 
    Only works with world space axises. Not sure if this is useful to you or not.

    import maya.cmds as cmds

    def planarAverage(axis='x'):
        myVerts = cmds.ls(sl=True, fl=True)
        
        average = [0,0,0]
        vertPos = {}
        
        for v in myVerts:
            t = cmds.xform(v, q=True, t=True, ws=True)
            vertPos[v] = t
            average = [average[i] + t[i] for i in range(3)]
        
        size = len(myVerts)
        average = [average[i] / size for i in range(3)]

        if axis == 'x':
            for v in myVerts:
                cmds.xform(v, t=[average[0],vertPos[v][1],vertPos[v][2]], ws=True)
        elif axis == 'y':
            for v in myVerts:
                cmds.xform(v, t=[vertPos[v][0],average[1],vertPos[v][2]], ws=True)
        else:
            for v in myVerts:
                cmds.xform(v, t=[vertPos[v][0],vertPos[v][1],average[2]], ws=True)    
  • musashidan
    Options
    Offline / Send Message
    musashidan high dynamic range
    kodde said:
    It's Maya so options in Max and ZBrush don't really apply.

    Scaling doesn't give an average, it gives a mid point between min and max.

    Sorry missed the Maya mention

    pedantics aside, scaling in an axis is still effectively 'averaging' the position of the geo.

  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    I beg to differ.

    Average or the number series [0,1,1,10] is (0+1+1+10)/4 = 12/4 = 3. Scaling would be halfway between 0(the smallest numer) and 10(the largest number), 5.
  • Joopson
    Options
    Offline / Send Message
    Joopson quad damage
    I'm not sure it does exactly what you want, but it's an amazing script, so I'll mention it.

    Funky Bunnies' FB Poly Planarize script for Maya. He actually has a bunch of awesome scripts, besides that one, too.

    It allows you to snap all selected vertices to a particular plane, or a "best plane" which is essentially the average direction of the verts.

    http://www.funkybunnies3d.com/tools.php
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    In Blender you can also make individual faces planar by using the Mesh->Clean up->Make Planar Faces operator.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I tried all the scripts mentioned.  I need to average based on the polygons current average.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Polygons current average what?
    The script i wrote averages currently selected vertices position in x/y/z(depending on what you choose when calling the function).
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    Based on faces, not vertices.  

    Kodde, I tried your script on some vertices, set the scene to world space and nothing happened ?
  • kodde
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Oh, and faces are fairly easily converted to vertices/edges/whatever :)
  • musashidan
    Options
    Offline / Send Message
    musashidan high dynamic range
    kodde said:
    I beg to differ.

    Average or the number series [0,1,1,10] is (0+1+1+10)/4 = 12/4 = 3. Scaling would be halfway between 0(the smallest numer) and 10(the largest number), 5.
    Sorry mate, but I was more thinking along the lines of an artist. Unless modeling for micro-millimetre tolerances I don't think too many people modeling in Maya are going for mathematical perfection.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    All I'm saying is there's a difference between an average value and a mid point value, and it's not necessarily "micro-millimeter tolerances" and "mathematical perfections".
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    Kodde your script runs off faces & vertices ?

    I ran the script on both and when the script is run on vertices I get this error;
    planarAverage
    # Result: <function planarAverage at 0x00000044EAADBF98> # 


  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    No it works on vertices. But like I mentioned, converting selections in Maya is easy. You have a foldout menu for this under Modify. Or just ctrl+f9/f10/f11/f12. Actually I think the script does produce some result if you were to run it with faces selected. I managed to do this myself by mistake and oddly enough it produced the wrong result at that time. If I had continued working on the script I'd add error handling that would tell the user to select vertices if the user had anything other than vertices selected.

    Did you look at the video? I show how you can use the script.  
    You could just append the function call at the end of the script and store it as shelf buttons if you prefer that way.

    I think the message you posted is because you didn't add the parenthesis after the function name.
    planarAverage   <- Should produce the message you posted
    planarAverage()   <- Should run the script as intended. Defaults to X-axis if you don't use any arguments.
    planarAverage('x') / planarAverage('y') / planarAverage('z')   <- Should run the script on the x/y/z axis.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I want the script to read the polygon average as it is when selected and average all the polygons selected based on faces selected average. Instead of as your script and others, which is averaging based on an axis.
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    I want the script to read the polygon average as it is when selected and average all the polygons selected based on faces selected average. Instead of as your script and others, which is averaging based on an axis.

    Check out the @Funky Bunnies script that @Joopson linked, it seems to do what you are looking for with the best plane command.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    M4DCow - I already tried that script; didn't do what I wanted.
  • Joopson
    Options
    Offline / Send Message
    Joopson quad damage
    Can you maybe describe what you want a little better? I thought I knew what you were looking for, but now, I'm really not sure. Maybe some visual aids to help explain, because as far as I can tell, that script does what you've been describing. So if it's not what you're looking for, you're not describing it well enough for us to help you properly.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    Look at Kodde video; in the video there is curved geometry. 

    If there is a edge loop around one of the peaks of the curves; I want to average all the polygons in the loop, that doesn't mean, I want to average them based on an X, Y or Z axes I want to average them based on the polygons individual angle.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    So we're talking about average position still? Average rotation? Average vertex normal direction?


  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    Average Position / Average Rotation & Average vertex normal direction, not sure which of the three fits the best method ?
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    Look at Kodde video; in the video there is curved geometry. 

    If there is a edge loop around one of the peaks of the curves; I want to average all the polygons in the loop, that doesn't mean, I want to average them based on an X, Y or Z axes I want to average them based on the polygons individual angle.
    But the Funkybunnies script seems to do this, unless I'm missing something.
    http://www.youtube.com/watch?v=2va7YCsbMDE
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Sorry I still don't follow. Just saying that you want to average them isn't descriptive enough for me in this case. I need to grasp what it is you want to average, what attribute/property? I was wrong about you wanted earlier.

    Do you mean that the selected faces are the ones that should assume an average rotation/position based on their neighboring faces(not selected)? If so it sounds like the already existing Maya command Average Vertices to me.




  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Or maybe the Average Vertices only averages among the selection? Don't use it to often. Need to check when I'm at work.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Yeah the Maya "Average Vertices" command seems to average vertex positions(x, y & z) to a per vertex averaged point based on it's neighbors.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I'm sure many of you have encountered where you have polygons that are non-planar, to some they wouldn't care. Moving those polygons along an axis will deform the object, not a desired method.  

    Usually those polygons will simply require slight movement; doing this manually causes a domino effect whereas other polygons become non-planar.  If there isn't a way to make the selected polygons, keep their position but make them planar; well I'll have to live with it :(:)
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I'm going to assume, no :)
  • Joopson
    Options
    Offline / Send Message
    Joopson quad damage
    Oh, make each individual quad planar? I imagine that could potentially change the shape of the mesh quit a lot, at least in certain circumstances. I'd be interested in seeing if such a thing can be done though; planar quads look so clean.
    I suppose you could run the @Funky Bunnies  script on each separate face, using the best plane setting, but that would suck if you had anything with any real number of polygons, and besides, each face you make planar would probably make the faces around it non-planar again. It would be like trying to empty a pond with a teacup.
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    Wow, yeah making all quads on a given mesh planar would be next to impossible. My head starts to hurt when I think about making something spherical all planar quads.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    I have tried the Funky Bunnies script on each individual faces and it doesn`t make the face non-planar :(
  • demigodssw
    Options
    Offline / Send Message
    demigodssw greentooth
    did u even try holding v and moving ur vertice in a particular axis?

  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Blender has this functionality built-in. If you care about having all planar polygons in your mesh you can take it over there, run the Make Planar Faces operation, and take it back to Maya.
  • brurpo
    Options
    Offline / Send Message
    brurpo polycounter lvl 8
    If you want to flatten based on the vertices average normal, just select the vertices you want to do that, select the scale tool, on the tool options choose normals average, then just scale, they will flatten on the chosen axis that is rotated to face the selection average normal.
  • Bartalon
    Options
    Offline / Send Message
    Bartalon polycounter lvl 12
    If you want all polygons on your mesh to become planar... Triangulate it. :wink:

    Other than that, it's not really feasible to do that without your mesh's shape drastically shifting, if it's possible at all.  The domino effect you mentioned would just work in reverse, forcing vertices to move out of place across your entire mesh in order to settle into a planar arrangement respective to all other polygons.
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Monkey before flattening, triangulated



    Monkey after 5 iterations of flattening, triangulated


    Is the shape different? You be the judge. It can't flatten every face because of the mesh density and odd topology, but it's loads better than the initial mesh and can usually get the faces to be around 95% planar. If you modeled your mesh well enough with enough resolution I bet it would barely change the shape at all.

    The only thing about this operator is that it doesn't weight face averages by the area of the face, so it can behave poorly with thin bevels. But overall, it works OK. Do your bevels after flattening faces and you'll be fine.
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8


    There must be a method to which the angle of the polygon(s) are stored then simply evened out to be non-planar, even if that means the polygon(s) are moved extremely subtle ?

  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    If I average based on a axis, the angle you see in the image is lost; no desired. If the vertices for the polygon, or polygons can be stored then averaged based on the vertices world position ?
  • CreativeSheep
    Options
    Offline / Send Message
    CreativeSheep polycounter lvl 8
    If you can keep the angle of the polygons, but make them non-planar that is the goal ?
1
Sign In or Register to comment.