[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3405] trunk/py/scripts/addons/ mesh_bsurfaces.py: Update from version 0.9 to version 1.5 .
Eclectiel L
eclect25 at yahoo.com
Sun May 27 17:14:09 CEST 2012
Revision: 3405
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3405
Author: eclectiel
Date: 2012-05-27 15:14:08 +0000 (Sun, 27 May 2012)
Log Message:
-----------
Update from version 0.9 to version 1.5 .
Modified Paths:
--------------
trunk/py/scripts/addons/mesh_bsurfaces.py
Modified: trunk/py/scripts/addons/mesh_bsurfaces.py
===================================================================
--- trunk/py/scripts/addons/mesh_bsurfaces.py 2012-05-27 09:38:39 UTC (rev 3404)
+++ trunk/py/scripts/addons/mesh_bsurfaces.py 2012-05-27 15:14:08 UTC (rev 3405)
@@ -2,8 +2,8 @@
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+# as published by the Free Software Foundation; version 2
+# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,64 +16,242 @@
#
# ##### END GPL LICENSE BLOCK #####
+
bl_info = {
"name": "Bsurfaces GPL Edition",
"author": "Eclectiel",
- "version": (0,9),
- "blender": (2, 5, 7),
+ "version": (1,5),
+ "blender": (2, 6, 3),
+ "api": 45996,
"location": "View3D > EditMode > ToolShelf",
- "description": "Draw meshes and re-topologies with Grease Pencil",
- "warning": "Beta",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
- "Scripts/Mesh/Surface_Sketch",
- "tracker_url": "https://projects.blender.org/tracker/index.php?"\
- "func=detail&aid=26642&group_id=153&atid=469",
+ "description": "Modeling and retopology tool.",
+ "wiki_url": "http://www.bsurfaces.info",
+ "tracker_url": "https://",
"category": "Mesh"}
+
-
import bpy
+import bmesh
import math
+import mathutils
+import operator
from math import *
-
-class VIEW3D_PT_tools_SURF_SKETCH(bpy.types.Panel):
+
+
+
+class VIEW3D_PT_tools_SURFSK_mesh(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
-
bl_context = "mesh_edit"
bl_label = "Bsurfaces"
@classmethod
def poll(cls, context):
return context.active_object
-
+
+
def draw(self, context):
layout = self.layout
scn = context.scene
+ ob = context.object
col = layout.column(align=True)
+ row = layout.row()
+ row.separator()
col.operator("gpencil.surfsk_add_surface", text="Add Surface")
- col.prop(scn, "SURFSK_edges_U")
- col.prop(scn, "SURFSK_edges_V")
+ col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
+ col.prop(scn, "SURFSK_cyclic_cross")
+ col.prop(scn, "SURFSK_cyclic_follow")
+ col.prop(scn, "SURFSK_loops_on_strokes")
+ col.prop(scn, "SURFSK_automatic_join")
+ col.prop(scn, "SURFSK_keep_strokes")
- layout.prop(scn, "SURFSK_keep_strokes")
- layout.operator("gpencil.surfsk_strokes_to_curves", text="Strokes to curves")
+
+class VIEW3D_PT_tools_SURFSK_curve(bpy.types.Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'TOOLS'
+ bl_context = "curve_edit"
+ bl_label = "Bsurfaces"
+
+ @classmethod
+ def poll(cls, context):
+ return context.active_object
+
+
+ def draw(self, context):
+ layout = self.layout
+
+ scn = context.scene
+ ob = context.object
+
+ col = layout.column(align=True)
+ row = layout.row()
+ row.separator()
+ col.operator("curve.surfsk_first_points", text="Set First Points")
+ col.operator("curve.switch_direction", text="Switch Direction")
+ col.operator("curve.surfsk_reorder_splines", text="Reorder Splines")
+
+
+
+#### Returns the type of strokes used.
+def get_strokes_type(main_object):
+ strokes_type = ""
+ strokes_num = 0
+
+ # Check if they are grease pencil
+ try:
+ #### Get the active grease pencil layer.
+ strokes_num = len(main_object.grease_pencil.layers.active.active_frame.strokes)
+
+ if strokes_num > 0:
+ strokes_type = "GP_STROKES"
+ except:
+ pass
+
+
+ # Check if they are curves, if there aren't grease pencil strokes.
+ if strokes_type == "":
+ if len(bpy.context.selected_objects) == 2:
+ for ob in bpy.context.selected_objects:
+ if ob != bpy.context.scene.objects.active and ob.type == "CURVE":
+ strokes_type = "EXTERNAL_CURVE"
+ strokes_num = len(ob.data.splines)
+
+ # Check if there is any non-bezier spline.
+ for i in range(len(ob.data.splines)):
+ if ob.data.splines[i].type != "BEZIER":
+ strokes_type = "CURVE_WITH_NON_BEZIER_SPLINES"
+ break
+
+ elif ob != bpy.context.scene.objects.active and ob.type != "CURVE":
+ strokes_type = "EXTERNAL_NO_CURVE"
+ elif len(bpy.context.selected_objects) > 2:
+ strokes_type = "MORE_THAN_ONE_EXTERNAL"
+
+
+ # Check if there is a single stroke without any selection in the object.
+ if strokes_num == 1 and main_object.data.total_vert_sel == 0:
+ if strokes_type == "EXTERNAL_CURVE":
+ strokes_type = "SINGLE_CURVE_STROKE_NO_SELECTION"
+ elif strokes_type == "GP_STROKES":
+ strokes_type = "SINGLE_GP_STROKE_NO_SELECTION"
+
+ if strokes_num == 0 and main_object.data.total_vert_sel > 0:
+ strokes_type = "SELECTION_ALONE"
+
+
+ if strokes_type == "":
+ strokes_type = "NO_STROKES"
+
+
+
+ return strokes_type
+
+
+
+
+# Surface generator operator.
class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
bl_idname = "gpencil.surfsk_add_surface"
bl_label = "Bsurfaces add surface"
- bl_description = "Generates a surface from grease pencil strokes or from curves"
+ bl_description = "Generates surfaces from grease pencil strokes, bezier curves or loose edges."
bl_options = {'REGISTER', 'UNDO'}
- ##### Get an ordered list of a chain of vertices.
- def get_ordered_verts(self, ob, all_selected_edges_idx, all_selected_verts_idx, first_vert_idx, middle_vertex_idx):
- # Order selected vertexes.
+ edges_U = bpy.props.IntProperty(name = "Cross",
+ description = "Number of face-loops crossing the strokes.",
+ default = 1,
+ min = 1,
+ max = 200)
+
+ edges_V = bpy.props.IntProperty(name = "Follow",
+ description = "Number of face-loops following the strokes.",
+ default = 1,
+ min = 1,
+ max = 200)
+
+ cyclic_cross = bpy.props.BoolProperty(name = "Cyclic Cross",
+ description = "Make cyclic the face-loops crossing the strokes.",
+ default = False)
+
+ cyclic_follow = bpy.props.BoolProperty(name = "Cyclic Follow",
+ description = "Make cyclic the face-loops following the strokes.",
+ default = False)
+
+ loops_on_strokes = bpy.props.BoolProperty(name = "Loops on strokes",
+ description = "Make the loops match the paths of the strokes.",
+ default = False)
+
+ automatic_join = bpy.props.BoolProperty(name = "Automatic join",
+ description = "Join automatically vertices of either surfaces generated by crosshatching, or from the borders of closed shapes.",
+ default = False)
+
+ join_stretch_factor = bpy.props.FloatProperty(name = "Stretch",
+ description = "Amount of stretching or shrinking allowed for edges when joining vertices automatically.",
+ default = 1,
+ min = 0,
+ max = 3,
+ subtype = 'FACTOR')
+
+
+
+
+ def draw(self, context):
+ layout = self.layout
+
+ scn = context.scene
+ ob = context.object
+
+ col = layout.column(align=True)
+ row = layout.row()
+
+ if not self.is_fill_faces:
+ row.separator()
+ if not self.is_crosshatch:
+ if not self.selection_U_exists:
+ col.prop(self, "edges_U")
+ row.separator()
+
+ if not self.selection_V_exists:
+ col.prop(self, "edges_V")
+ row.separator()
+
+ row.separator()
+
+ if not self.selection_U_exists:
+ if not ((self.selection_V_exists and not self.selection_V_is_closed) or (self.selection_V2_exists and not self.selection_V2_is_closed)):
+ col.prop(self, "cyclic_cross")
+
+ if not self.selection_V_exists:
+ if not ((self.selection_U_exists and not self.selection_U_is_closed) or (self.selection_U2_exists and not self.selection_U2_is_closed)):
+ col.prop(self, "cyclic_follow")
+
+
+ col.prop(self, "loops_on_strokes")
+
+ col.prop(self, "automatic_join")
+
+ if self.automatic_join:
+ row.separator()
+ col.separator()
+ row.separator()
+ col.prop(self, "join_stretch_factor")
+
+
+
+ #### Get an ordered list of a chain of vertices.
+ def get_ordered_verts(self, ob, all_selected_edges_idx, all_selected_verts_idx, first_vert_idx, middle_vertex_idx, closing_vert_idx):
+ # Order selected vertices.
verts_ordered = []
- verts_ordered.append(self.main_object.data.vertices[first_vert_idx])
+ if closing_vert_idx != None:
+ verts_ordered.append(ob.data.vertices[closing_vert_idx])
+
+ verts_ordered.append(ob.data.vertices[first_vert_idx])
prev_v = first_vert_idx
prev_ed = None
finish_while = False
@@ -81,11 +259,11 @@
edges_non_matched = 0
for i in all_selected_edges_idx:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list