def draw(self, context): # draw connecting line points = [(self.head.x, self.head.y), (self.tail.x, self.tail.y)] contour_utilities.draw_polyline_from_points(context, points, (0, 0.5, 1, 1), 1, "GL_LINE_STIPPLE") # draw head #draw tail contour_utilities.draw_points(context, points, (1, 0, 0.2, 1), 5)
def draw(self,context, settings): ''' setings are the addon preferences for contour tools ''' debug = settings.debug #settings = context.user_preferences.addons['contour_tools'].preferences #this should be moved to only happen if the view changes :-/ I'ts only #a few hundred calcs even with a lot of lines. Waste not want not. if self.head.world_position: self.head.screen_from_world(context) if self.tail.world_position: self.tail.screen_from_world(context) if self.plane_tan.world_position: self.plane_tan.screen_from_world(context) #draw connecting line points = [(self.head.x,self.head.y),(self.tail.x,self.tail.y)] if settings.show_edges: contour_utilities.draw_polyline_from_points(context, points, (0,.2,1,1), settings.line_thick, "GL_LINE_STIPPLE") #draw the two handles contour_utilities.draw_points(context, points, self.head.color, settings.handle_size) #draw the current plane point and the handle to change plane orientation if self.plane_pt: point1 = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_pt) point2 = (self.plane_tan.x, self.plane_tan.y) if settings.show_edges: contour_utilities.draw_polyline_from_points(context, [point1,point2], (0,.2,1,1), settings.line_thick, "GL_LINE_STIPPLE") contour_utilities.draw_points(context, [point2], self.plane_tan.color, settings.handle_size) contour_utilities.draw_points(context, [point1], self.head.color, settings.handle_size) #draw the raw contour vertices if (self.verts and self.verts_simple == []) or (debug > 0 and settings.show_verts): contour_utilities.draw_3d_points(context, self.verts, (0,1,.2,1), settings.raw_vert_size) #draw the simplified contour vertices and edges (rings) if self.verts_simple: points = self.verts_simple.copy() if 0 in self.eds[-1]: points.append(self.verts_simple[0]) if settings.show_ring_edges: contour_utilities.draw_polyline_from_3dpoints(context, points, (0,1,.2,1), settings.line_thick,"GL_LINE_STIPPLE") contour_utilities.draw_3d_points(context, self.verts_simple, (0,.2,1,1), settings.vert_size) if debug: if settings.vert_inds: for i, point in enumerate(self.verts): loc = location_3d_to_region_2d(context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i)) if settings.simple_vert_inds: for i, point in enumerate(self.verts_simple): loc = location_3d_to_region_2d(context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i))
def draw(self,context, settings, three_dimensional = True): ''' setings are the addon preferences for contour tools ''' debug = settings.debug #settings = context.user_preferences.addons['contour_tools'].preferences #this should be moved to only happen if the view changes :-/ I'ts only #a few hundred calcs even with a lot of lines. Waste not want not. if self.head and self.head.world_position: self.head.screen_from_world(context) if self.tail and self.tail.world_position: self.tail.screen_from_world(context) #if self.plane_tan.world_position: #self.plane_tan.screen_from_world(context) if debug > 1: if self.plane_com: com_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_com) contour_utilities.draw_3d_points(context, [self.plane_com], (0,1,0,1), 4) if self.vec_x: pt_x = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_com + self.vec_x) screen_vec_x = pt_x - com_2d screen_pt_x = com_2d + 40 * screen_vec_x.normalized() contour_utilities.draw_points(context, [pt_x], (1,1,0,1), 6) if self.vec_y: pt_y = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_com + self.vec_y) screen_vec_y = pt_y - com_2d screen_pt_y = com_2d + 40 * screen_vec_y.normalized() contour_utilities.draw_points(context, [pt_y], (0,1,1,1), 6) if self.plane_no: pt_z = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_com + self.plane_no) screen_vec_z = pt_z - com_2d screen_pt_z = com_2d + 40 * screen_vec_z.normalized() contour_utilities.draw_points(context, [pt_z], (1,0,1,1), 6) #draw connecting line if self.head: points = [(self.head.x,self.head.y),(self.tail.x,self.tail.y)] contour_utilities.draw_polyline_from_points(context, points, (0,.2,1,1), settings.stroke_thick, "GL_LINE_STIPPLE") #draw the two handles contour_utilities.draw_points(context, points, self.head.color, settings.handle_size) #draw the current plane point and the handle to change plane orientation #if self.plane_pt and settings.draw_widget: #point1 = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_pt) #point2 = (self.plane_tan.x, self.plane_tan.y) #contour_utilities.draw_polyline_from_points(context, [point1,point2], (0,.2,1,1), settings.stroke_thick, "GL_LINE_STIPPLE") #contour_utilities.draw_points(context, [point2], self.plane_tan.color, settings.handle_size) #contour_utilities.draw_points(context, [point1], self.head.color, settings.handle_size) #draw the raw contour vertices if (self.verts and self.verts_simple == []) or (debug > 0 and settings.show_verts): if three_dimensional: contour_utilities.draw_3d_points(context, self.verts, self.vert_color, settings.raw_vert_size) else: contour_utilities.draw_points(context, self.verts_screen, self.vert_color, settings.raw_vert_size) #draw the simplified contour vertices and edges (rings) if self.verts !=[] and self.eds != []: if three_dimensional: points = self.verts_simple.copy() else: points = self.verts_simple_screen.copy() if 0 in self.eds[-1]: points.append(points[0]) #draw the ring #draw the points over it if settings.show_ring_edges: if three_dimensional: contour_utilities.draw_polyline_from_3dpoints(context, points, self.geom_color, settings.line_thick,"GL_LINE_STIPPLE") contour_utilities.draw_3d_points(context, points, self.vert_color, settings.vert_size) else: contour_utilities.draw_polyline_from_points(context, points, self.geom_color, settings.line_thick,"GL_LINE_STIPPLE") contour_utilities.draw_points(context,points, self.vert_color, settings.vert_size) if debug: if settings.vert_inds: for i, point in enumerate(self.verts): loc = location_3d_to_region_2d(context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i)) if settings.simple_vert_inds: for i, point in enumerate(self.verts_simple): loc = location_3d_to_region_2d(context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i))
def draw(self, context, settings): ''' setings are the addon preferences for contour tools ''' debug = settings.debug #settings = context.user_preferences.addons['contour_tools'].preferences #this should be moved to only happen if the view changes :-/ I'ts only #a few hundred calcs even with a lot of lines. Waste not want not. if self.head.world_position: self.head.screen_from_world(context) if self.tail.world_position: self.tail.screen_from_world(context) if self.plane_tan.world_position: self.plane_tan.screen_from_world(context) #draw connecting line points = [(self.head.x, self.head.y), (self.tail.x, self.tail.y)] if settings.show_edges: contour_utilities.draw_polyline_from_points( context, points, (0, .2, 1, 1), settings.line_thick, "GL_LINE_STIPPLE") #draw the two handles contour_utilities.draw_points(context, points, self.head.color, settings.handle_size) #draw the current plane point and the handle to change plane orientation if self.plane_pt: point1 = location_3d_to_region_2d(context.region, context.space_data.region_3d, self.plane_pt) point2 = (self.plane_tan.x, self.plane_tan.y) if settings.show_edges: contour_utilities.draw_polyline_from_points( context, [point1, point2], (0, .2, 1, 1), settings.line_thick, "GL_LINE_STIPPLE") contour_utilities.draw_points(context, [point2], self.plane_tan.color, settings.handle_size) contour_utilities.draw_points(context, [point1], self.head.color, settings.handle_size) #draw the raw contour vertices if (self.verts and self.verts_simple == []) or (debug > 0 and settings.show_verts): contour_utilities.draw_3d_points(context, self.verts, (0, 1, .2, 1), settings.raw_vert_size) #draw the simplified contour vertices and edges (rings) if self.verts_simple: points = self.verts_simple.copy() if 0 in self.eds[-1]: points.append(self.verts_simple[0]) if settings.show_ring_edges: contour_utilities.draw_polyline_from_3dpoints( context, points, (0, 1, .2, 1), settings.line_thick, "GL_LINE_STIPPLE") contour_utilities.draw_3d_points(context, self.verts_simple, (0, .2, 1, 1), settings.vert_size) if debug: if settings.vert_inds: for i, point in enumerate(self.verts): loc = location_3d_to_region_2d( context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i)) if settings.simple_vert_inds: for i, point in enumerate(self.verts_simple): loc = location_3d_to_region_2d( context.region, context.space_data.region_3d, point) blf.position(0, loc[0], loc[1], 0) blf.draw(0, str(i))
def draw(self, context): settings = context.user_preferences.addons['contour_tools'].preferences if not self.transform: #draw wedges contour_utilities.draw_polyline_from_points(context, self.wedge_1, self.color, self.line_width, "GL_LINES") contour_utilities.draw_polyline_from_points(context, self.wedge_2, self.color, self.line_width, "GL_LINES") contour_utilities.draw_polyline_from_points(context, self.wedge_3, self.color, self.line_width, "GL_LINES") contour_utilities.draw_polyline_from_points(context, self.wedge_4, self.color, self.line_width, "GL_LINES") #draw arc 1 l = len(self.arc_arrow_1) contour_utilities.draw_polyline_from_points(context, self.arc_arrow_1[:l-1], self.color2, self.line_width, "GL_LINES") #draw a line perpendicular to arc point_1 = Vector((self.x,self.y)) + 2/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle), math.sin(self.angle))) point_2 = Vector((self.x,self.y)) + 1/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle), math.sin(self.angle))) contour_utilities.draw_polyline_from_points(context, [point_1, point_2], self.color3, self.line_width, "GL_LINES") #drawa arc 2 contour_utilities.draw_polyline_from_points(context, self.arc_arrow_2[:l-1], self.color2, self.line_width, "GL_LINES") #draw an up and down arrow point_1 = Vector((self.x,self.y)) + 2/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle + .5*math.pi), math.sin(self.angle + .5*math.pi))) point_2 = Vector((self.x,self.y)) + 1/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle + .5*math.pi), math.sin(self.angle + .5*math.pi))) contour_utilities.draw_polyline_from_points(context, [point_1, point_2], self.color, self.line_width, "GL_LINES") point_1 = Vector((self.x,self.y)) + 2/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle + 3/2 * math.pi), math.sin(self.angle + 3/2 * math.pi))) point_2 = Vector((self.x,self.y)) + 1/3 * (self.inner_radius + self.radius) * Vector((math.cos(self.angle + 3/2 * math.pi), math.sin(self.angle + 3/2 * math.pi))) contour_utilities.draw_polyline_from_points(context, [point_1, point_2], self.color, self.line_width, "GL_LINES") else: #draw a small inner circle contour_utilities.draw_polyline_from_points(context, self.inner_circle, self.color, self.line_width, "GL_LINES") if not settings.live_update: if self.transform_mode == "NORMAL_TRANSLATE": #draw a line representing the COM translation points = [self.initial_com, self.cut_line.plane_com] contour_utilities.draw_3d_points(context, points, self.color3, 4) contour_utilities.draw_polyline_from_3dpoints(context, points, self.color ,2 , "GL_STIPPLE") else: rv3d = context.space_data.region_3d view_x = rv3d.view_rotation * Vector((1,0,0)) p1 = self.cut_line.plane_com p2 = p1 + view_x p3 = p1 + self.cut_line.plane_no p1_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d, p1) p2_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d, p2) p3_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d, p3) vec_2d_scale = p1_2d - p2_2d screen_scale = self.radius / vec_2d_scale.length vec_2d = p1_2d - p3_2d p4_2d = p1_2d + screen_scale * vec_2d contour_utilities.draw_points(context, [p1_2d, p4_2d], self.color3, 5) contour_utilities.draw_polyline_from_points(context, [p1_2d, p4_2d], self.color ,2 , "GL_STIPPLE") #If self.transform_mode != #cut line, a user interactive 2d line which represents a plane in 3d splace #head (type conrol point) #tail (type control points) #target mesh #view_direction (crossed with line to make plane normal for slicing) #draw method #new control point project method #mouse hover line calc #retopo object, surface #colelction of cut lines #collection of countours to loft #n rings (crosses borrowed from looptools) #n follows (borrowed from looptools and or bsurfaces) #method contours from cutlines #method bridge contours