diff options
author | meta-androcto <meta.androcto1@gmail.com> | 2017-03-23 09:06:55 +0300 |
---|---|---|
committer | meta-androcto <meta.androcto1@gmail.com> | 2017-03-23 09:06:55 +0300 |
commit | 857df14fe48528a4362bc5ab7f836695bf32a368 (patch) | |
tree | 52e9bf43eef5a706a3b099c82e8f596f77d13203 /mesh_extra_tools | |
parent | 365f25f0d7a1eba07586d781efad4731bd4f4335 (diff) |
mesh edit tools: multi extrude, add probability, thanks @JimmyHaze
Diffstat (limited to 'mesh_extra_tools')
-rw-r--r-- | mesh_extra_tools/mesh_mextrude_plus.py | 92 |
1 files changed, 69 insertions, 23 deletions
diff --git a/mesh_extra_tools/mesh_mextrude_plus.py b/mesh_extra_tools/mesh_mextrude_plus.py index 1cfd1714..786db0f5 100644 --- a/mesh_extra_tools/mesh_mextrude_plus.py +++ b/mesh_extra_tools/mesh_mextrude_plus.py @@ -36,7 +36,7 @@ import bpy import bmesh import random from bpy.types import Operator -from random import gauss +from random import gauss, choice from math import radians from mathutils import Euler from bpy.props import ( @@ -45,6 +45,12 @@ from bpy.props import ( ) +# added normal rot +def nrot(self,n): + return Euler((radians(self.nrotx) * n[0], \ + radians(self.nroty) * n[1], \ + radians(self.nrotz) * n[2]), 'XYZ') + def vloc(self, r): random.seed(self.ran + r) return self.off * (1 + gauss(0, self.var1 / 3)) @@ -98,6 +104,28 @@ class MExtrude(Operator): default=-0, description="Z Rotation" ) + nrotx = FloatProperty( + name="N Rot X", + min=-85, max=85, + soft_min=-30, soft_max=30, + default=0, + description="X Rotation" + ) + nroty = FloatProperty( + name="N Rot Y", + min=-85, max=85, + soft_min=-30, + soft_max=30, + default=0, + description="Y Rotation" + ) + nrotz = FloatProperty( + name="N Rot Z", + min=-85, max=85, + soft_min=-30, soft_max=30, + default=-0, + description="Z Rotation" + ) sca = FloatProperty( name="Scale", min=0.1, max=2, @@ -125,6 +153,12 @@ class MExtrude(Operator): default=0, description="Scaling noise" ) + var4 = IntProperty( + name="Probability", + min=0, max=100, + default=100, + description="Probability, chance of extruding a face" + ) num = IntProperty( name="Repeat", min=1, max=50, @@ -151,6 +185,9 @@ class MExtrude(Operator): col.prop(self, "rotx", slider=True) col.prop(self, "roty", slider=True) col.prop(self, "rotz", slider=True) + col.prop(self, 'nrotx', slider=True) + col.prop(self, 'nroty', slider=True) + col.prop(self, 'nrotz', slider=True) col.prop(self, "sca", slider=True) col = layout.column(align=True) @@ -158,11 +195,14 @@ class MExtrude(Operator): col.prop(self, "var1", slider=True) col.prop(self, "var2", slider=True) col.prop(self, "var3", slider=True) + col.prop(self, "var4", slider=True) col.prop(self, "ran") - col = layout.column(align=False) col.prop(self, 'num') + + + def execute(self, context): obj = bpy.context.object om = obj.mode @@ -180,30 +220,36 @@ class MExtrude(Operator): for i, of in enumerate(sel): rot = vrot(self, i) off = vloc(self, i) + nro = nrot(self, of.normal) of.normal_update() # extrusion loop - for r in range(self.num): - nf = of.copy() - nf.normal_update() - no = nf.normal.copy() - ce = nf.calc_center_bounds() - s = vsca(self, i + r) - - for v in nf.verts: - v.co -= ce - v.co.rotate(rot) - v.co += ce + no * off - v.co = v.co.lerp(ce, 1 - s) - - # extrude code from TrumanBlending - for a, b in zip(of.loops, nf.loops): - sf = bm.faces.new((a.vert, a.link_loop_next.vert, - b.link_loop_next.vert, b.vert)) - sf.normal_update() - - bm.faces.remove(of) - of = nf + for r in range( self.num ): + + ## random % skip some extrusions + if self.var4 >= int(random.random()*100): + + nf = of.copy() + nf.normal_update() + no = nf.normal.copy() + ce = nf.calc_center_bounds() + s = vsca(self, i + r) + + for v in nf.verts: + v.co -= ce + v.co.rotate(nro) + v.co.rotate(rot) + v.co += ce + no * off + v.co = v.co.lerp(ce, 1 - s) + + # extrude code from TrumanBlending + for a, b in zip(of.loops, nf.loops): + sf = bm.faces.new((a.vert, a.link_loop_next.vert, + b.link_loop_next.vert, b.vert)) + sf.normal_update() + + bm.faces.remove(of) + of = nf after.append(of) for v in bm.verts: |