Guest User

Untitled

a guest
Nov 12th, 2015
315
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Idea by Makkon
  2. --Original Maya Python script by Fingus
  3. --Maxscript by Noors
  4. --http://polycount.com/discussion/160770/normals-from-edgeloop-s-script-for-those-lovely-edge-decals/p1
  5.  
  6. --works only with editable Poly. Select an edge loop and run.
  7. (
  8. fn vertNeighbors obj vert vertLoop =
  9. (
  10. connectedEdges = polyop.getEdgesUsingVert obj #{vert}
  11. connectedVerts = polyop.getVertsUsingEdge obj connectedEdges
  12. neighbors = connectedVerts - vertLoop
  13. return neighbors
  14. )
  15.  
  16. sel = selection as array
  17. for obj in sel where classof obj == Editable_Poly do
  18. (
  19.  
  20. --get selected edgeloop
  21. edgeLoop = polyop.getEdgeSelection obj
  22. --get verticles in the edge loop
  23. vertLoop_bit = polyop.getVertsUsingEdge obj edgeLoop
  24. vertLoop = vertLoop_bit as array
  25.  
  26. --set edit normals modifier
  27. max modify mode
  28. modi = Edit_Normals ()
  29. addmodifier obj modi
  30.  
  31. --soften mesh
  32. normCount = modi.GetNumNormals()
  33. modi.SetSelection #{1..normCount}
  34. modi.Unify()
  35. --force redraw to register the unify, idno :/
  36. max create mode
  37. max modify mode
  38. --
  39. modi.MakeExplicit()
  40.  
  41. --cache methods
  42. _convert = modi.ConvertVertexSelection
  43. _getNorm = modi.Getnormal
  44. _setNorm = modi.Setnormal
  45.  
  46. for v in vertLoop do
  47. (
  48. --get normal of a loop vertex
  49. vert = #{v}
  50. normID = #{}
  51. _convert &vert &normID
  52. norm = _getNorm (normID as array)[1]
  53. --get neighbors vertices
  54. neighbors = vertNeighbors obj v vertLoop_bit
  55. --get their normals
  56. nNormIDs = #{}
  57. _convert &neighbors &nNormIDs
  58. nNormIDs = nNormIDs as array
  59. for id in nNormIDs do _setNorm id norm
  60. )
  61. modi.EditNormalsMod.SetSelection #{}
  62. )
  63. )
RAW Paste Data