Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. obj = selection[1]
  2. polyop.setMapSupport obj 0 true
  3. polyop.setNumMapVerts obj 0 (getNumVerts obj)
  4. polyop.setNumMapFaces obj 0 (getNumFaces obj)
  5. polyop.defaultMapFaces obj 0
  6. verts = polyop.getNumVerts obj
  7. arr = #()
  8. for i=1 to verts do append arr i
  9. polyop.setVertColor obj 0 arr (Color 128 128 128)
  10. edges = polyop.getNumEdges obj
  11. for i=1 to edges do
  12. (
  13. faces = polyop.getEdgeFaces obj i
  14. if (faces.count > 1) then
  15. (
  16. c1 = polyop.getFaceCenter obj faces[1]
  17. c2 = polyop.getFaceCenter obj faces[2]
  18.  
  19. n1 = polyop.getFaceNormal obj faces[1]
  20. n2 = polyop.getFaceNormal obj faces[2]
  21.  
  22. vec = normalize (c1 - c2)
  23. convex = 1
  24. if (dot vec n1) < 0 then convex = -1
  25. flatness = (dot n1 n2)
  26. if flatness < 0 then flatness = 0
  27.  
  28. curvature = ((1.0 - flatness) * convex) * 0.5 + 0.5
  29. /*print "!"
  30. print convex
  31. print flatness
  32. print curvature*/
  33. if (curvature < 0) then curvature = 0
  34. if (curvature > 1) then curvature = 1
  35.  
  36. verts = polyop.getEdgeVerts obj i
  37. color1 = polyop.getMapVert obj 0 (verts[1])
  38. color2 = polyop.getMapVert obj 0 (verts[2])
  39.  
  40. color1.x *= curvature * 2 -- multiply 2x
  41. if (color1.x < 0) then color1.x = 0
  42. if (color1.x > 1) then color1.x = 1
  43.  
  44. color2.x *= curvature * 2
  45. if (color2.x < 0) then color2.x = 0
  46. if (color2.x > 1) then color2.x = 1
  47.  
  48. polyop.setMapVert obj 0 (verts[1]) [color1.x, color1.x, color1.x]
  49. polyop.setMapVert obj 0 (verts[2]) [color2.x, color2.x, color2.x]
  50. )
  51. )
  52. update obj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement