Announcement

Collapse
No announcement yet.

Maxscript - Vertex location?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript - Vertex location?

    Hey guys,


    I was wondering if any of you scripters could help me with something. I basically need a little script that will take, for instance a selection of three vertices and center the middle vertex between the first and third. Ideally this would work for an editable poly and/or spline shapes. Any help will be greatly appreciated.
    -----Dwayne D. Ellis-----

  • #2
    On what criteria is the "middle" vertex determined?
    Colin Senner

    Comment


    • #3
      PolyBoost has tools to do this. You can also evenly space multiple edge loops instead of just one.

      PB has a ton of other tools. I would have a hard time going back to plain old poly modeling in max.

      http://www.polyboost.com/

      Comment


      • #4
        Going to have to look into polyboost for sure.

        The middle vertex is...well...imagine you start out with a 3 vert shape that looks like the letter V...but kind of tilted so that the two top verts aren't at the samee elevation. Then you want to take that middle vertex and move it so that its exactly in the middle of the two vertices...as far as elevation goes. Hope that makes sense.
        -----Dwayne D. Ellis-----

        Comment


        • #5
          A picture is worth a thousand words...

          Comment


          • #6
            you are meaning to align the to the VIEW up vector? or to the Z position?
            the code for the window alignment is slightly more complex, but the basic idea, once you have a reference coordinate system, is simply to average out the two transform matrices, and derive as such the third one.

            Code:
            ------------ initialise the variable that will contain the matrices sum
            theSum=[0,0,0] 
            ------------ increment the total sum value by the matrix of each vertex i-Nth of the mesh $
            for i=1 to (meshop.getNumVerts $) do (
            theSum+=meshop.getvert $ i
            )
            ------------ calculate the average position dividing the sum by the number of vertices
            theAvg = theSum / (meshop.getNumVerts $)
            ------------ move the vertices in place
            for i=1 to (meshop.getNumVerts $) do (
            meshop.setVert $ i theAvg 
            )
            ------------ redraw required to see the meshop results
            redrawViews()
            This will move every vertex of a given MESH object (or else it will fail, use a mesh select op on top of the stack to make sure it's read as a mesh) to the average position of all the vertices.
            In a standard sphere, this represents the pivot location at the origin of the sphere.
            Feel free to customize the code to suit your needs.
            Lele
            Trouble Stirrer in RnD @ Chaos
            ----------------------
            emanuele.lecchi@chaos.com

            Disclaimer:
            The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

            Comment

            Working...
            X