Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ant_landscape/add_mesh_ant_landscape.py')
-rw-r--r--ant_landscape/add_mesh_ant_landscape.py189
1 files changed, 86 insertions, 103 deletions
diff --git a/ant_landscape/add_mesh_ant_landscape.py b/ant_landscape/add_mesh_ant_landscape.py
index 52afed75..28f89da7 100644
--- a/ant_landscape/add_mesh_ant_landscape.py
+++ b/ant_landscape/add_mesh_ant_landscape.py
@@ -42,6 +42,8 @@ from .ant_functions import (
draw_ant_water,
)
+from ant_landscape import ant_noise
+
# ------------------------------------------------------------
# Add landscape
class AntAddLandscape(bpy.types.Operator):
@@ -50,128 +52,128 @@ class AntAddLandscape(bpy.types.Operator):
bl_description = "Add landscape mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- ant_terrain_name = StringProperty(
+ ant_terrain_name: StringProperty(
name="Name",
default="Landscape"
)
- land_material = StringProperty(
+ land_material: StringProperty(
name='Material',
default="",
description="Terrain material"
)
- water_material = StringProperty(
+ water_material: StringProperty(
name='Material',
default="",
description="Water plane material"
)
- texture_block = StringProperty(
+ texture_block: StringProperty(
name="Texture",
default=""
)
- at_cursor = BoolProperty(
+ at_cursor: BoolProperty(
name="Cursor",
default=True,
description="Place at cursor location",
)
- smooth_mesh = BoolProperty(
+ smooth_mesh: BoolProperty(
name="Smooth",
default=True,
description="Shade smooth"
)
- tri_face = BoolProperty(
+ tri_face: BoolProperty(
name="Triangulate",
default=False,
description="Triangulate faces"
)
- sphere_mesh = BoolProperty(
+ sphere_mesh: BoolProperty(
name="Sphere",
default=False,
description="Generate uv sphere - remove doubles when ready"
)
- subdivision_x = IntProperty(
+ subdivision_x: IntProperty(
name="Subdivisions X",
default=128,
min=4,
max=6400,
description="Mesh X subdivisions"
)
- subdivision_y = IntProperty(
+ subdivision_y: IntProperty(
default=128,
name="Subdivisions Y",
min=4,
max=6400,
description="Mesh Y subdivisions"
)
- mesh_size = FloatProperty(
+ mesh_size: FloatProperty(
default=2.0,
name="Mesh Size",
min=0.01,
max=100000.0,
description="Mesh size"
)
- mesh_size_x = FloatProperty(
+ mesh_size_x: FloatProperty(
default=2.0,
name="Mesh Size X",
min=0.01,
description="Mesh x size"
)
- mesh_size_y = FloatProperty(
+ mesh_size_y: FloatProperty(
name="Mesh Size Y",
default=2.0,
min=0.01,
description="Mesh y size"
)
- random_seed = IntProperty(
+ random_seed: IntProperty(
name="Random Seed",
default=0,
min=0,
description="Randomize noise origin"
)
- noise_offset_x = FloatProperty(
+ noise_offset_x: FloatProperty(
name="Offset X",
default=0.0,
description="Noise X Offset"
)
- noise_offset_y = FloatProperty(
+ noise_offset_y: FloatProperty(
name="Offset Y",
default=0.0,
description="Noise Y Offset"
)
- noise_offset_z = FloatProperty(
+ noise_offset_z: FloatProperty(
name="Offset Z",
default=0.0,
description="Noise Z Offset"
)
- noise_size_x = FloatProperty(
+ noise_size_x: FloatProperty(
default=1.0,
name="Size X",
min=0.01,
max=1000.0,
description="Noise x size"
)
- noise_size_y = FloatProperty(
+ noise_size_y: FloatProperty(
name="Size Y",
default=1.0,
min=0.01,
max=1000.0,
description="Noise y size"
)
- noise_size_z = FloatProperty(
+ noise_size_z: FloatProperty(
name="Size Z",
default=1.0,
min=0.01,
max=1000.0,
description="Noise Z size"
)
- noise_size = FloatProperty(
+ noise_size: FloatProperty(
name="Noise Size",
default=1.0,
min=0.01,
max=1000.0,
description="Noise size"
)
- noise_type = EnumProperty(
+ noise_type: EnumProperty(
name="Noise Type",
default='hetero_terrain',
description="Noise type",
@@ -196,46 +198,26 @@ class AntAddLandscape(bpy.types.Operator):
('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
)
- basis_type = EnumProperty(
+ basis_type: EnumProperty(
name="Noise Basis",
- default="0",
+ default=ant_noise.noise_basis_default,
description="Noise basis algorithms",
- items = [
- ("0", "Blender", "Blender default noise", 0),
- ("1", "Perlin", "Perlin noise", 1),
- ("2", "New Perlin", "New Perlin noise", 2),
- ("3", "Voronoi F1", "Voronoi F1", 3),
- ("4", "Voronoi F2", "Voronoi F2", 4),
- ("5", "Voronoi F3", "Voronoi F3", 5),
- ("6", "Voronoi F4", "Voronoi F4", 6),
- ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7),
- ("8", "Voronoi Crackle", "Voronoi Crackle", 8),
- ("9", "Cell Noise", "Cell noise", 9)]
- )
- vl_basis_type = EnumProperty(
+ items = ant_noise.noise_basis
+ )
+ vl_basis_type: EnumProperty(
name="vlNoise Basis",
- default="0",
+ default=ant_noise.noise_basis_default,
description="VLNoise basis algorithms",
- items = [
- ("0", "Blender", "Blender default noise", 0),
- ("1", "Perlin", "Perlin noise", 1),
- ("2", "New Perlin", "New Perlin noise", 2),
- ("3", "Voronoi F1", "Voronoi F1", 3),
- ("4", "Voronoi F2", "Voronoi F2", 4),
- ("5", "Voronoi F3", "Voronoi F3", 5),
- ("6", "Voronoi F4", "Voronoi F4", 6),
- ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7),
- ("8", "Voronoi Crackle", "Voronoi Crackle", 8),
- ("9", "Cell Noise", "Cell noise", 9)]
- )
- distortion = FloatProperty(
+ items = ant_noise.noise_basis
+ )
+ distortion: FloatProperty(
name="Distortion",
default=1.0,
min=0.01,
max=100.0,
description="Distortion amount"
)
- hard_noise = EnumProperty(
+ hard_noise: EnumProperty(
name="Soft Hard",
default="0",
description="Soft Noise, Hard noise",
@@ -243,56 +225,56 @@ class AntAddLandscape(bpy.types.Operator):
("0", "Soft", "Soft Noise", 0),
("1", "Hard", "Hard noise", 1)]
)
- noise_depth = IntProperty(
+ noise_depth: IntProperty(
name="Depth",
default=8,
min=0,
max=16,
description="Noise Depth - number of frequencies in the fBm"
)
- amplitude = FloatProperty(
+ amplitude: FloatProperty(
name="Amp",
default=0.5,
min=0.01,
max=1.0,
description="Amplitude"
)
- frequency = FloatProperty(
+ frequency: FloatProperty(
name="Freq",
default=2.0,
min=0.01,
max=5.0,
description="Frequency"
)
- dimension = FloatProperty(
+ dimension: FloatProperty(
name="Dimension",
default=1.0,
min=0.01,
max=2.0,
description="H - fractal dimension of the roughest areas"
)
- lacunarity = FloatProperty(
+ lacunarity: FloatProperty(
name="Lacunarity",
min=0.01,
max=6.0,
default=2.0,
description="Lacunarity - gap between successive frequencies"
)
- offset = FloatProperty(
+ offset: FloatProperty(
name="Offset",
default=1.0,
min=0.01,
max=6.0,
description="Offset - raises the terrain from sea level"
)
- gain = FloatProperty(
+ gain: FloatProperty(
name="Gain",
default=1.0,
min=0.01,
max=6.0,
description="Gain - scale factor"
)
- marble_bias = EnumProperty(
+ marble_bias: EnumProperty(
name="Bias",
default="0",
description="Marble bias",
@@ -302,7 +284,7 @@ class AntAddLandscape(bpy.types.Operator):
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3)]
)
- marble_sharp = EnumProperty(
+ marble_sharp: EnumProperty(
name="Sharp",
default="0",
description="Marble sharpness",
@@ -314,7 +296,7 @@ class AntAddLandscape(bpy.types.Operator):
("4", "Sharp inv.", "Sharp", 4),
("5", "Sharper inv.", "Sharper", 5)]
)
- marble_shape = EnumProperty(
+ marble_shape: EnumProperty(
name="Shape",
default="0",
description="Marble shape",
@@ -328,33 +310,33 @@ class AntAddLandscape(bpy.types.Operator):
("6", "Y", "Y", 6),
("7", "X", "X", 7)]
)
- height = FloatProperty(
+ height: FloatProperty(
name="Height",
default=0.5,
min=-10000.0,
max=10000.0,
description="Noise intensity scale"
)
- height_invert = BoolProperty(
+ height_invert: BoolProperty(
name="Invert",
default=False,
description="Height invert",
)
- height_offset = FloatProperty(
+ height_offset: FloatProperty(
name="Offset",
default=0.0,
min=-10000.0,
max=10000.0,
description="Height offset"
)
- fx_mixfactor = FloatProperty(
+ fx_mixfactor: FloatProperty(
name="Mix Factor",
default=0.0,
min=-1.0,
max=1.0,
description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
)
- fx_mix_mode = EnumProperty(
+ fx_mix_mode: EnumProperty(
name="Effect Mix",
default="0",
description="Effect mix mode",
@@ -370,7 +352,7 @@ class AntAddLandscape(bpy.types.Operator):
("8", "Max", "Maximum", 8)
]
)
- fx_type = EnumProperty(
+ fx_type: EnumProperty(
name="Effect Type",
default="0",
description="Effect type",
@@ -399,7 +381,7 @@ class AntAddLandscape(bpy.types.Operator):
("21", "Flat Voronoi", "Flat voronoi", 21)
]
)
- fx_bias = EnumProperty(
+ fx_bias: EnumProperty(
name="Effect Bias",
default="0",
description="Effect bias type",
@@ -410,64 +392,64 @@ class AntAddLandscape(bpy.types.Operator):
("3", "Saw", "Saw", 3),
("4", "None", "None", 4)]
)
- fx_turb = FloatProperty(
+ fx_turb: FloatProperty(
name="Distortion",
default=0.0,
min=0.0,
max=1000.0,
description="Effect turbulence distortion"
)
- fx_depth = IntProperty(
+ fx_depth: IntProperty(
name="Depth",
default=0,
min=0,
max=16,
description="Effect depth - number of frequencies"
)
- fx_amplitude = FloatProperty(
+ fx_amplitude: FloatProperty(
name="Amp",
default=0.5,
min=0.01,
max=1.0,
description="Amplitude"
)
- fx_frequency = FloatProperty(
+ fx_frequency: FloatProperty(
name="Freq",
default=2.0,
min=0.01,
max=5.0,
description="Frequency"
)
- fx_size = FloatProperty(
+ fx_size: FloatProperty(
name="Effect Size",
default=1.0,
min=0.01,
max=1000.0,
description="Effect size"
)
- fx_loc_x = FloatProperty(
+ fx_loc_x: FloatProperty(
name="Offset X",
default=0.0,
description="Effect x offset"
)
- fx_loc_y = FloatProperty(
+ fx_loc_y: FloatProperty(
name="Offset Y",
default=0.0,
description="Effect y offset"
)
- fx_height = FloatProperty(
+ fx_height: FloatProperty(
name="Intensity",
default=1.0,
min=-1000.0,
max=1000.0,
description="Effect intensity scale"
)
- fx_invert = BoolProperty(
+ fx_invert: BoolProperty(
name="Invert",
default=False,
description="Effect invert"
)
- fx_offset = FloatProperty(
+ fx_offset: FloatProperty(
name="Offset",
default=0.0,
min=-1000.0,
@@ -475,7 +457,7 @@ class AntAddLandscape(bpy.types.Operator):
description="Effect height offset"
)
- edge_falloff = EnumProperty(
+ edge_falloff: EnumProperty(
name="Falloff",
default="3",
description="Flatten edges",
@@ -485,53 +467,53 @@ class AntAddLandscape(bpy.types.Operator):
("2", "X", "X Falloff", 2),
("3", "X Y", "X Y Falloff", 3)]
)
- falloff_x = FloatProperty(
+ falloff_x: FloatProperty(
name="Falloff X",
default=4.0,
min=0.1,
max=100.0,
description="Falloff x scale"
)
- falloff_y = FloatProperty(
+ falloff_y: FloatProperty(
name="Falloff Y",
default=4.0,
min=0.1,
max=100.0,
description="Falloff y scale"
)
- edge_level = FloatProperty(
+ edge_level: FloatProperty(
name="Edge Level",
default=0.0,
min=-10000.0,
max=10000.0,
description="Edge level, sealevel offset"
)
- maximum = FloatProperty(
+ maximum: FloatProperty(
name="Maximum",
default=1.0,
min=-10000.0,
max=10000.0,
description="Maximum, flattens terrain at plateau level"
)
- minimum = FloatProperty(
+ minimum: FloatProperty(
name="Minimum",
default=-1.0,
min=-10000.0,
max=10000.0,
description="Minimum, flattens terrain at seabed level"
)
- vert_group = StringProperty(
+ vert_group: StringProperty(
name="Vertex Group",
default=""
)
- strata = FloatProperty(
+ strata: FloatProperty(
name="Amount",
default=5.0,
min=0.01,
max=1000.0,
description="Strata layers / terraces"
)
- strata_type = EnumProperty(
+ strata_type: EnumProperty(
name="Strata",
default="0",
description="Strata types",
@@ -543,44 +525,44 @@ class AntAddLandscape(bpy.types.Operator):
("4", "Quantize", "Quantize", 4),
("5", "Quantize Mix", "Quantize mixed", 5)]
)
- water_plane = BoolProperty(
+ water_plane: BoolProperty(
name="Water Plane",
default=False,
description="Add water plane"
)
- water_level = FloatProperty(
+ water_level: FloatProperty(
name="Level",
default=0.01,
min=-10000.0,
max=10000.0,
description="Water level"
)
- remove_double = BoolProperty(
+ remove_double: BoolProperty(
name="Remove Doubles",
default=False,
description="Remove doubles"
)
- show_main_settings = BoolProperty(
+ show_main_settings: BoolProperty(
name="Main Settings",
default=True,
description="Show settings"
)
- show_noise_settings = BoolProperty(
+ show_noise_settings: BoolProperty(
name="Noise Settings",
default=True,
description="Show noise settings"
)
- show_displace_settings = BoolProperty(
+ show_displace_settings: BoolProperty(
name="Displace Settings",
default=True,
description="Show displace settings"
)
- refresh = BoolProperty(
+ refresh: BoolProperty(
name="Refresh",
default=False,
description="Refresh"
)
- auto_refresh = BoolProperty(
+ auto_refresh: BoolProperty(
name="Auto",
default=True,
description="Automatic refresh"
@@ -689,6 +671,7 @@ class AntAddLandscape(bpy.types.Operator):
]
scene = context.scene
+ vl = context.view_layer
# Main function, create landscape mesh object
if self.ant_terrain_name != "":
@@ -709,7 +692,7 @@ class AntAddLandscape(bpy.types.Operator):
)
new_ob = create_mesh_object(context, verts, [], faces, new_name)
if self.remove_double:
- new_ob.select = True
+ new_ob.select_set(True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
bpy.ops.object.mode_set(mode = 'OBJECT')
@@ -727,7 +710,7 @@ class AntAddLandscape(bpy.types.Operator):
)
new_ob = create_mesh_object(context, verts, [], faces, new_name)
- new_ob.select = True
+ new_ob.select_set(True)
if self.smooth_mesh:
bpy.ops.object.shade_smooth()
@@ -755,7 +738,7 @@ class AntAddLandscape(bpy.types.Operator):
)
wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
if self.remove_double:
- wobj.select = True
+ wobj.select_set(True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
bpy.ops.object.mode_set(mode = 'OBJECT')
@@ -773,7 +756,7 @@ class AntAddLandscape(bpy.types.Operator):
)
wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
- wobj.select = True
+ wobj.select_set(True)
if self.smooth_mesh:
bpy.ops.object.shade_smooth()
@@ -787,10 +770,10 @@ class AntAddLandscape(bpy.types.Operator):
bpy.context.object.data.materials.append(mat)
# select landscape and make active
- new_ob.select = True
- scene.objects.active = new_ob.object
+ new_ob.select_set(True)
+ vl.objects.active = new_ob
#
- new_ob = store_properties(self, new_ob.object)
+ new_ob = store_properties(self, new_ob)
if self.auto_refresh is False:
self.refresh = False