Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Getting vertex order consistent when iterating over a mesh
  RSS 2.0 ATOM  

Getting vertex order consistent when iterating over a mesh
Rate this thread
 
63879
 
Permlink of this thread  
avatar
  • Location: Columbus, Ohio
  • Total Posts: 434
  • Joined: 01 March 2008 04:43 AM

I am trying to figure out how to make the output of the vertices to come out consistently Clockwise or Counterclockwise when getting vertices from faces in a mesh. Use this as an example:

themeshes #()
 
 
--array containing a couple boxes turned to meshes
 themeshes 
#((convertToMesh (Box pos:[0,0,0] width: 30 height:30 length:30)),(convertToMesh (Box pos:[100,100,100] width:30 height:30 length:30)))
 
 
--iterate through an array containing EditableMesh objects
 
for myMesh in themeshes do (
  --
iterate over all the faces in the mesh
  
for index 1 to myMesh.numfaces do (
   --
get the vertices in each face
   local verts 
meshop.getVertsUsingFace myMesh #{index}
   
--iterate over the vertices
   
for vert in verts do (
    --
get the coordinates of each vertex
    vertinfo 
meshop.getVert myMesh vert
    
print vertinfo
   
)
  )
 )

You cannot use the ordering of the vertices for writing mesh data because some are clockwise and some are counter-clockwise. My question is how to efficiently get the vertices in a consistent pattern.

I originally tried to cheat by reversing the order of the verts array above every iteration through the outter loop… but that hack failed… though it is “better” than the default ordering.



______________________________
Shawn Olson’s Creative Arts
Developer of the Wall Worm Model Tools for Source
And my Favorite Unsung Plugin: Convexity for Level Design

Max 4/Gmax, 2008 - 2013
Mudbox 2009-2011
Win 7 x64 (x4)
Geforce 480x2 | Geforce 275x1 | ATI Radeon HD 3200 | Intel Generic chip
8GB | 12GB | 4GB | 4GB
Intel Quad 6700 | i7 930 | Athlon QL-65 | Intel Quad 6700

Replies: 0
avatar
  • Ruramuq
  • Posted: 25 January 2012 11:28 AM

you want the face’s verts of a mesh?

getVertsusingFaces returns a bitarray, [ no order ]

try with : getFace $ <face>



Replies: 1
/img/forum/dark/default_avatar.png

Thank you for that tip. It was the answer I was looking for :)

Author: Shawn Olson

Replied: 25 January 2012 12:06 PM