Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- obj = selection[1]
- polyop.setMapSupport obj 0 true
- polyop.setNumMapVerts obj 0 (getNumVerts obj)
- polyop.setNumMapFaces obj 0 (getNumFaces obj)
- polyop.defaultMapFaces obj 0
- verts = polyop.getNumVerts obj
- arr = #()
- for i=1 to verts do append arr i
- polyop.setVertColor obj 0 arr (Color 128 128 128)
- edges = polyop.getNumEdges obj
- for i=1 to edges do
- (
- faces = polyop.getEdgeFaces obj i
- if (faces.count > 1) then
- (
- c1 = polyop.getFaceCenter obj faces[1]
- c2 = polyop.getFaceCenter obj faces[2]
- n1 = polyop.getFaceNormal obj faces[1]
- n2 = polyop.getFaceNormal obj faces[2]
- vec = normalize (c1 - c2)
- convex = 1
- if (dot vec n1) < 0 then convex = -1
- flatness = (dot n1 n2)
- if flatness < 0 then flatness = 0
- curvature = ((1.0 - flatness) * convex) * 0.5 + 0.5
- /*print "!"
- print convex
- print flatness
- print curvature*/
- if (curvature < 0) then curvature = 0
- if (curvature > 1) then curvature = 1
- verts = polyop.getEdgeVerts obj i
- color1 = polyop.getMapVert obj 0 (verts[1])
- color2 = polyop.getMapVert obj 0 (verts[2])
- color1.x *= curvature * 2 -- multiply 2x
- if (color1.x < 0) then color1.x = 0
- if (color1.x > 1) then color1.x = 1
- color2.x *= curvature * 2
- if (color2.x < 0) then color2.x = 0
- if (color2.x > 1) then color2.x = 1
- polyop.setMapVert obj 0 (verts[1]) [color1.x, color1.x, color1.x]
- polyop.setMapVert obj 0 (verts[2]) [color2.x, color2.x, color2.x]
- )
- )
- update obj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement