[Bf-extensions-cvs] [16dbda9c] master: mesh tissue update by Alessandro

meta-androcto noreply at git.blender.org
Wed Jun 14 04:42:56 CEST 2017


Commit: 16dbda9caabd065a1eb5b0e6af0e3596fe313442
Author: meta-androcto
Date:   Wed Jun 14 12:42:31 2017 +1000
Branches: master
https://developer.blender.org/rBA16dbda9caabd065a1eb5b0e6af0e3596fe313442

mesh tissue update by Alessandro

===================================================================

M	mesh_tissue/__init__.py
M	mesh_tissue/colors_groups_exchanger.py
M	mesh_tissue/dual_mesh.py
M	mesh_tissue/tessellate_numpy.py

===================================================================

diff --git a/mesh_tissue/__init__.py b/mesh_tissue/__init__.py
index 1c0945ed..372f3474 100644
--- a/mesh_tissue/__init__.py
+++ b/mesh_tissue/__init__.py
@@ -17,7 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # --------------------------------- TISSUE ------------------------------------#
-#-------------------------------- version 0.29 --------------------------------#
+#-------------------------------- version 0.3 ---------------------------------#
 #                                                                              #
 # Creates duplicates of selected mesh to active morphing the shape according   #
 # to target faces.                                                             #
@@ -41,6 +41,7 @@ else:
     from . import tessellate_numpy
     from . import colors_groups_exchanger
     from . import dual_mesh
+    from . import lattice
 
 import bpy
 from mathutils import Vector
@@ -50,7 +51,7 @@ from mathutils import Vector
 bl_info = {
 	"name": "Tissue",
 	"author": "Alessandro Zomparelli (Co-de-iT)",
-	"version": (0, 2, 9),
+	"version": (0, 3, 0),
 	"blender": (2, 7, 8),
 	"location": "",
 	"description": "Tools for Computational Design",
diff --git a/mesh_tissue/colors_groups_exchanger.py b/mesh_tissue/colors_groups_exchanger.py
index 8bd47b46..4ae76020 100644
--- a/mesh_tissue/colors_groups_exchanger.py
+++ b/mesh_tissue/colors_groups_exchanger.py
@@ -26,7 +26,7 @@
 # For use the command "Vertex Clors to Vertex Groups" use the search bar       #
 # (space bar).                                                                 #
 #                                                                              #
-#                            (c)  Alessandro Zomparelli                           #
+#                          (c)  Alessandro Zomparelli                          #
 #                                     (2017)                                   #
 #                                                                              #
 # http://www.co-de-it.com/                                                     #
@@ -35,6 +35,7 @@
 
 import bpy
 import math
+from math import pi
 
 bl_info = {
     "name": "Colors/Groups Exchanger",
@@ -51,8 +52,9 @@ bl_info = {
 
 class vertex_colors_to_vertex_groups(bpy.types.Operator):
     bl_idname = "object.vertex_colors_to_vertex_groups"
-    bl_label = "Weight from Colors"
+    bl_label = "Vertex Color"
     bl_options = {'REGISTER', 'UNDO'}
+    bl_description = ("Convert the active Vertex Color into a Vertex Group.")
 
     red = bpy.props.BoolProperty(
         name="red channel", default=False, description="convert red channel")
@@ -135,8 +137,9 @@ class vertex_colors_to_vertex_groups(bpy.types.Operator):
 
 class vertex_group_to_vertex_colors(bpy.types.Operator):
     bl_idname = "object.vertex_group_to_vertex_colors"
-    bl_label = "Colors from Weight"
+    bl_label = "Vertex Group"
     bl_options = {'REGISTER', 'UNDO'}
+    bl_description = ("Convert the active Vertex Group into a Vertex Color.")
 
     channel = bpy.props.EnumProperty(
         items=[('Blue', 'Blue Channel', 'Convert to Blue Channel'),
@@ -212,13 +215,58 @@ class vertex_group_to_vertex_colors(bpy.types.Operator):
         bpy.context.object.data.vertex_colors[colors_id].active_render = True
         return {'FINISHED'}
 
+class curvature_to_vertex_groups(bpy.types.Operator):
+    bl_idname = "object.curvature_to_vertex_groups"
+    bl_label = "Curvature"
+    bl_options = {'REGISTER', 'UNDO'}
+    invert = bpy.props.BoolProperty(
+        name="invert", default=False, description="invert values")
+    bl_description = ("Generate a Vertex Group based on the curvature of the"
+                      "mesh. Is based on Dirty Vertex Color.")
+
+    blur_strength = bpy.props.FloatProperty(
+      name="Blur Strength", default=1, min=0.001,
+      max=1, description="Blur strength per iteration")
+
+    blur_iterations = bpy.props.IntProperty(
+      name="Blur Strength", default=1, min=0,
+      max=40, description="Number of times to blur the values")
+
+    min_angle = bpy.props.FloatProperty(
+      name="Min Angle", default=0, min=0,
+      max=pi/2, subtype='ANGLE', description="Minimum angle")
+
+    max_angle = bpy.props.FloatProperty(
+      name="Max Angle", default=pi, min=pi/2,
+      max=pi, subtype='ANGLE', description="Maximum angle")
+
+    invert = bpy.props.BoolProperty(
+        name="Invert", default=False,
+        description="Invert the curvature map")
+
+    def execute(self, context):
+        bpy.ops.object.mode_set(mode='OBJECT')
+        bpy.ops.mesh.vertex_color_add()
+        vertex_colors = bpy.context.active_object.data.vertex_colors
+        vertex_colors[-1].active = True
+        vertex_colors[-1].active_render = True
+        vertex_colors[-1].name = "Curvature"
+        bpy.ops.object.mode_set(mode='VERTEX_PAINT')
+        bpy.ops.paint.vertex_color_dirt(blur_strength=self.blur_strength, blur_iterations=self.blur_iterations, clean_angle=self.max_angle, dirt_angle=self.min_angle)
+        bpy.ops.object.vertex_colors_to_vertex_groups(invert=self.invert)
+        bpy.ops.mesh.vertex_color_remove()
+        return {'FINISHED'}
+
+
 
 class face_area_to_vertex_groups(bpy.types.Operator):
     bl_idname = "object.face_area_to_vertex_groups"
-    bl_label = "Weight from Faces Area"
+    bl_label = "Area"
     bl_options = {'REGISTER', 'UNDO'}
     invert = bpy.props.BoolProperty(
         name="invert", default=False, description="invert values")
+    bl_description = ("Generate a Vertex Group based on the area of individual"
+                      "faces.")
 
     def execute(self, context):
         obj = bpy.context.active_object
@@ -237,7 +285,6 @@ class face_area_to_vertex_groups(bpy.types.Operator):
         max_area = False
         n_values = [0]*len(obj.data.vertices)
         values = [0]*len(obj.data.vertices)
-        print(len(values))
         for p in obj.data.polygons:
             for v in p.vertices:
                 n_values[v] += 1
@@ -266,21 +313,25 @@ class face_area_to_vertex_groups(bpy.types.Operator):
 
 
 class colors_groups_exchanger_panel(bpy.types.Panel):
-    bl_label = "Colors-Weight Exchanger"
-    bl_category = "Create"
+    bl_label = "Data Converter"
+    bl_category = "Tools"
     bl_space_type = "VIEW_3D"
     bl_region_type = "TOOLS"
-    bl_options = {'DEFAULT_CLOSED'}
     #bl_context = "objectmode"
 
     def draw(self, context):
         layout = self.layout
         col = layout.column(align=True)
-        col.operator("object.vertex_group_to_vertex_colors", icon="GROUP_VCOL")
+        col.label(text="Create Vertex Groups:")
         col.operator(
-            "object.vertex_colors_to_vertex_groups", icon="GROUP_VERTEX")
-        col.separator()
+            "object.vertex_colors_to_vertex_groups", icon="GROUP_VCOL")
         col.operator("object.face_area_to_vertex_groups", icon="SNAP_FACE")
+        col.operator("object.curvature_to_vertex_groups", icon="SURFACE_DATA")
+
+        col.separator()
+        col.label(text="Create Vertex Colors:")
+        col.operator("object.vertex_group_to_vertex_colors", icon="GROUP_VERTEX")
+
 
 
 def register():
diff --git a/mesh_tissue/dual_mesh.py b/mesh_tissue/dual_mesh.py
index 5a4a5d13..60a11927 100644
--- a/mesh_tissue/dual_mesh.py
+++ b/mesh_tissue/dual_mesh.py
@@ -15,13 +15,14 @@
 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ##### END GPL LICENSE BLOCK #####
+
 #---------------------------------- DUAL MESH ---------------------------------#
 #--------------------------------- version 0.3 --------------------------------#
 #                                                                              #
 # Convert a generic mesh to its dual. With open meshes it can get some wired   #
 # effect on the borders.                                                       #
 #                                                                              #
-#                          (c)   Alessandro Zomparelli                            #
+#                        (c)   Alessandro Zomparelli                           #
 #                                    (2017)                                    #
 #                                                                              #
 # http://www.co-de-it.com/                                                     #
@@ -47,6 +48,7 @@ class dual_mesh(bpy.types.Operator):
     bl_idname = "object.dual_mesh"
     bl_label = "Dual Mesh"
     bl_options = {'REGISTER', 'UNDO'}
+    bl_description = ("Convert a generic mesh to its dual.")
 
     quad_method = bpy.props.EnumProperty(
         items=[('BEAUTY', 'Beauty',
@@ -214,11 +216,10 @@ class dual_mesh(bpy.types.Operator):
 
 class dual_mesh_panel(bpy.types.Panel):
     bl_label = "Dual Mesh"
-    bl_category = "Create"
+    bl_category = "Tools"
     bl_space_type = "VIEW_3D"
     bl_region_type = "TOOLS"
     bl_context = (("objectmode"))
-    bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
         layout = self.layout
diff --git a/mesh_tissue/tessellate_numpy.py b/mesh_tissue/tessellate_numpy.py
index 001a438d..fb1a5d39 100644
--- a/mesh_tissue/tessellate_numpy.py
+++ b/mesh_tissue/tessellate_numpy.py
@@ -22,7 +22,7 @@
 # Creates duplicates of selected mesh to active morphing the shape according   #
 # to target faces.                                                             #
 #                                                                              #
-#                    (c)  Alessandro Zomparelli                                   #
+#                    (c)  Alessandro Zomparelli                                #
 #                             (2017)                                           #
 #                                                                              #
 # http://www.co-de-it.com/                                                     #
@@ -776,17 +776,20 @@ class tessellate(bpy.types.Operator):
         bpy.ops.object.mode_set(mode='OBJECT')
 
         # MATERIALS
-        # create materials list
-        polygon_materials = [p.material_index for p in ob1.data.polygons]*int(
-            len(new_ob.data.polygons) / len(ob1.data.polygons))


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list