Skip to content

Commit

Permalink
Adding uniform scale option for UV unwrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackears committed Apr 5, 2021
1 parent 5bcd632 commit 3104cd7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Perform a cubemap projection based on the grid coorinates.
##### Use Grid Scale
If true, the current scale factor of the grid will be applied to the projection. Otherwise the layout will be done with absolute values.

##### Uniform Scale
If true, u and v axes will be scaled uniformly. Otherwise scaling for each axis can be specified separately.

##### U Scale
Multiplier for U coorinate.

Expand Down
21 changes: 17 additions & 4 deletions source/operators/triplanarUvUnwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@


class TriplanarSettings(bpy.types.PropertyGroup):

scale_uniform : bpy.props.BoolProperty(
name="Scale Uniform", description="If true, both axes will be scaled by the same amount. Otherwise u and v scaling can be specified separately.", default = True
)

scale_u : bpy.props.FloatProperty(
name="U Scale", description="Scale of texture along horizon", default = 1, min=0, soft_max = 4
)
Expand Down Expand Up @@ -79,8 +84,12 @@ def map_editmode(context):
else:
uv = mathutils.Vector(wco.xy)

uv.x /= settings.scale_u
uv.y /= settings.scale_v
if settings.scale_uniform:
uv.x /= settings.scale_u
uv.y /= settings.scale_u
else:
uv.x /= settings.scale_u
uv.y /= settings.scale_v

if use_grid_scale:
uv /= scale
Expand Down Expand Up @@ -135,8 +144,12 @@ def map_objectmode(context):
else:
uv = mathutils.Vector(wco.xy)

uv.x /= settings.scale_u
uv.y /= settings.scale_v
if settings.scale_uniform:
uv.x /= settings.scale_u
uv.y /= settings.scale_u
else:
uv.x /= settings.scale_u
uv.y /= settings.scale_v

if use_grid_scale:
uv /= scale
Expand Down
13 changes: 9 additions & 4 deletions source/operators/uvToolsPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def draw(self, context):
col.operator("kitfox.uv_plane_layout_op", text="Uv Plane Project", icon_value = pcoll["uvBrush"].icon_id)
col.prop(planeLayout_props, "selected_faces_only")
col.prop(planeLayout_props, "clamp_to_basis")
col.prop(planeLayout_props, "clamp_scalar")
col.prop(planeLayout_props, "clamp_scalar")
col.prop(planeLayout_props, "init_layout", expand = True)

#--------------------------------
Expand All @@ -123,9 +123,14 @@ def draw(self, context):
col = layout.column();
col.operator("kitfox.triplanar_uv_unwrap", text="Triplanar Unwrap")

row = layout.row()
row.prop(settings_tri, "scale_u")
row.prop(settings_tri, "scale_v")
col.prop(settings_tri, "scale_uniform")
row = col.row()
if settings_tri.scale_uniform:
row.prop(settings_tri, "scale_u", text = "Scale")
else:
row.prop(settings_tri, "scale_u")
row.prop(settings_tri, "scale_v")

col.prop(settings_tri, "use_grid_scale")

#--------------------------------
Expand Down

0 comments on commit 3104cd7

Please sign in to comment.