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
28 class AntMeshDisplace(bpy
.types
.Operator
):
29 bl_idname
= "mesh.ant_displace"
30 bl_label
= "Another Noise Tool - Displace"
31 bl_description
= "Displace mesh vertices"
32 bl_options
= {'REGISTER', 'UNDO', 'PRESET'}
34 ant_terrain_name
: StringProperty(
38 land_material
: StringProperty(
41 description
="Terrain material"
43 water_material
: StringProperty(
46 description
="Water plane material"
48 texture_block
: StringProperty(
52 at_cursor
: BoolProperty(
55 description
="Place at cursor location",
57 smooth_mesh
: BoolProperty(
60 description
="Shade smooth"
62 tri_face
: BoolProperty(
65 description
="Triangulate faces"
67 sphere_mesh
: BoolProperty(
70 description
="Generate uv sphere - remove doubles when ready"
72 subdivision_x
: IntProperty(
73 name
="Subdivisions X",
77 description
="Mesh X subdivisions"
79 subdivision_y
: IntProperty(
81 name
="Subdivisions Y",
84 description
="Mesh Y subdivisions"
86 mesh_size
: FloatProperty(
91 description
="Mesh size"
93 mesh_size_x
: FloatProperty(
97 description
="Mesh x size"
99 mesh_size_y
: FloatProperty(
103 description
="Mesh y size"
106 random_seed
: IntProperty(
110 description
="Randomize noise origin"
112 noise_offset_x
: FloatProperty(
115 description
="Noise X Offset"
117 noise_offset_y
: FloatProperty(
120 description
="Noise Y Offset"
122 noise_offset_z
: FloatProperty(
125 description
="Noise Z Offset"
127 noise_size_x
: FloatProperty(
132 description
="Noise x size"
134 noise_size_y
: FloatProperty(
139 description
="Noise y size"
141 noise_size_z
: FloatProperty(
146 description
="Noise Z size"
148 noise_size
: FloatProperty(
153 description
="Noise size"
155 noise_type
: EnumProperty(
157 default
='hetero_terrain',
158 description
="Noise type",
160 ('multi_fractal', "Multi Fractal", "Blender: Multi Fractal algorithm", 0),
161 ('ridged_multi_fractal', "Ridged MFractal", "Blender: Ridged Multi Fractal", 1),
162 ('hybrid_multi_fractal', "Hybrid MFractal", "Blender: Hybrid Multi Fractal", 2),
163 ('hetero_terrain', "Hetero Terrain", "Blender: Hetero Terrain", 3),
164 ('fractal', "fBm Fractal", "Blender: fBm - Fractional Browninian motion", 4),
165 ('turbulence_vector', "Turbulence", "Blender: Turbulence Vector", 5),
166 ('variable_lacunarity', "Distorted Noise", "Blender: Distorted Noise", 6),
167 ('marble_noise', "Marble", "A.N.T.: Marble Noise", 7),
168 ('shattered_hterrain', "Shattered hTerrain", "A.N.T.: Shattered hTerrain", 8),
169 ('strata_hterrain', "Strata hTerrain", "A.N.T: Strata hTerrain", 9),
170 ('ant_turbulence', "Another Noise", "A.N.T: Turbulence variation", 10),
171 ('vl_noise_turbulence', "vlNoise turbulence", "A.N.T: Real vlNoise turbulence", 11),
172 ('vl_hTerrain', "vlNoise hTerrain", "A.N.T: vlNoise hTerrain", 12),
173 ('distorted_heteroTerrain', "Distorted hTerrain", "A.N.T distorted hTerrain", 13),
174 ('double_multiFractal', "Double MultiFractal", "A.N.T: double multiFractal", 14),
175 ('rocks_noise', "Noise Rocks", "A.N.T: turbulence variation", 15),
176 ('slick_rock', "Slick Rock", "A.N.T: slick rock", 16),
177 ('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
178 ('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
180 basis_type
: EnumProperty(
182 default
=ant_noise
.noise_basis_default
,
183 description
="Noise basis algorithms",
184 items
= ant_noise
.noise_basis
186 vl_basis_type
: EnumProperty(
187 name
="vlNoise Basis",
188 default
=ant_noise
.noise_basis_default
,
189 description
="VLNoise basis algorithms",
190 items
= ant_noise
.noise_basis
192 distortion
: FloatProperty(
197 description
="Distortion amount"
199 hard_noise
: EnumProperty(
202 description
="Soft Noise, Hard noise",
204 ("0", "Soft", "Soft Noise", 0),
205 ("1", "Hard", "Hard noise", 1)]
207 noise_depth
: IntProperty(
212 description
="Noise Depth - number of frequencies in the fBm"
214 amplitude
: FloatProperty(
219 description
="Amplitude"
221 frequency
: FloatProperty(
226 description
="Frequency"
228 dimension
: FloatProperty(
233 description
="H - fractal dimension of the roughest areas"
235 lacunarity
: FloatProperty(
240 description
="Lacunarity - gap between successive frequencies"
242 offset
: FloatProperty(
247 description
="Offset - raises the terrain from sea level"
254 description
="Gain - scale factor"
256 marble_bias
: EnumProperty(
259 description
="Marble bias",
261 ("0", "Sin", "Sin", 0),
262 ("1", "Cos", "Cos", 1),
263 ("2", "Tri", "Tri", 2),
264 ("3", "Saw", "Saw", 3)]
266 marble_sharp
: EnumProperty(
269 description
="Marble sharpness",
271 ("0", "Soft", "Soft", 0),
272 ("1", "Sharp", "Sharp", 1),
273 ("2", "Sharper", "Sharper", 2),
274 ("3", "Soft inv.", "Soft", 3),
275 ("4", "Sharp inv.", "Sharp", 4),
276 ("5", "Sharper inv.", "Sharper", 5)]
278 marble_shape
: EnumProperty(
281 description
="Marble shape",
283 ("0", "Default", "Default", 0),
284 ("1", "Ring", "Ring", 1),
285 ("2", "Swirl", "Swirl", 2),
286 ("3", "Bump", "Bump", 3),
287 ("4", "Wave", "Wave", 4),
292 height
: FloatProperty(
297 description
="Noise intensity scale"
299 height_invert
: BoolProperty(
302 description
="Height invert",
304 height_offset
: FloatProperty(
309 description
="Height offset"
312 fx_mixfactor
: FloatProperty(
317 description
="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
319 fx_mix_mode
: EnumProperty(
322 description
="Effect mix mode",
324 ("0", "Mix", "Mix", 0),
325 ("1", "Add", "Add", 1),
326 ("2", "Sub", "Subtract", 2),
327 ("3", "Mul", "Multiply", 3),
328 ("4", "Abs", "Absolute", 4),
329 ("5", "Scr", "Screen", 5),
330 ("6", "Mod", "Modulo", 6),
331 ("7", "Min", "Minimum", 7),
332 ("8", "Max", "Maximum", 8)
335 fx_type
: EnumProperty(
338 description
="Effect type",
340 ("0", "None", "No effect", 0),
341 ("1", "Gradient", "Gradient", 1),
342 ("2", "Waves", "Waves - Bumps", 2),
343 ("3", "Zigzag", "Zigzag", 3),
344 ("4", "Wavy", "Wavy", 4),
345 ("5", "Bump", "Bump", 5),
346 ("6", "Dots", "Dots", 6),
347 ("7", "Rings", "Rings", 7),
348 ("8", "Spiral", "Spiral", 8),
349 ("9", "Square", "Square", 9),
350 ("10", "Blocks", "Blocks", 10),
351 ("11", "Grid", "Grid", 11),
352 ("12", "Tech", "Tech", 12),
353 ("13", "Crackle", "Crackle", 13),
354 ("14", "Cracks", "Cracks", 14),
355 ("15", "Rock", "Rock noise", 15),
356 ("16", "Lunar", "Craters", 16),
357 ("17", "Cosine", "Cosine", 17),
358 ("18", "Spikey", "Spikey", 18),
359 ("19", "Stone", "Stone", 19),
360 ("20", "Flat Turb", "Flat turbulence", 20),
361 ("21", "Flat Voronoi", "Flat voronoi", 21)
364 fx_bias
: EnumProperty(
367 description
="Effect bias type",
369 ("0", "Sin", "Sin", 0),
370 ("1", "Cos", "Cos", 1),
371 ("2", "Tri", "Tri", 2),
372 ("3", "Saw", "Saw", 3),
373 ("4", "None", "None", 4)
376 fx_turb
: FloatProperty(
381 description
="Effect turbulence distortion"
383 fx_depth
: IntProperty(
388 description
="Effect depth - number of frequencies"
390 fx_amplitude
: FloatProperty(
395 description
="Amplitude"
397 fx_frequency
: FloatProperty(
402 description
="Frequency"
404 fx_size
: FloatProperty(
409 description
="Effect size"
411 fx_loc_x
: FloatProperty(
414 description
="Effect x offset"
416 fx_loc_y
: FloatProperty(
419 description
="Effect y offset"
421 fx_height
: FloatProperty(
426 description
="Effect intensity scale"
428 fx_invert
: BoolProperty(
431 description
="Effect invert"
433 fx_offset
: FloatProperty(
438 description
="Effect height offset"
441 edge_falloff
: EnumProperty(
444 description
="Flatten edges",
446 ("0", "None", "None", 0),
447 ("1", "Y", "Y Falloff", 1),
448 ("2", "X", "X Falloff", 2),
449 ("3", "X Y", "X Y Falloff", 3)]
451 falloff_x
: FloatProperty(
456 description
="Falloff x scale"
458 falloff_y
: FloatProperty(
463 description
="Falloff y scale"
465 edge_level
: FloatProperty(
470 description
="Edge level, sealevel offset"
472 maximum
: FloatProperty(
477 description
="Maximum, flattens terrain at plateau level"
479 minimum
: FloatProperty(
484 description
="Minimum, flattens terrain at seabed level"
486 vert_group
: StringProperty(
490 strata
: FloatProperty(
495 description
="Strata layers / terraces"
497 strata_type
: EnumProperty(
500 description
="Strata types",
502 ("0", "None", "No strata", 0),
503 ("1", "Smooth", "Smooth transitions", 1),
504 ("2", "Sharp Sub", "Sharp subtract transitions", 2),
505 ("3", "Sharp Add", "Sharp add transitions", 3),
506 ("4", "Quantize", "Quantize", 4),
507 ("5", "Quantize Mix", "Quantize mixed", 5)]
509 water_plane
: BoolProperty(
512 description
="Add water plane"
514 water_level
: FloatProperty(
519 description
="Water level"
521 remove_double
: BoolProperty(
522 name
="Remove Doubles",
524 description
="Remove doubles"
526 direction
: EnumProperty(
529 description
="Displacement direction",
531 ("NORMAL", "Normal", "Displace along vertex normal direction", 0),
532 ("Z", "Z", "Displace in the Z direction", 1),
533 ("Y", "Y", "Displace in the Y direction", 2),
534 ("X", "X", "Displace in the X direction", 3)]
536 show_main_settings
: BoolProperty(
537 name
="Main Settings",
539 description
="Show settings"
541 show_noise_settings
: BoolProperty(
542 name
="Noise Settings",
544 description
="Show noise settings"
546 show_displace_settings
: BoolProperty(
547 name
="Displace Settings",
549 description
="Show terrain settings"
551 refresh
: BoolProperty(
554 description
="Refresh"
556 auto_refresh
: BoolProperty(
559 description
="Automatic refresh"
562 def draw(self
, context
):
563 draw_ant_refresh(self
, context
)
564 draw_ant_noise(self
, context
, generate
=False)
565 draw_ant_displace(self
, context
, generate
=False)
569 def poll(cls
, context
):
571 return (ob
and ob
.type == 'MESH')
574 def invoke(self
, context
, event
):
576 return self
.execute(context
)
579 def execute(self
, context
):
581 return {'PASS_THROUGH'}
587 self
.ant_terrain_name
,
657 if self
.vert_group
!= "" and self
.vert_group
in ob
.vertex_groups
:
658 vertex_group
= ob
.vertex_groups
[self
.vert_group
]
661 gi
= vertex_group
.index
662 if self
.direction
== "X":
663 for v
in mesh
.vertices
:
666 v
.co
[0] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
668 if self
.direction
== "Y":
669 for v
in mesh
.vertices
:
672 v
.co
[1] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
674 if self
.direction
== "Z":
675 for v
in mesh
.vertices
:
678 v
.co
[2] += vertex_group
.weight(v
.index
) * noise_gen(v
.co
, props
)
681 for v
in mesh
.vertices
:
684 v
.co
+= vertex_group
.weight(v
.index
) * v
.normal
* noise_gen(v
.co
, props
)
687 if self
.direction
== "X":
688 for v
in mesh
.vertices
:
689 v
.co
[0] += noise_gen(v
.co
, props
)
691 elif self
.direction
== "Y":
692 for v
in mesh
.vertices
:
693 v
.co
[1] += noise_gen(v
.co
, props
)
695 elif self
.direction
== "Z":
696 for v
in mesh
.vertices
:
697 v
.co
[2] += noise_gen(v
.co
, props
)
700 for v
in mesh
.vertices
:
701 v
.co
+= v
.normal
* noise_gen(v
.co
, props
)
705 if self
.auto_refresh
is False: