forked from leukbaars/DreamUV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
339 lines (289 loc) · 11.7 KB
/
__init__.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#this script is dedicated to the public domain under CC0 (https://creativecommons.org/publicdomain/zero/1.0/)
#do whatever you want with it!
#contributers:
#Bram Eulaers
#Jeiel Aranal (added pixel snapping!)
# TODO
#-precision mode for rotation
#-draw on screen handles that fit with Blender's transform tools
bl_info = {
"name": "DreamUV",
"category": "UV",
"author": "Bram Eulaers",
"description": "Edit selected faces'UVs directly inside the 3D Viewport. WIP. Check for updates @leukbaars",
"blender": (2, 80, 0),
"version": (0, 8)
}
if 'bpy' not in locals():
import bpy
from bpy.props import EnumProperty, BoolProperty, FloatProperty
from . import DUV_UVTranslate, DUV_UVRotate, DUV_UVScale, DUV_UVExtend, DUV_UVStitch, DUV_UVTransfer, DUV_UVCycle, DUV_UVMirror, DUV_UVMoveToEdge,DUV_Utils,DUV_HotSpot,DUV_UVProject,DUV_UVUnwrap
else:
from importlib import reload
reload(DUV_UVTranslate)
reload(DUV_UVRotate)
reload(DUV_UVScale)
reload(DUV_UVExtend)
reload(DUV_UVStitch)
reload(DUV_UVTransfer)
reload(DUV_UVCycle)
reload(DUV_UVMirror)
reload(DUV_UVMoveToEdge)
reload(DUV_HotSpot)
reload(DUV_UVProject)
reload(DUV_UVUnwrap)
reload(DUV_Utils)
uvmenutype = [("SUBMENU", "Submenu", ""),
("INDIVIDUAL", "Individual Entries", "")]
class DUVUVToolsPreferences(bpy.types.AddonPreferences):
bl_idname = __name__
pixel_snap = BoolProperty(
name="UV Pixel Snap",
description="Translate Pixel Snapping",
default=False
)
move_snap = FloatProperty(
name="UV Move Snap",
description="Translate Scale Subdivision Snap Size",
default=0.25
)
scale_snap = FloatProperty(
name="UV Scale Snap",
description="Scale Snap Size",
default=2
)
rotate_snap = FloatProperty(
name="UV Rotate Snap",
description="Rotate Angle Snap Size",
default=45
)
show_panel_tools = BoolProperty(
name="Show Tools in UV Panel",
default=True
)
#adduvmenu = BoolProperty(name="Add DUV UVTools to UV Menu", default=True)
#individualorsubmenu = EnumProperty(name="Individual or Sub-Menu", items=uvmenutype, default="SUBMENU")
def draw(self, context):
layout = self.layout
#column = layout.column(align=True)
#row = column.row()
#row.prop(self, "adduvmenu")
#if self.adduvmenu:
# row.prop(self, "individualorsubmenu", expand=True)
#column.prop(self, "show_panel_tools")
#column.prop(self, "pixel_snap")
class DUV_UVPanel(bpy.types.Panel):
"""DreamUV Tools Panel Test!"""
bl_label = "DreamUV"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'DreamUV'
bl_context = "mesh_edit"
@classmethod
def poll(cls, context):
prefs = bpy.context.preferences.addons[__name__].preferences
return prefs.show_panel_tools
def draw_header(self, _):
layout = self.layout
#layout.label(text="", icon='FACESEL_HLT')
def draw(self, context):
addon_prefs = prefs()
layout = self.layout
box = layout.box()
col = box.column(align=True)
col.label(text="Viewport UV Tools:")
row = col.row(align = True)
row.operator("uv.duv_uvtranslate", text="Move", icon="UV_SYNC_SELECT")
row = row.row(align = True)
row.prop(addon_prefs, 'move_snap', text="")
row = col.row(align = True)
op = row.operator("uv.duv_uvtranslatestep", text=" ", icon="TRIA_UP")
op.direction="up"
op = row.operator("uv.duv_uvtranslatestep", text=" ", icon="TRIA_DOWN")
op.direction="down"
op = row.operator("uv.duv_uvtranslatestep", text=" ", icon="TRIA_LEFT")
op.direction = "left"
op = row.operator("uv.duv_uvtranslatestep", text=" ", icon="TRIA_RIGHT")
op.direction = "right"
col.separator()
row = col.row(align = True)
row.operator("uv.duv_uvscale", text="Scale", icon="FULLSCREEN_ENTER")
row = row.row(align = True)
row.prop(addon_prefs, 'scale_snap', text="")
row = col.row(align = True)
op = row.operator("uv.duv_uvscalestep", text=" ", icon="ADD")
op.direction="+XY"
op = row.operator("uv.duv_uvscalestep", text=" ", icon="REMOVE")
op.direction="-XY"
op = row.operator("uv.duv_uvscalestep", text="+X")
op.direction = "+X"
op = row.operator("uv.duv_uvscalestep", text="-X")
op.direction = "-X"
op = row.operator("uv.duv_uvscalestep", text="+Y")
op.direction = "+Y"
op = row.operator("uv.duv_uvscalestep", text="-Y")
op.direction = "-Y"
col.separator()
row = col.row(align = True)
row.operator("uv.duv_uvrotate", text="Rotate", icon="FILE_REFRESH")
row = row.row(align = True)
row.prop(addon_prefs, 'rotate_snap', text="")
row = col.row(align = True)
op = row.operator("uv.duv_uvrotatestep", text=" ", icon="LOOP_FORWARDS")
op.direction="forward"
op = row.operator("uv.duv_uvrotatestep", text=" ", icon="LOOP_BACK")
op.direction="reverse"
col.separator()
col.operator("uv.duv_uvextend", text="Extend", icon="MOD_TRIANGULATE")
col.operator("uv.duv_uvstitch", text="Stitch", icon="UV_EDGESEL")
col.operator("uv.duv_uvcycle", text="Cycle", icon="FILE_REFRESH")
row = col.row(align = True)
op = row.operator("uv.duv_uvmirror", text="Mirror X", icon="MOD_MIRROR")
op.direction = "x"
op = row.operator("uv.duv_uvmirror", text="Mirror Y")
op.direction = "y"
# pixel snap not functional in 2.8
#layout.prop(addon_prefs, "pixel_snap", text = 'Move Pixel Snap')
#col.prop(addon_prefs, "pixel_snap", text = 'Move Pixel Snap', icon = 'FORCE_TEXTURE')
#box = layout.box()
#col = box.column(align=True)
col.label(text="Move to UV Edge:")
row = col.row(align = True)
op = row.operator("uv.duv_uvmovetoedge", text=" ", icon="TRIA_UP_BAR")
op.direction="up"
op = row.operator("uv.duv_uvmovetoedge", text=" ", icon="TRIA_DOWN_BAR")
op.direction="down"
op = row.operator("uv.duv_uvmovetoedge", text=" ", icon="TRIA_LEFT_BAR")
op.direction = "left"
op = row.operator("uv.duv_uvmovetoedge", text=" ", icon="TRIA_RIGHT_BAR")
op.direction = "right"
box = layout.box()
col = box.column(align=True)
col.label(text="Unwrapping Tools:")
col.operator("uv.duv_uvunwrapsquare", text="Square Fit Unwrap", icon="OUTLINER_OB_LATTICE")
unwraptool=col.operator("uv.unwrap", text="Blender Unwrap", icon='UV')
unwraptool.method='CONFORMAL'
unwraptool.margin=0.001
col.separator()
box = layout.box()
col = box.column(align=True)
col.label(text="UV Transfer Tool:")
row = col.row(align = True)
#row.label(text="minUV/maxUV:")
row.prop(context.scene, "uvtransferxmin", text="")
row.prop(context.scene, "uvtransferymin", text="")
row.prop(context.scene, "uvtransferxmax", text="")
row.prop(context.scene, "uvtransferymax", text="")
col.operator("uv.duv_uvtransfergrab", text="Grab UV from selection")
row = col.row(align = True)
row.operator("uv.duv_uvtransfer", text="Transfer to selection", icon="MOD_UVPROJECT")
#col.label(text="top right coord:")
#row = col.row(align = True)
col.separator()
box = layout.box()
col = box.column(align=True)
#col = self.layout.column(align = True)
col.label(text="HotSpot Tool:")
#col = self.layout.column(align = True)
row = col.row(align = True)
row.label(text="Atlas Object:")
row.prop_search(context.scene, "subrect_atlas", context.scene, "objects", text="", icon="MOD_MULTIRES")
col.separator()
col.operator("duv.hotspotter", text = "HotSpot", icon="SHADERFX")
col = self.layout.column(align = True)
#col.enabled = True
col2= self.layout.column(align = True)
col2.label(text="DreamUV Beta")
col2.enabled = False
col2.label(text="send feedback to @leukbaars!")
#col.operator("DUV.uvproject", text = "PROJECT!")
#class DUV_UVMenu(bpy.types.Menu):
# bl_label = "DUV UV Tools"
#
#
# def draw(self, context):
# layout = self.layout
#
# col = layout.column()
# col.operator("uv.duv_uvtranslate", text="UVTranslate", icon="MAN_TRANS")
# col.operator("uv.duv_uvrotate", text="UVRotate", icon="MAN_ROT")
# col.operator("uv.duv_uvscale", text="UVScale", icon="MAN_SCALE")
# col.operator("uv.duv_uvextend", text="UVExtend", icon="MOD_SHRINKWRAP")
# col.operator("uv.duv_uvstitch", text="UVStitch", icon="MOD_TRIANGULATE")
# col.operator("uv.duv_uvtransfer", text="Transfer", icon="MOD_UVPROJECT")
# col.operator("uv.duv_uvcycle", text="Transfer", icon="MOD_UVPROJECT")
#def uv_menu_func(self, context):
# if prefs().adduvmenu:
# if prefs().individualorsubmenu == "SUBMENU":
# self.layout.menu("DUV_UVMenu")
# else:
# layout = self.layout
#
# col = layout.column()
# col.operator_context = 'INVOKE_DEFAULT'
# col.operator("uv.duv_uvtranslate", text="UVTranslate", icon="MAN_TRANS")
# col.operator("uv.duv_uvrotate", text="UVRotate", icon="MAN_ROT")
# col.operator("uv.duv_uvscale", text="UVScale", icon="MAN_SCALE")
# col.operator("uv.duv_uvextend", text="UVExtend", icon="MOD_SHRINKWRAP")
# col.operator("uv.duv_uvstitch", text="UVStitch", icon="MOD_TRIANGULATE")
# col.operator("uv.duv_uvtransfer", text="Transfer", icon="MOD_UVPROJECT")
# col.operator("uv.duv_uvcycle", text="Transfer", icon="MOD_UVPROJECT")
# self.layout.separator()
def prefs():
return bpy.context.preferences.addons[__name__].preferences
classes = (
DUVUVToolsPreferences,
DUV_UVPanel,
DUV_UVTranslate.UVTranslate,
DUV_UVTranslate.UVTranslateStep,
DUV_UVRotate.UVRotate,
DUV_UVRotate.UVRotateStep,
DUV_UVScale.UVScale,
DUV_UVScale.UVScaleStep,
DUV_UVExtend.UVExtend,
DUV_UVStitch.UVStitch,
DUV_UVTransfer.UVTransfer,
DUV_UVTransfer.UVTransferGrab,
DUV_UVCycle.UVCycle,
DUV_UVMirror.UVMirror,
DUV_UVMoveToEdge.UVMoveToEdge,
DUV_UVProject.UVProject,
DUV_UVUnwrap.UVUnwrapSquare,
DUV_HotSpot.HotSpotter,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
#if prefs().adduvmenu:
# bpy.types.VIEW3D_MT_uv_map.prepend(uv_menu_func)
bpy.types.Scene.subrect_atlas = bpy.props.StringProperty (
name = "atlas",
default = "hotspot atlas object",
description = "atlas object",
)
bpy.types.Scene.uvtransferxmin = bpy.props.FloatProperty (
name = "uvtransferxmin",
default = 0.0,
)
bpy.types.Scene.uvtransferymin = bpy.props.FloatProperty (
name = "uvtransferymin",
default = 0.0,
)
bpy.types.Scene.uvtransferxmax = bpy.props.FloatProperty (
name = "uvtransferxmax",
default = 1.0,
)
bpy.types.Scene.uvtransferymax = bpy.props.FloatProperty (
name = "uvtransferymax",
default = 1.0,
)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
del bpy.types.Scene.subrect_atlas
del bpy.types.Scene.uvtransferxmin
del bpy.types.Scene.uvtransferymin
del bpy.types.Scene.uvtransferxmax
del bpy.types.Scene.uvtransferymax
if __name__ == "__main__":
register()