From f22dcd3f8018835d900fe033265c6e46a9d3c71a Mon Sep 17 00:00:00 2001 From: Jimmy Hazevoet Date: Mon, 10 Jul 2017 11:50:38 +1000 Subject: ant landscape fix for noise types part1 --- ant_landscape/__init__.py | 11 +++++------ ant_landscape/add_mesh_ant_landscape.py | 11 +++++------ ant_landscape/ant_functions.py | 15 ++++++--------- ant_landscape/ant_landscape_refresh.py | 28 +++++++++------------------- ant_landscape/mesh_ant_displace.py | 29 ++++++++--------------------- 5 files changed, 33 insertions(+), 61 deletions(-) (limited to 'ant_landscape') diff --git a/ant_landscape/__init__.py b/ant_landscape/__init__.py index 60dd81a1..25d4be9b 100644 --- a/ant_landscape/__init__.py +++ b/ant_landscape/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "A.N.T.Landscape", - "author": "Jim Hazevoet", + "author": "Jimmy Hazevoet", "version": (0, 1, 8), "blender": (2, 78, 0), "location": "View3D > Tool Shelf", @@ -375,7 +375,7 @@ class AntDisplaceSettingsPanel(bpy.types.Panel): col = box.column() col.prop(ant, "strata") col = box.column() - col.prop(ant, "use_vgroup", toggle=True) + col.prop_search(ant, "vert_group", ob, "vertex_groups") # ------------------------------------------------------------ @@ -724,10 +724,9 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): max=10000.0, description="Minimum, flattens terrain at seabed level" ) - use_vgroup = BoolProperty( - name="Vertex Group Weight", - default=False, - description="Use active vertex group weight" + vert_group = StringProperty( + name="Vertex Group", + default="" ) strata = FloatProperty( name="Amount", diff --git a/ant_landscape/add_mesh_ant_landscape.py b/ant_landscape/add_mesh_ant_landscape.py index 7fc4a268..dee82a55 100644 --- a/ant_landscape/add_mesh_ant_landscape.py +++ b/ant_landscape/add_mesh_ant_landscape.py @@ -392,10 +392,9 @@ class AntAddLandscape(bpy.types.Operator): max=10000.0, description="Minimum, flattens terrain at seabed level" ) - use_vgroup = BoolProperty( - name="Vertex Group Weight", - default=False, - description="Use active vertex group weight" + vert_group = StringProperty( + name="Vertex Group", + default="" ) strata = FloatProperty( name="Amount", @@ -536,10 +535,10 @@ class AntAddLandscape(bpy.types.Operator): self.strata, self.water_plane, self.water_level, - self.use_vgroup, + self.vert_group, self.remove_double ] - + scene = context.scene # Main function, create landscape mesh object diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py index ce7751af..8adacc0b 100644 --- a/ant_landscape/ant_functions.py +++ b/ant_landscape/ant_functions.py @@ -20,7 +20,7 @@ # Jimmy Hazevoet # ErosionR: -# Michel Anders (varkenvarken), Ian Huish (nerk) +# Michel Anders, Ian Huish # import modules import bpy @@ -279,7 +279,7 @@ def shapes(x, y, z, shape=0): y = y * p * 2 s = sin(x + sin(y)) elif shape is 5: - # x grad. + # z grad. s = (z * p) elif shape is 6: # y grad. @@ -878,7 +878,7 @@ def draw_ant_displace(self, context, generate=True): if not generate: col = box.column(align=False) - col.prop(self, "use_vgroup", toggle=True) + col.prop_search(self, "vert_group", bpy.context.object, "vertex_groups") def draw_ant_water(self, context): @@ -944,19 +944,18 @@ def store_properties(operator, ob): ob.ant_landscape.strata = operator.strata ob.ant_landscape.water_plane = operator.water_plane ob.ant_landscape.water_level = operator.water_level - ob.ant_landscape.use_vgroup = operator.use_vgroup + ob.ant_landscape.vert_group = operator.vert_group ob.ant_landscape.remove_double = operator.remove_double return ob # ------------------------------------------------------------ # "name": "ErosionR" -# "author": "Michel Anders (varkenvarken), Ian Huish (nerk)" - +# "author": "Michel Anders, Ian Huish" + from random import random as rand from math import tan, radians from .eroder import Grid -#print("Imported multifiles", file=sys.stderr) from .stats import Stats from .utils import numexpr_available @@ -1135,8 +1134,6 @@ class Eroder(bpy.types.Operator): stats = Stats() counts= {} - # add poll function to restrict action to mesh object in object mode - def execute(self, context): ob = context.active_object diff --git a/ant_landscape/ant_landscape_refresh.py b/ant_landscape/ant_landscape_refresh.py index e3ff5366..b809619e 100644 --- a/ant_landscape/ant_landscape_refresh.py +++ b/ant_landscape/ant_landscape_refresh.py @@ -19,7 +19,6 @@ # Another Noise Tool - Landscape Redraw - Regenerate # Jimmy Hazevoet - # ------------------------------------------------------------ # import modules import bpy @@ -61,9 +60,6 @@ class AntLandscapeRefresh(bpy.types.Operator): if obj and obj.ant_landscape.keys(): ob = obj.ant_landscape obi = ob.items() - #print("Refresh A.N.T. Landscape Grid") - #for k in obi.keys(): - # print(k, "-", obi[k]) prop = [] for i in range(len(obi)): prop.append(obi[i][1]) @@ -71,15 +67,14 @@ class AntLandscapeRefresh(bpy.types.Operator): # redraw verts mesh = obj.data - if ob['use_vgroup']: - vertex_group = obj.vertex_groups.active - if vertex_group: - gi = vertex_group.index - for v in mesh.vertices: - for g in v.groups: - if g.group == gi: - v.co[2] = 0.0 - v.co[2] = vertex_group.weight(v.index) * noise_gen(v.co, prop) + if ob['vert_group'] != "" and ob['vert_group'] in obj.vertex_groups: + vertex_group = obj.vertex_groups[ob['vert_group']] + gi = vertex_group.index + for v in mesh.vertices: + for g in v.groups: + if g.group == gi: + v.co[2] = 0.0 + v.co[2] = vertex_group.weight(v.index) * noise_gen(v.co, prop) else: for v in mesh.vertices: v.co[2] = 0 @@ -121,14 +116,11 @@ class AntLandscapeRegenerate(bpy.types.Operator): if obj and obj.ant_landscape.keys(): ob = obj.ant_landscape obi = ob.items() - #print("Regenerate A.N.T. Landscape Grid") - #for k in obi.keys(): - # print(k, "-", obi[k]) ant_props = [] for i in range(len(obi)): ant_props.append(obi[i][1]) - new_name = obj.name #ob.ant_terrain_name + new_name = obj.name # Main function, create landscape mesh object if ob['sphere_mesh']: @@ -222,7 +214,6 @@ class AntLandscapeRegenerate(bpy.types.Operator): wobj.scale = obj.scale wobj.select = False - new_ob.location = obj.location new_ob.rotation_euler = obj.rotation_euler new_ob.scale = obj.scale @@ -236,7 +227,6 @@ class AntLandscapeRegenerate(bpy.types.Operator): obj.select = True scene.objects.active = obj bpy.ops.object.delete(use_global=False) - #scene.update() # Select landscape and make active new_ob.select = True diff --git a/ant_landscape/mesh_ant_displace.py b/ant_landscape/mesh_ant_displace.py index a0ecebb4..7e1439b4 100644 --- a/ant_landscape/mesh_ant_displace.py +++ b/ant_landscape/mesh_ant_displace.py @@ -388,10 +388,9 @@ class AntMeshDisplace(bpy.types.Operator): max=10000.0, description="Minimum, flattens terrain at seabed level" ) - use_vgroup = BoolProperty( - name="Vertex Group Weight", - default=False, - description="Use active vertex group weight" + vert_group = StringProperty( + name="Vertex Group", + default="" ) strata = FloatProperty( name="Amount", @@ -424,11 +423,7 @@ class AntMeshDisplace(bpy.types.Operator): max=10000.0, description="Water level" ) - remove_double = BoolProperty( - name="Remove Doubles", - default=False, - description="Remove doubles" - ) + direction = EnumProperty( name="Direction", default="NORMAL", @@ -544,22 +539,14 @@ class AntMeshDisplace(bpy.types.Operator): self.strata, self.water_plane, self.water_level, - self.use_vgroup, - self.remove_double + self.vert_group ] - ''' - gi = ob.vertex_groups["Group"].index # get group index - for v in ob.data.vertices: - for g in v.groups: - if g.group == gi: # compare with index in VertexGroupElement - v.co[0] = 5 - ''' # do displace mesh = ob.data - if self.use_vgroup is True: - vertex_group = ob.vertex_groups.active + if self.vert_group != "" and self.vert_group in ob.vertex_groups: + vertex_group = ob.vertex_groups[self.vert_group] if vertex_group: gi = vertex_group.index if self.direction == "X": @@ -597,7 +584,7 @@ class AntMeshDisplace(bpy.types.Operator): for v in mesh.vertices: v.co += v.normal * noise_gen(v.co, props) - mesh.update() + mesh.update() if self.auto_refresh is False: self.refresh = False -- cgit v1.2.3