Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2019-10-25 00:37:48 +0300
committerSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2019-10-25 00:37:48 +0300
commit5716f119e348c61f5da1bc5513029591fc381b47 (patch)
tree47b473bb1969fca74c2212805c2b9891b09a8f91 /mesh_bsurfaces.py
parentd92964b0e5035e4532b539137e937591eba88b26 (diff)
Addon: BSurfaces: Added shade smooth and added show wire
Diffstat (limited to 'mesh_bsurfaces.py')
-rw-r--r--mesh_bsurfaces.py107
1 files changed, 103 insertions, 4 deletions
diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index 504e17de..d896d71f 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -20,11 +20,12 @@
bl_info = {
"name": "Bsurfaces GPL Edition",
"author": "Eclectiel, Spivak Vladimir(cwolf3d)",
- "version": (1, 7, 4),
+ "version": (1, 7, 5),
"blender": (2, 80, 0),
"location": "View3D EditMode > Sidebar > Edit Tab",
"description": "Modeling and retopology tool",
- "wiki_url": "https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Bsurfaces_1.5",
+ "wiki_url": "https://docs.blender.org/manual/nb/dev/addons/"
+ "mesh/bsurfaces.html",
"category": "Mesh",
}
@@ -62,9 +63,11 @@ from bpy.types import (
# ----------------------------
# GLOBAL
-global_color = [1.0, 0.0, 0.0, 1.0]
+global_color = [1.0, 0.0, 0.0, 0.3]
global_offset = 0.01
global_in_front = False
+global_shade_smooth = False
+global_show_wire = True
global_mesh_object = ""
global_gpencil_object = ""
global_curve_object = ""
@@ -92,6 +95,8 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
col.prop(scn, "SURFSK_mesh_color")
col.prop(scn, "SURFSK_Shrinkwrap_offset")
col.prop(scn, "SURFSK_in_front")
+ col.prop(scn, "SURFSK_shade_smooth")
+ col.prop(scn, "SURFSK_show_wire")
col.label(text="Guide strokes:")
col.row().prop(scn, "SURFSK_guide", expand=True)
@@ -1056,6 +1061,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='EDIT')
bpy.ops.mesh.normals_make_consistent(inside=False)
bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT')
+
+ self.update()
return num_faces_created
@@ -1397,6 +1404,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
for m_idx in range(len(self.main_object.modifiers)):
self.main_object.modifiers[m_idx].show_viewport = self.modifiers_prev_viewport_state[m_idx]
+ self.update()
+
return
# Part of the Crosshatch process that is repeated when the operator is tweaked
@@ -1767,6 +1776,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
for m_idx in range(len(self.main_object.modifiers)):
self.main_object.modifiers[m_idx].show_viewport = self.modifiers_prev_viewport_state[m_idx]
+ self.update()
+
return {'FINISHED'}
def rectangular_surface(self, context):
@@ -3068,6 +3079,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.mesh.normals_make_consistent('INVOKE_REGION_WIN', inside=False)
bpy.ops.mesh.select_all('INVOKE_REGION_WIN', action='DESELECT')
+ self.update()
+
return{'FINISHED'}
def update(self):
@@ -3087,12 +3100,32 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
else:
self.main_object.data.materials.append(material)
bpy.context.scene.bsurfaces.SURFSK_mesh_color = global_color
+ except:
+ pass
+ try:
global global_in_front
self.main_object.show_in_front = global_in_front
bpy.context.scene.bsurfaces.SURFSK_in_front = global_in_front
except:
pass
+
+ try:
+ global global_show_wire
+ self.main_object.show_wire = global_show_wire
+ bpy.context.scene.bsurfaces.SURFSK_show_wire = global_show_wire
+ except:
+ pass
+
+ try:
+ global global_shade_smooth
+ if global_shade_smooth:
+ bpy.ops.object.shade_smooth()
+ else:
+ bpy.ops.object.shade_flat()
+ bpy.context.scene.bsurfaces.SURFSK_shade_smooth = global_shade_smooth
+ except:
+ pass
return{'FINISHED'}
@@ -3162,6 +3195,14 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
self.rectangular_surface(context)
elif strokes_for_crosshatch:
self.crosshatch_surface_execute(context)
+
+ #Set Shade smooth to new polygons
+ bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT')
+ global global_shade_smooth
+ if global_shade_smooth:
+ bpy.ops.object.shade_smooth()
+ else:
+ bpy.ops.object.shade_flat()
# Delete main splines
bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT')
@@ -3498,6 +3539,8 @@ class GPENCIL_OT_SURFSK_init(Operator):
global global_color
global global_offset
global global_in_front
+ global global_show_wire
+ global global_shade_smooth
global global_mesh_object
global global_gpencil_object
@@ -3514,6 +3557,15 @@ class GPENCIL_OT_SURFSK_init(Operator):
mesh_object.display_type = 'SOLID'
mesh_object.show_wire = True
+ global_shade_smooth = bpy.context.scene.bsurfaces.SURFSK_shade_smooth
+ if global_shade_smooth:
+ bpy.ops.object.shade_smooth()
+ else:
+ bpy.ops.object.shade_flat()
+
+ global_show_wire = bpy.context.scene.bsurfaces.SURFSK_show_wire
+ mesh_object.show_wire = global_show_wire
+
global_color = bpy.context.scene.bsurfaces.SURFSK_mesh_color
material = makeMaterial("BSurfaceMesh", global_color)
mesh_object.data.materials.append(material)
@@ -4405,6 +4457,41 @@ def update_in_front(self, context):
bpy.data.objects[global_mesh_object].show_in_front = global_in_front
except Exception as e:
print("Select mesh object")
+
+def update_show_wire(self, context):
+ try:
+ global global_show_wire
+ global_show_wire = bpy.context.scene.bsurfaces.SURFSK_show_wire
+ global global_mesh_object
+ bpy.data.objects[global_mesh_object].show_wire = global_show_wire
+ except Exception as e:
+ print("Select mesh object")
+
+def update_shade_smooth(self, context):
+ try:
+ global global_shade_smooth
+ global_shade_smooth = bpy.context.scene.bsurfaces.SURFSK_shade_smooth
+
+ contex_mode = bpy.context.mode
+
+ if bpy.ops.object.mode_set.poll():
+ bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT')
+
+ bpy.ops.object.select_all(action='DESELECT')
+ global global_mesh_object
+ global_mesh_object = bpy.context.scene.bsurfaces.SURFSK_mesh.name
+ bpy.data.objects[global_mesh_object].select_set(True)
+
+ if global_shade_smooth:
+ bpy.ops.object.shade_smooth()
+ else:
+ bpy.ops.object.shade_flat()
+
+ if contex_mode == "EDIT_MESH":
+ bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
+
+ except Exception as e:
+ print("Select mesh object")
class BsurfPreferences(AddonPreferences):
@@ -4505,7 +4592,7 @@ class BsurfacesProps(PropertyGroup):
)
SURFSK_mesh_color: FloatVectorProperty(
name="Mesh color",
- default=(1.0, 0.0, 0.0, 1.0),
+ default=(1.0, 0.0, 0.0, 0.3),
size=4,
subtype="COLOR",
min=0,
@@ -4526,6 +4613,18 @@ class BsurfacesProps(PropertyGroup):
default=False,
update=update_in_front,
)
+ SURFSK_show_wire: BoolProperty(
+ name="Show wire",
+ description="Add the object’s wireframe over solid drawing",
+ default=False,
+ update=update_show_wire,
+ )
+ SURFSK_shade_smooth: BoolProperty(
+ name="Shade smooth",
+ description="Render and display faces smooth, using interpolated Vertex Normals",
+ default=False,
+ update=update_shade_smooth,
+ )
classes = (
GPENCIL_OT_SURFSK_init,