Skip to content
Snippets Groups Projects
Commit 2db1851c authored by Campbell Barton's avatar Campbell Barton
Browse files

uv smart project now in unwrap menu with 2 most important options

parent 65f92c89
Branches
Tags
No related merge requests found
...@@ -74,7 +74,7 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): ...@@ -74,7 +74,7 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg):
from bpy.props import * from bpy.props import *
class AddTorusPrimitive(bpy.types.Operator): class AddTorus(bpy.types.Operator):
'''Add a torus mesh.''' '''Add a torus mesh.'''
bl_idname = "mesh.primitive_torus_add" bl_idname = "mesh.primitive_torus_add"
bl_label = "Add Torus" bl_label = "Add Torus"
...@@ -125,12 +125,12 @@ class AddTorusPrimitive(bpy.types.Operator): ...@@ -125,12 +125,12 @@ class AddTorusPrimitive(bpy.types.Operator):
return ('FINISHED',) return ('FINISHED',)
# Register the operator # Register the operator
bpy.ops.add(AddTorusPrimitive) bpy.ops.add(AddTorus)
# Add to a menu # Add to a menu
import dynamic_menu import dynamic_menu
menu_func = (lambda self, context: self.layout.itemO("mesh.primitive_torus_add", menu_func = (lambda self, context: self.layout.itemO(AddTorus.bl_idname,
text="Torus", icon='ICON_MESH_DONUT')) text="Torus", icon='ICON_MESH_DONUT'))
menu_item = dynamic_menu.add(bpy.types.INFO_MT_mesh_add, menu_func) menu_item = dynamic_menu.add(bpy.types.INFO_MT_mesh_add, menu_func)
......
...@@ -821,7 +821,7 @@ class thickface(object): ...@@ -821,7 +821,7 @@ class thickface(object):
global ob global ob
ob = None ob = None
def main(context): def main(context, island_margin, projection_limit):
global USER_FILL_HOLES global USER_FILL_HOLES
global USER_FILL_HOLES_QUALITY global USER_FILL_HOLES_QUALITY
global USER_STRETCH_ASPECT global USER_STRETCH_ASPECT
...@@ -847,35 +847,16 @@ def main(context): ...@@ -847,35 +847,16 @@ def main(context):
raise('error, no selected mesh objects') raise('error, no selected mesh objects')
# Create the variables. # Create the variables.
USER_PROJECTION_LIMIT = (66) USER_PROJECTION_LIMIT = projection_limit
USER_ONLY_SELECTED_FACES = (1) USER_ONLY_SELECTED_FACES = (1)
USER_SHARE_SPACE = (1) # Only for hole filling. USER_SHARE_SPACE = (1) # Only for hole filling.
USER_STRETCH_ASPECT = (1) # Only for hole filling. USER_STRETCH_ASPECT = (1) # Only for hole filling.
USER_ISLAND_MARGIN = (0.0) # Only for hole filling. USER_ISLAND_MARGIN = island_margin # Only for hole filling.
USER_FILL_HOLES = (0) USER_FILL_HOLES = (0)
USER_FILL_HOLES_QUALITY = (50) # Only for hole filling. USER_FILL_HOLES_QUALITY = (50) # Only for hole filling.
USER_VIEW_INIT = (0) # Only for hole filling. USER_VIEW_INIT = (0) # Only for hole filling.
USER_AREA_WEIGHT = (1) # Only for hole filling. USER_AREA_WEIGHT = (1) # Only for hole filling.
pup_block = [\
'Projection',\
('Angle Limit:', USER_PROJECTION_LIMIT, 1, 89, 'lower for more projection groups, higher for less distortion.'),\
('Selected Faces Only', USER_ONLY_SELECTED_FACES, 'Use only selected faces from all selected meshes.'),\
('Init from view', USER_VIEW_INIT, 'The first projection will be from the view vector.'),\
('Area Weight', USER_AREA_WEIGHT, 'Weight projections vector by face area.'),\
'',\
'',\
'',\
'UV Layout',\
('Share Tex Space', USER_SHARE_SPACE, 'Objects Share texture space, map all objects into 1 uvmap.'),\
('Stretch to bounds', USER_STRETCH_ASPECT, 'Stretch the final output to texture bounds.'),\
('Island Margin:', USER_ISLAND_MARGIN, 0.0, 0.5, 'Margin to reduce bleed from adjacent islands.'),\
'Fill in empty areas',\
('Fill Holes', USER_FILL_HOLES, 'Fill in empty areas reduced texture waistage (slow).'),\
('Fill Quality:', USER_FILL_HOLES_QUALITY, 1, 100, 'Depends on fill holes, how tightly to fill UV holes, (higher is slower)'),\
]
# Reuse variable # Reuse variable
if len(obList) == 1: if len(obList) == 1:
ob = "Unwrap %i Selected Mesh" ob = "Unwrap %i Selected Mesh"
...@@ -1123,20 +1104,60 @@ def main(context): ...@@ -1123,20 +1104,60 @@ def main(context):
#XXX Window.WaitCursor(0) #XXX Window.WaitCursor(0)
#XXX Window.RedrawAll() #XXX Window.RedrawAll()
"""
pup_block = [\
'Projection',\
* ('Angle Limit:', USER_PROJECTION_LIMIT, 1, 89, ''),\
('Selected Faces Only', USER_ONLY_SELECTED_FACES, 'Use only selected faces from all selected meshes.'),\
('Init from view', USER_VIEW_INIT, 'The first projection will be from the view vector.'),\
('Area Weight', USER_AREA_WEIGHT, 'Weight projections vector by face area.'),\
'',\
'',\
'',\
'UV Layout',\
('Share Tex Space', USER_SHARE_SPACE, 'Objects Share texture space, map all objects into 1 uvmap.'),\
('Stretch to bounds', USER_STRETCH_ASPECT, 'Stretch the final output to texture bounds.'),\
* ('Island Margin:', USER_ISLAND_MARGIN, 0.0, 0.5, ''),\
'Fill in empty areas',\
('Fill Holes', USER_FILL_HOLES, 'Fill in empty areas reduced texture waistage (slow).'),\
('Fill Quality:', USER_FILL_HOLES_QUALITY, 1, 100, 'Depends on fill holes, how tightly to fill UV holes, (higher is slower)'),\
]
"""
from bpy.props import *
class SmartProject(bpy.types.Operator): class SmartProject(bpy.types.Operator):
'''This script projection unwraps the selected faces of a mesh. it operates on all selected mesh objects, and can be used unwrap selected faces, or all faces.''' '''This script projection unwraps the selected faces of a mesh. it operates on all selected mesh objects, and can be used unwrap selected faces, or all faces.'''
bl_idname = "uv.smart_project" bl_idname = "uv.smart_project"
bl_label = "Smart UV Project" bl_label = "Smart UV Project"
bl_register = True
bl_undo = True
angle_limit = FloatProperty(name="Angle Limit",
description="lower for more projection groups, higher for less distortion.",
default=66.0, min=1.0, max=89.0)
island_margin = FloatProperty(name="Island Margin",
description="Margin to reduce bleed from adjacent islands.",
default=0.0, min=0.0, max=1.0)
def poll(self, context): def poll(self, context):
return context.active_object != None return context.active_object != None
def execute(self, context): def execute(self, context):
main(context) main(context, self.island_margin, self.angle_limit)
return ('FINISHED',) return ('FINISHED',)
bpy.ops.add(SmartProject) bpy.ops.add(SmartProject)
# Add to a menu
import dynamic_menu
menu_func = (lambda self, context: self.layout.itemO(SmartProject.bl_idname,
text="Smart Project"))
menu_item = dynamic_menu.add(bpy.types.VIEW3D_MT_uv_map, menu_func)
if __name__ == '__main__': if __name__ == '__main__':
bpy.ops.uv.smart_project() bpy.ops.uv.smart_project()
...@@ -90,7 +90,7 @@ class VIEW3D_MT_snap(bpy.types.Menu): ...@@ -90,7 +90,7 @@ class VIEW3D_MT_snap(bpy.types.Menu):
layout.itemO("view3d.snap_cursor_to_grid", text="Cursor to Grid") layout.itemO("view3d.snap_cursor_to_grid", text="Cursor to Grid")
layout.itemO("view3d.snap_cursor_to_active", text="Cursor to Active") layout.itemO("view3d.snap_cursor_to_active", text="Cursor to Active")
class VIEW3D_MT_uv_map(bpy.types.Menu): class VIEW3D_MT_uv_map(dynamic_menu.DynMenu):
bl_label = "UV Mapping" bl_label = "UV Mapping"
def draw(self, context): def draw(self, context):
......
...@@ -109,7 +109,8 @@ class VIEW3D_PT_tools_meshedit(View3DPanel): ...@@ -109,7 +109,8 @@ class VIEW3D_PT_tools_meshedit(View3DPanel):
col = layout.column(align=True) col = layout.column(align=True)
col.itemL(text="UV Mapping:") col.itemL(text="UV Mapping:")
col.itemO("uv.mapping_menu", text="Unwrap") col.item_stringO("wm.call_menu", "name", "VIEW3D_MT_uv_map", text="Unwrap")
col.itemO("mesh.uvs_rotate") col.itemO("mesh.uvs_rotate")
col.itemO("mesh.uvs_mirror") col.itemO("mesh.uvs_mirror")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment