1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Another Noise Tool - Mesh Displace
6 # ------------------------------------------------------------
9 from bpy
.props
import (
17 from .ant_functions
import (
23 from .ant_noise
import noise_gen
24 from ant_landscape
import ant_noise
26 # ------------------------------------------------------------
27 # Do vert displacement
30 class AntMeshDisplace(bpy
.types
.Operator
):
31 bl_idname
= "mesh.ant_displace"
32 bl_label
= "Another Noise Tool - Displace"
33 bl_description
= "Displace mesh vertices"
34 bl_options
= {'REGISTER', 'UNDO', 'PRESET'}
36 ant_terrain_name
: StringProperty(
40 land_material
: StringProperty(
43 description
="Terrain material"
45 water_material
: StringProperty(
48 description
="Water plane material"
50 texture_block
: StringProperty(
54 at_cursor
: BoolProperty(
57 description
="Place at cursor location",
59 smooth_mesh
: BoolProperty(
62 description
="Shade smooth"
64 tri_face
: BoolProperty(
67 description
="Triangulate faces"
69 sphere_mesh
: BoolProperty(
72 description
="Generate uv sphere - remove doubles when ready"
74 subdivision_x
: IntProperty(
75 name
="Subdivisions X",
79 description
="Mesh X subdivisions"
81 subdivision_y
: IntProperty(
83 name
="Subdivisions Y",
86 description
="Mesh Y subdivisions"
88 mesh_size
: FloatProperty(
93 description
="Mesh size"
95 mesh_size_x
: FloatProperty(
99 description
="Mesh x size"
101 mesh_size_y
: FloatProperty(
105 description
="Mesh y size"
108 random_seed
: IntProperty(
112 description
="Randomize noise origin"
114 noise_offset_x
: FloatProperty(
117 description
="Noise X Offset"
119 noise_offset_y
: FloatProperty(
122 description
="Noise Y Offset"
124 noise_offset_z
: FloatProperty(
127 description
="Noise Z Offset"
129 noise_size_x
: FloatProperty(
134 description
="Noise x size"
136 noise_size_y
: FloatProperty(
141 description
="Noise y size"
143 noise_size_z
: FloatProperty(
148 description
="Noise Z size"
150 noise_size
: FloatProperty(
155 description
="Noise size"
157 noise_type
: EnumProperty(
159 default
='hetero_terrain',
160 description
="Noise type",
162 ('multi_fractal', "Multi Fractal", "Blender: Multi Fractal algorithm", 0),
163 ('ridged_multi_fractal', "Ridged MFractal", "Blender: Ridged Multi Fractal", 1),
164 ('hybrid_multi_fractal', "Hybrid MFractal", "Blender: Hybrid Multi Fractal", 2),
165 ('hetero_terrain', "Hetero Terrain", "Blender: Hetero Terrain", 3),
166 ('fractal', "fBm Fractal", "Blender: fBm - Fractional Browninian motion", 4),
167 ('turbulence_vector', "Turbulence", "Blender: Turbulence Vector", 5),
168 ('variable_lacunarity', "Distorted Noise", "Blender: Distorted Noise", 6),
169 ('marble_noise', "Marble", "A.N.T.: Marble Noise", 7),
170 ('shattered_hterrain', "Shattered hTerrain", "A.N.T.: Shattered hTerrain", 8),
171 ('strata_hterrain', "Strata hTerrain", "A.N.T: Strata hTerrain", 9),
172 ('ant_turbulence', "Another Noise", "A.N.T: Turbulence variation", 10),
173 ('vl_noise_turbulence', "vlNoise turbulence", "A.N.T: Real vlNoise turbulence", 11),
174 ('vl_hTerrain', "vlNoise hTerrain", "A.N.T: vlNoise hTerrain", 12),
175 ('distorted_heteroTerrain', "Distorted hTerrain", "A.N.T distorted hTerrain", 13),
176 ('double_multiFractal', "Double MultiFractal", "A.N.T: double multiFractal", 14),
177 ('rocks_noise', "Noise Rocks", "A.N.T: turbulence variation", 15),
178 ('slick_rock', "Slick Rock", "A.N.T: slick rock", 16),
179 ('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
180 ('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
182 basis_type
: EnumProperty(
184 default
=ant_noise
.noise_basis_default
,
185 description
="Noise basis algorithms",
186 items
=ant_noise
.noise_basis
188 vl_basis_type
: EnumProperty(
189 name
="vlNoise Basis",
190 default
=ant_noise
.noise_basis_default
,
191 description
="VLNoise basis algorithms",
192 items
=ant_noise
.noise_basis
194 distortion
: FloatProperty(
199 description
="Distortion amount"
201 hard_noise
: EnumProperty(
204 description
="Soft Noise, Hard noise",
206 ("0", "Soft", "Soft Noise", 0),
207 ("1", "Hard", "Hard noise", 1)]
209 noise_depth
: IntProperty(
214 description
="Noise Depth - number of frequencies in the fBm"
216 amplitude
: FloatProperty(
221 description
="Amplitude"
223 frequency
: FloatProperty(
228 description
="Frequency"
230 dimension
: FloatProperty(
235 description
="H - fractal dimension of the roughest areas"
237 lacunarity
: FloatProperty(
242 description
="Lacunarity - gap between successive frequencies"
244 offset
: FloatProperty(
249 description
="Offset - raises the terrain from sea level"
256 description
="Gain - scale factor"
258 marble_bias
: EnumProperty(
261 description
="Marble bias",
263 ("0", "Sin", "Sin", 0),
264 ("1", "Cos", "Cos", 1),
265 ("2", "Tri", "Tri", 2),
266 ("3", "Saw", "Saw", 3)]
268 marble_sharp
: EnumProperty(
271 description
="Marble sharpness",
273 ("0", "Soft", "Soft", 0),
274 ("1", "Sharp", "Sharp", 1),
275 ("2", "Sharper", "Sharper", 2),
276 ("3", "Soft inv.", "Soft", 3),
277 ("4", "Sharp inv.", "Sharp", 4),
278 ("5", "Sharper inv.", "Sharper", 5)]
280 marble_shape
: EnumProperty(
283 description
="Marble shape",
285 ("0", "Default", "Default", 0),
286 ("1", "Ring", "Ring", 1),
287 ("2", "Swirl", "Swirl", 2),
288 ("3", "Bump", "Bump", 3),
289 ("4", "Wave", "Wave", 4),
294 height
: FloatProperty(
299 description
="Noise intensity scale"
301 height_invert
: BoolProperty(
304 description
="Height invert",
306 height_offset
: FloatProperty(
311 description
="Height offset"
314 fx_mixfactor
: FloatProperty(
319 description
="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
321 fx_mix_mode
: EnumProperty(
324 description
="Effect mix mode",
326 ("0", "Mix", "Mix", 0),
327 ("1", "Add", "Add", 1),
328 ("2", "Sub", "Subtract", 2),
329 ("3", "Mul", "Multiply", 3),
330 ("4", "Abs", "Absolute", 4),
331 ("5", "Scr", "Screen", 5),
332 ("6", "Mod", "Modulo", 6),
333 ("7", "Min", "Minimum", 7),
334 ("8", "Max", "Maximum", 8)
337 fx_type
: EnumProperty(
340 description
="Effect type",
342 ("0", "None", "No effect", 0),
343 ("1", "Gradient", "Gradient", 1),
344 ("2", "Waves", "Waves - Bumps", 2),
345 ("3", "Zigzag", "Zigzag", 3),
346 ("4", "Wavy", "Wavy", 4),
347 ("5", "Bump", "Bump", 5),
348 ("6", "Dots", "Dots", 6),
349 ("7", "Rings", "Rings", 7),
350 ("8", "Spiral", "Spiral", 8),
351 ("9", "Square", "Square", 9),
352 ("10", "Blocks", "Blocks", 10),
353 ("11", "Grid", "Grid", 11),
354 ("12", "Tech", "Tech", 12),
355 ("13", "Crackle", "Crackle", 13),
356 ("14", "Cracks", "Cracks", 14),
357 ("15", "Rock", "Rock noise", 15),
358 ("16", "Lunar", "Craters", 16),
359 ("17", "Cosine", "Cosine", 17),
360 ("18", "Spikey", "Spikey", 18),
361 ("19", "Stone", "Stone", 19),
362 ("20", "Flat Turb", "Flat turbulence", 20),
363 ("21", "Flat Voronoi", "Flat voronoi", 21)
366 fx_bias
: EnumProperty(
369 description
="Effect bias type",
371 ("0", "Sin", "Sin", 0),
372 ("1", "Cos", "Cos", 1),
373 ("2", "Tri", "Tri", 2),
374 ("3", "Saw", "Saw", 3),
375 ("4", "None", "None", 4)
378 fx_turb
: FloatProperty(
383 description
="Effect turbulence distortion"
385 fx_depth
: IntProperty(
390 description
="Effect depth - number of frequencies"
392 fx_amplitude
: FloatProperty(
397 description
="Amplitude"
399 fx_frequency
: FloatProperty(
404 description
="Frequency"
406 fx_size
: FloatProperty(
411 description
="Effect size"
413 fx_loc_x
: FloatProperty(
416 description
="Effect x offset"
418 fx_loc_y
: FloatProperty(
421 description
="Effect y offset"
423 fx_height
: FloatProperty(
428 description
="Effect intensity scale"
430 fx_invert
: BoolProperty(
433 description
="Effect invert"
435 fx_offset
: FloatProperty(
440 description
="Effect height offset"
443 edge_falloff
: EnumProperty(
446 description
="Flatten edges",
448 ("0", "None", "None", 0),
449 ("1", "Y", "Y Falloff", 1),
450 ("2", "X", "X Falloff", 2),
451 ("3", "X Y", "X Y Falloff", 3)]
453 falloff_x
: FloatProperty(
458 description
="Falloff x scale"
460 falloff_y
: FloatProperty(
465 description
="Falloff y scale"
467 edge_level
: FloatProperty(
472 description
="Edge level, sealevel offset"
474 maximum
: FloatProperty(
479 description
="Maximum, flattens terrain at plateau level"
481 minimum
: FloatProperty(
486 description
="Minimum, flattens terrain at seabed level"
488 vert_group
: StringProperty(
492 strata
: FloatProperty(
497 description
="Strata layers / terraces"
499 strata_type
: EnumProperty(
502 description
="Strata types",
504 ("0", "None", "No strata", 0),
505 ("1", "Smooth", "Smooth transitions", 1),
506 ("2", "Sharp Sub", "Sharp subtract transitions", 2),
507 ("3", "Sharp Add", "Sharp add transitions", 3),
508 ("4", "Quantize", "Quantize", 4),
509 ("5", "Quantize Mix", "Quantize mixed", 5)]
511 water_plane
: BoolProperty(
514 description
="Add water plane"
516 water_level
: FloatProperty(
521 description
="Water level"
523 remove_double
: BoolProperty(
524 name
="Remove Doubles",
526 description
="Remove doubles"
528 direction
: EnumProperty(
531 description
="Displacement direction",
533 ("NORMAL", "Normal", "Displace along vertex normal direction", 0),
534 ("Z", "Z", "Displace in the Z direction", 1),
535 ("Y", "Y", "Displace in the Y direction", 2),
536 ("X", "X", "Displace in the X direction", 3)]
538 show_main_settings
: BoolProperty(
539 name
="Main Settings",
541 description
="Show settings"
543 show_noise_settings
: BoolProperty(
544 name
="Noise Settings",
546 description
="Show noise settings"
548 show_displace_settings
: BoolProperty(
549 name
="Displace Settings",
551 description
="Show terrain settings"
553 refresh
: BoolProperty(
556 description
="Refresh"
558 auto_refresh
: BoolProperty(
561 description
="Automatic refresh"
564 def draw(self
, context
):
565 draw_ant_refresh(self
, context
)
566 draw_ant_noise(self
, context
, generate
=False)
567 draw_ant_displace(self
, context
, generate
=False)
570 def poll(cls
, context
):
572 return (ob
and ob
.type == 'MESH')
574 def invoke(self
, context
, event
):
576 return self
.execute(context
)
578 def execute(self
, context
):
580 return {'PASS_THROUGH'}
586 self
.ant_terrain_name
,
656 if self
.vert_group
!= "" and self
.vert_group
in ob
.vertex_groups
:
657 vertex_group
= ob
.vertex_groups
[self
.vert_group
]
660 gi
= vertex_group
.index
661 if self
.direction
== "X":
662 for v
in mesh
.vertices
:
665 v
.co
[0] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
667 if self
.direction
== "Y":
668 for v
in mesh
.vertices
:
671 v
.co
[1] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
673 if self
.direction
== "Z":
674 for v
in mesh
.vertices
:
677 v
.co
[2] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
680 for v
in mesh
.vertices
:
683 v
.co
+= vertex_group
.weight(v
.index
) * v
.normal
* noise_gen(v
.co
, props
)
686 if self
.direction
== "X":
687 for v
in mesh
.vertices
:
688 v
.co
[0] += noise_gen(v
.co
, props
)
690 elif self
.direction
== "Y":
691 for v
in mesh
.vertices
:
692 v
.co
[1] += noise_gen(v
.co
, props
)
694 elif self
.direction
== "Z":
695 for v
in mesh
.vertices
:
696 v
.co
[2] += noise_gen(v
.co
, props
)
699 for v
in mesh
.vertices
:
700 v
.co
+= v
.normal
* noise_gen(v
.co
, props
)
704 if self
.auto_refresh
is False: