This repository was archived by the owner on Dec 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpolystrips_draw.py
70 lines (57 loc) · 2.33 KB
/
polystrips_draw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'''
Copyright (C) 2014 CG Cookie
http://cgcookie.com
Created by Jonathan Denning, Jonathan Williamson, and Patrick Moore
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
####class definitions####
import bpy
import math
import time
import copy
from mathutils import Vector, Quaternion, Matrix
from mathutils.geometry import intersect_point_line, intersect_line_plane
from bpy_extras.view3d_utils import location_3d_to_region_2d, region_2d_to_vector_3d, region_2d_to_location_3d, region_2d_to_origin_3d
import bmesh
import blf
import bgl
import itertools
from lib import common_utilities
from lib import common_drawing
from lib.common_utilities import iter_running_sum, dprint, get_object_length_scale, profiler, AddonLocator
from polystrips_utilities import *
#Make the addon name and location accessible
AL = AddonLocator()
def draw_gedge_text(gedge,context, text):
l = len(gedge.cache_igverts)
if l > 4:
n_quads = math.floor(l/2) + 1
mid_vert_ind = math.floor(l/2)
mid_vert = gedge.cache_igverts[mid_vert_ind]
position_3d = mid_vert.position + 1.5 * mid_vert.tangent_y * mid_vert.radius
else:
position_3d = (gedge.gvert0.position + gedge.gvert3.position)/2
position_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d,position_3d)
txt_width, txt_height = blf.dimensions(0, text)
blf.position(0, position_2d[0]-(txt_width/2), position_2d[1]-(txt_height/2), 0)
blf.draw(0, text)
def draw_gedge_info(gedge,context):
'''
helper draw module to display info about the Gedge
'''
l = len(gedge.cache_igverts)
if l > 4:
n_quads = math.floor(l/2) + 1
else:
n_quads = 3
draw_gedge_text(gedge, context, str(n_quads))