mesh tissue: update panels by Alessandro
This commit is contained in:
parent
5417a6c0c2
commit
856c1b9284
|
@ -36,7 +36,6 @@ if "bpy" in locals():
|
|||
importlib.reload(tessellate_numpy)
|
||||
importlib.reload(colors_groups_exchanger)
|
||||
importlib.reload(dual_mesh)
|
||||
importlib.reload(lattice)
|
||||
|
||||
else:
|
||||
from . import tessellate_numpy
|
||||
|
@ -52,8 +51,8 @@ from mathutils import Vector
|
|||
bl_info = {
|
||||
"name": "Tissue",
|
||||
"author": "Alessandro Zomparelli (Co-de-iT)",
|
||||
"version": (0, 3, 0),
|
||||
"blender": (2, 7, 8),
|
||||
"version": (0, 3, 1),
|
||||
"blender": (2, 7, 9),
|
||||
"location": "",
|
||||
"description": "Tools for Computational Design",
|
||||
"warning": "",
|
||||
|
@ -75,5 +74,6 @@ def unregister():
|
|||
dual_mesh.unregister()
|
||||
lattice.unregister()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
|
|
@ -229,7 +229,7 @@ class curvature_to_vertex_groups(bpy.types.Operator):
|
|||
max=1, description="Blur strength per iteration")
|
||||
|
||||
blur_iterations = bpy.props.IntProperty(
|
||||
name="Blur Strength", default=1, min=0,
|
||||
name="Blur Iterations", default=1, min=0,
|
||||
max=40, description="Number of times to blur the values")
|
||||
|
||||
min_angle = bpy.props.FloatProperty(
|
||||
|
@ -251,6 +251,7 @@ class curvature_to_vertex_groups(bpy.types.Operator):
|
|||
vertex_colors[-1].active = True
|
||||
vertex_colors[-1].active_render = True
|
||||
vertex_colors[-1].name = "Curvature"
|
||||
for c in vertex_colors[-1].data: c.color.r, c.color.g, c.color.b = 1,1,1
|
||||
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)
|
||||
|
@ -313,7 +314,7 @@ class face_area_to_vertex_groups(bpy.types.Operator):
|
|||
|
||||
|
||||
class colors_groups_exchanger_panel(bpy.types.Panel):
|
||||
bl_label = "Tissue Data Tools"
|
||||
bl_label = "Tissue Tools"
|
||||
bl_category = "Tools"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "TOOLS"
|
||||
|
@ -321,22 +322,21 @@ class colors_groups_exchanger_panel(bpy.types.Panel):
|
|||
#bl_context = "objectmode"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Create Vertex Groups:")
|
||||
col.operator(
|
||||
"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")
|
||||
col.separator()
|
||||
col.label(text="Lattice Along Surface:")
|
||||
try:
|
||||
col.operator("object.lattice_along_surface", icon="MOD_LATTICE")
|
||||
|
||||
if bpy.context.active_object.type == 'MESH':
|
||||
layout = self.layout
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Transform:")
|
||||
col.operator("object.dual_mesh")
|
||||
col.separator()
|
||||
col.label(text="Weight from:")
|
||||
col.operator(
|
||||
"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="SMOOTHCURVE")
|
||||
col.separator()
|
||||
col.label(text="Vertex Color from:")
|
||||
col.operator("object.vertex_group_to_vertex_colors", icon="GROUP_VERTEX")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
|
@ -48,7 +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.")
|
||||
bl_description = ("Convert a generic mesh into a polygonal mesh.")
|
||||
|
||||
quad_method = bpy.props.EnumProperty(
|
||||
items=[('BEAUTY', 'Beauty',
|
||||
|
@ -75,14 +75,31 @@ class dual_mesh(bpy.types.Operator):
|
|||
name="Preserve Borders", default=True,
|
||||
description="Preserve original borders")
|
||||
|
||||
apply_modifiers = bpy.props.BoolProperty(
|
||||
name="Apply Modifiers", default=True,
|
||||
description="Apply object's modifiers")
|
||||
|
||||
def execute(self, context):
|
||||
mode = context.mode
|
||||
if mode == 'EDIT_MESH': mode = 'EDIT'
|
||||
act = bpy.context.active_object
|
||||
sel = bpy.context.selected_objects
|
||||
if mode != 'OBJECT':
|
||||
sel = [act]
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
else: sel = bpy.context.selected_objects
|
||||
doneMeshes = []
|
||||
'''
|
||||
if self.new_object:
|
||||
bpy.ops.object.duplicate_move()
|
||||
for i in range(len(sel)):
|
||||
bpy.context.selected_objects[i].name = sel[i].name + "_dual"
|
||||
if sel[i] == act:
|
||||
bpy.context.scene.objects.active = bpy.context.selected_objects[i]
|
||||
sel = bpy.context.selected_objects
|
||||
'''
|
||||
for ob0 in sel:
|
||||
if ob0.type != 'MESH': continue
|
||||
if ob0.data.name in doneMeshes: continue
|
||||
##ob = bpy.data.objects.new("dual_mesh_wip", ob0.data.copy())
|
||||
ob = ob0
|
||||
mesh_name = ob0.data.name
|
||||
|
||||
|
@ -96,31 +113,33 @@ class dual_mesh(bpy.types.Operator):
|
|||
count+=1
|
||||
clones.append(o)
|
||||
if count == n_users: break
|
||||
if self.apply_modifiers: bpy.ops.object.convert(target='MESH')
|
||||
ob.data = ob.data.copy()
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
ob.select = True
|
||||
bpy.context.scene.objects.active = ob0
|
||||
bpy.ops.object.mode_set(mode = 'EDIT')
|
||||
|
||||
if self.preserve_borders:
|
||||
bpy.ops.mesh.select_mode(
|
||||
use_extend=False, use_expand=False, type='EDGE')
|
||||
bpy.ops.mesh.select_non_manifold(
|
||||
extend=False, use_wire=False, use_boundary=True,
|
||||
use_multi_face=False, use_non_contiguous=False,
|
||||
use_verts=False)
|
||||
bpy.ops.mesh.extrude_region_move(
|
||||
MESH_OT_extrude_region={"mirror":False},
|
||||
TRANSFORM_OT_translate={"value":(0, 0, 0),
|
||||
"constraint_axis":(False, False, False),
|
||||
"constraint_orientation":'GLOBAL', "mirror":False,
|
||||
"proportional":'DISABLED',
|
||||
"proportional_edit_falloff":'SMOOTH', "proportional_size":1,
|
||||
"snap":False, "snap_target":'CLOSEST',
|
||||
"snap_point":(0, 0, 0), "snap_align":False,
|
||||
"snap_normal":(0, 0, 0), "gpencil_strokes":False,
|
||||
"texture_space":False, "remove_on_cancel":False,
|
||||
"release_confirm":False})
|
||||
# prevent borders erosion
|
||||
bpy.ops.mesh.select_mode(
|
||||
use_extend=False, use_expand=False, type='EDGE')
|
||||
bpy.ops.mesh.select_non_manifold(
|
||||
extend=False, use_wire=False, use_boundary=True,
|
||||
use_multi_face=False, use_non_contiguous=False,
|
||||
use_verts=False)
|
||||
bpy.ops.mesh.extrude_region_move(
|
||||
MESH_OT_extrude_region={"mirror":False},
|
||||
TRANSFORM_OT_translate={"value":(0, 0, 0),
|
||||
"constraint_axis":(False, False, False),
|
||||
"constraint_orientation":'GLOBAL', "mirror":False,
|
||||
"proportional":'DISABLED',
|
||||
"proportional_edit_falloff":'SMOOTH', "proportional_size":1,
|
||||
"snap":False, "snap_target":'CLOSEST',
|
||||
"snap_point":(0, 0, 0), "snap_align":False,
|
||||
"snap_normal":(0, 0, 0), "gpencil_strokes":False,
|
||||
"texture_space":False, "remove_on_cancel":False,
|
||||
"release_confirm":False})
|
||||
|
||||
|
||||
bpy.ops.mesh.select_mode(
|
||||
use_extend=False, use_expand=False, type='VERT',
|
||||
|
@ -132,6 +151,9 @@ class dual_mesh(bpy.types.Operator):
|
|||
bpy.ops.object.mode_set(mode = 'OBJECT')
|
||||
bpy.ops.object.modifier_add(type='SUBSURF')
|
||||
ob.modifiers[-1].name = "dual_mesh_subsurf"
|
||||
while True:
|
||||
bpy.ops.object.modifier_move_up(modifier="dual_mesh_subsurf")
|
||||
if ob.modifiers[0].name == "dual_mesh_subsurf": break
|
||||
bpy.ops.object.modifier_apply(
|
||||
apply_as='DATA', modifier='dual_mesh_subsurf')
|
||||
|
||||
|
@ -199,6 +221,14 @@ class dual_mesh(bpy.types.Operator):
|
|||
bpy.ops.mesh.dissolve_verts()
|
||||
bpy.ops.mesh.select_all(action = 'DESELECT')
|
||||
|
||||
# remove border faces
|
||||
if not self.preserve_borders:
|
||||
bpy.ops.mesh.select_non_manifold(
|
||||
extend=False, use_wire=False, use_boundary=True,
|
||||
use_multi_face=False, use_non_contiguous=False, use_verts=False)
|
||||
bpy.ops.mesh.select_more()
|
||||
bpy.ops.mesh.delete(type='FACE')
|
||||
|
||||
# clean wires
|
||||
bpy.ops.mesh.select_non_manifold(
|
||||
extend=False, use_wire=True, use_boundary=False,
|
||||
|
@ -211,16 +241,16 @@ class dual_mesh(bpy.types.Operator):
|
|||
for o in clones: o.data = ob.data
|
||||
for o in sel: o.select = True
|
||||
bpy.context.scene.objects.active = act
|
||||
bpy.ops.object.mode_set(mode=mode)
|
||||
return {'FINISHED'}
|
||||
|
||||
'''
|
||||
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
|
||||
|
@ -232,14 +262,15 @@ class dual_mesh_panel(bpy.types.Panel):
|
|||
pass
|
||||
'''
|
||||
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(dual_mesh)
|
||||
# bpy.utils.register_class(dual_mesh_panel)
|
||||
#bpy.utils.register_class(dual_mesh_panel)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(dual_mesh)
|
||||
# bpy.utils.unregister_class(dual_mesh_panel)
|
||||
#bpy.utils.unregister_class(dual_mesh_panel)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -252,6 +252,9 @@ class lattice_along_surface(bpy.types.Operator):
|
|||
col.prop(self, "set_parent")
|
||||
|
||||
def execute(self, context):
|
||||
if len(bpy.context.selected_objects) != 2:
|
||||
self.report({'ERROR'}, "Please, select two objects")
|
||||
return {'CANCELLED'}
|
||||
grid_obj = bpy.context.active_object
|
||||
if grid_obj.type not in ('MESH', 'CURVE', 'SURFACE'):
|
||||
self.report({'ERROR'}, "The surface object is not valid. Only Mesh,"
|
||||
|
@ -278,6 +281,12 @@ class lattice_along_surface(bpy.types.Operator):
|
|||
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
||||
grid_mesh = grid_obj.to_mesh(bpy.context.scene, apply_modifiers=True,
|
||||
settings = 'PREVIEW')
|
||||
if len(grid_mesh.polygons) > 64*64:
|
||||
bpy.ops.object.delete(use_global=False)
|
||||
bpy.context.scene.objects.active = obj
|
||||
obj.select = True
|
||||
self.report({'ERROR'}, "Maximum resolution allowed for Lattice is 64")
|
||||
return {'CANCELLED'}
|
||||
# CREATING LATTICE
|
||||
min = Vector((0,0,0))
|
||||
max = Vector((0,0,0))
|
||||
|
@ -358,6 +367,7 @@ class lattice_along_surface(bpy.types.Operator):
|
|||
bpy.ops.object.modifier_remove(modifier=obj.modifiers[-1].name)
|
||||
if nu > 64 or nv > 64:
|
||||
self.report({'ERROR'}, "Maximum resolution allowed for Lattice is 64")
|
||||
return {'CANCELLED'}
|
||||
else:
|
||||
self.report({'ERROR'}, "The grid mesh is not correct")
|
||||
return {'CANCELLED'}
|
||||
|
@ -397,7 +407,6 @@ class lattice_along_surface_panel(bpy.types.Panel):
|
|||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "TOOLS"
|
||||
bl_context = (("objectmode"))
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@ -408,14 +417,15 @@ class lattice_along_surface_panel(bpy.types.Panel):
|
|||
pass
|
||||
'''
|
||||
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(lattice_along_surface)
|
||||
# bpy.utils.register_class(lattice_along_surface_panel)
|
||||
#bpy.utils.register_class(lattice_along_surface_panel)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(lattice_along_surface)
|
||||
# bpy.utils.unregister_class(lattice_along_surface_panel)
|
||||
#bpy.utils.unregister_class(lattice_along_surface_panel)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1248,22 +1248,26 @@ class settings_tessellate(bpy.types.Operator):
|
|||
|
||||
|
||||
class tessellate_panel(bpy.types.Panel):
|
||||
bl_label = "Tessellate/Dual"
|
||||
bl_label = "Tissue"
|
||||
bl_category = "Create"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "TOOLS"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
#bl_context = "objectmode", "editmode"
|
||||
#bl_context = "objectmode"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.mode in {'OBJECT', 'EDIT_MESH'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Add:")
|
||||
col.label(text="Tessellate Add:")
|
||||
col.operator("object.tessellate")#, icon="STRANDS")
|
||||
#col.enable = False
|
||||
#col.operator("object.adaptive_duplifaces", icon="MESH_CUBE")
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Edit:")
|
||||
col.label(text="Tessellate Edit:")
|
||||
col.operator("object.settings_tessellate")
|
||||
col.operator("object.update_tessellate")
|
||||
col = layout.column(align=True)
|
||||
|
@ -1274,12 +1278,12 @@ class tessellate_panel(bpy.types.Panel):
|
|||
for ob1 in context.selected_objects:
|
||||
if(ob1.name == act.name or ob1.type != 'MESH'): continue
|
||||
sel = ob1
|
||||
try:
|
||||
if bpy.context.active_object.type == 'MESH':
|
||||
col.label(text="Dual Mesh:")
|
||||
col.operator("object.dual_mesh")
|
||||
except:
|
||||
pass
|
||||
|
||||
col.separator()
|
||||
col.label(text="Add Modifier:")
|
||||
col.operator("object.lattice_along_surface", icon="OUTLINER_OB_LATTICE")
|
||||
|
||||
|
||||
|
||||
class rotate_face(bpy.types.Operator):
|
||||
bl_idname = "mesh.rotate_face"
|
||||
|
|
Loading…
Reference in New Issue