[Bf-extensions-cvs] [e19917af] master: initial commit ANT Displace by Jimmy Haze
meta-androcto
noreply at git.blender.org
Sat May 13 11:16:53 CEST 2017
Commit: e19917af55f9eeae398883ba7c8f8c25e22fe04e
Author: meta-androcto
Date: Sat May 13 19:16:22 2017 +1000
Branches: master
https://developer.blender.org/rBACe19917af55f9eeae398883ba7c8f8c25e22fe04e
initial commit ANT Displace by Jimmy Haze
===================================================================
A mesh_ant_displace.py
===================================================================
diff --git a/mesh_ant_displace.py b/mesh_ant_displace.py
new file mode 100644
index 00000000..8d9e956d
--- /dev/null
+++ b/mesh_ant_displace.py
@@ -0,0 +1,1171 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+bl_info = {
+ "name": "ANT Displace",
+ "author": "Jimmy Hazevoet",
+ "version": (0, 1, 6),
+ "blender": (2, 77, 0),
+ "location": "View3D > Tool Shelf",
+ "description": "Displace vertices of selected mesh",
+ "warning": "",
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Scripts/Add_Mesh/ANT_Landscape",
+ "category": "Mesh",
+}
+
+"""
+# -------------------------------------------------------------
+--- UPDATE: - VERSION 0,1,6 (5/2017) - Vert Displace Version
+# -------------------------------------------------------------
+ - NEW:
+ -
+ - Vert Displace Version
+ - Slope map, z normal to vertex group weight,
+ and optional select vertices on flat area's
+ - Noise variations (from old A.N.T. Blender-2.49 addon)
+ - Variable X and Y noise size (and X Y Offset since version 0.1.5)
+ - Plateau and Sealevel renamed to Maximum (plateau) and Minimum (now: seabed)
+ - Variable X and Y edge fallof with variable edge level (now: sealevel)
+ -
+# -------------------------------------------------------------
+# Another Noise Tool: Vert Displace Version
+# -------------------------------------------------------------
+MESH OPTIONS:
+Mesh update: Turn this on for interactive mesh refresh.
+Vertex Group: Slope map, z normal value to vertex group weight,
+ and select vertices on flat area's
+
+NOISE OPTIONS: ( Many of these options are the same as in blender textures. )
+X_Offset: Noise x offset in blender units (make tiled terrain)
+Y_Offset: Noise y offset in blender units
+Random seed: Use this to randomise the origin of the noise function.
+Noise size: Size of the noise.
+Noise type: Available noise types: multiFractal, ridgedMFractal, fBm, hybridMFractal, heteroTerrain,
+ Turbulence, Distorted Noise, Marble, Shattered_hTerrain, Strata_hTerrain, Planet_noise
+Noise basis: Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1,
+ Voronoi Crackle, Cellnoise
+Distortion: Distortion amount.
+Hard: Hard/Soft turbulence noise.
+Depth: Noise depth, number of frequencies in the fBm.
+Dimension: Musgrave: Fractal dimension of the roughest areas.
+Lacunarity: Musgrave: Gap between successive frequencies.
+Offset: Musgrave: Raises the terrain from sea level.
+Gain: Musgrave: Scale factor.
+Marble Bias: Sin, Tri, Saw
+Marble Sharpnes: Soft, Sharp, Sharper
+Marble Shape: Shape of the marble function: Default, Ring, Swirl, Bumps, Wave, X, Y
+
+TERRAIN OPTIONS:
+Height: Scale terrain height.
+Invert: Invert terrain height.
+Offset: Terrain height offset.
+Seabed: Flattens terrain at seabed level.
+Plateau: Flattens terrain at plateau level.
+Falloff: Terrain height falloff: X falloff, Y falloff, XY falloff
+Edge Level: Falloff edge level, sealevel
+FalloffSizeX: Scale falloff x
+FalloffSizeY: Scale falloff y
+Strata: Strata amount, number of strata / terrace layers.
+Strata type: Strata types, Smooth, Sharp-sub, Sharp-add, Quantize
+"""
+
+# ------------------------------------------------------------
+# import modules
+import bpy
+import os
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ FloatVectorProperty,
+ )
+from mathutils import Vector
+from mathutils.noise import (
+ seed_set,
+ turbulence,
+ turbulence_vector,
+ fractal,
+ hybrid_multi_fractal,
+ multi_fractal,
+ ridged_multi_fractal,
+ hetero_terrain,
+ random_unit_vector,
+ variable_lacunarity,
+ )
+from math import (
+ floor, sqrt,
+ sin, cos, pi,
+ )
+
+# ------------------------------------------------------------
+# some functions for marble_noise
+def sin_bias(a):
+ return 0.5 + 0.5 * sin(a)
+
+
+def cos_bias(a):
+ return 0.5 + 0.5 * cos(a)
+
+
+def tri_bias(a):
+ b = 2 * pi
+ a = 1 - 2 * abs(floor((a * (1 / b)) + 0.5) - (a * (1 / b)))
+ return a
+
+
+def saw_bias(a):
+ b = 2 * pi
+ n = int(a / b)
+ a -= n * b
+ if a < 0:
+ a += b
+ return a / b
+
+
+def soft(a):
+ return a
+
+
+def sharp(a):
+ return a**0.5
+
+
+def sharper(a):
+ return sharp(sharp(a))
+
+
+def shapes(x, y, shape=0):
+ p = pi
+ if shape is 1:
+ # ring
+ x = x * p
+ y = y * p
+ s = cos(x**2 + y**2) / (x**2 + y**2 + 0.5)
+ elif shape is 2:
+ # swirl
+ x = x * p
+ y = y * p
+ s = ((x * sin(x * x + y * y) + y * cos(x * x + y * y)) / (x**2 + y**2 + 0.5))
+ elif shape is 3:
+ # bumps
+ x = x * p
+ y = y * p
+ s = ((cos(x * p) + cos(y * p)) - 0.5)
+ elif shape is 4:
+ # wave
+ x = x * p * 2
+ y = y * p * 2
+ s = sin(x + sin(y))
+ elif shape is 5:
+ # y grad.
+ s = (y * p)
+ elif shape is 6:
+ # x grad.
+ s = (x * p)
+ else:
+ # marble default
+ s = ((x + y) * 5)
+ return s
+
+
+# marble_noise
+def marble_noise(x, y, z, origin, size, shape, bias, sharpnes, turb, depth, hard, basis, amp, freq):
+
+ s = shapes(x, y, shape)
+ x += origin[0]
+ y += origin[1]
+ z += origin[2]
+ value = s + turb * turbulence_vector((x, y, z), depth, hard, basis)[0]
+
+ if bias is 1:
+ value = cos_bias(value)
+ if bias is 2:
+ value = tri_bias(value)
+ elif bias is 3:
+ value = saw_bias(value)
+ else:
+ value = sin_bias(value)
+
+ if sharpnes is 1:
+ value = 1.0 - sharp(value)
+ elif sharpnes is 2:
+ value = 1.0 - sharper(value)
+ elif sharpnes is 3:
+ value = soft(value)
+ elif sharpnes is 4:
+ value = sharp(value)
+ elif sharpnes is 5:
+ value = sharper(value)
+ else:
+ value = 1.0 - soft(value)
+
+ return value
+
+# ------------------------------------------------------------
+# custom noise types
+
+# vl_noise_turbulence:
+def vlnTurbMode(coords, distort, basis, vlbasis, hardnoise):
+ # hard noise
+ if hardnoise:
+ return (abs(-variable_lacunarity(coords, distort, basis, vlbasis)))
+ # soft noise
+ else:
+ return variable_lacunarity(coords, distort, basis, vlbasis)
+
+
+def vl_noise_turbulence(coords, distort, depth, basis, vlbasis, hardnoise, amp, freq):
+ x, y, z = coords
+ value = vlnTurbMode(coords, distort, basis, vlbasis, hardnoise)
+ i=0
+ for i in range(depth):
+ i+=1
+ value += vlnTurbMode((x * (freq * i), y * (freq * i), z * (freq * i)), distort, basis, vlbasis, hardnoise) * (amp * 0.5 / i)
+ return value
+
+
+## duo_multiFractal:
+def double_multiFractal(coords, H, lacunarity, octaves, offset, gain, basis, vlbasis):
+ x, y, z = coords
+ n1 = multi_fractal((x * 1.5 + 1, y * 1.5 + 1, z * 1.5 + 1), 1.0, 1.0, 1.0, basis) * (offset * 0.5)
+ n2 = multi_fractal((x - 1, y - 1, z - 1), H, lacunarity, octaves, vlbasis) * (gain * 0.5)
+ return (n1 * n1 + n2 * n2) * 0.5
+
+
+## distorted_heteroTerrain:
+def distorted_heteroTerrain(coords, H, lacunarity, octaves, offset, distort, basis, vlbasis):
+ x, y, z = coords
+ h1 = (hetero_terrain((x, y, z), 1.0, 2.0, 1.0, 1.0, basis) * 0.5)
+ d = h1 * distort * 2
+ h2 = (hetero_terrain((x + d, y + d, z + d), H, lacunarity, octaves, offset, vlbasis) * 0.25)
+ return (h1 * h1 + h2 * h2) * 0.5
+
+
+## SlickRock:
+def slick_rock(coords, H, lacunarity, octaves, offset, gain, basis, vlbasis):
+ x, y, z = coords
+ gain = 5.0
+ vlbasis = 7
+ n = multi_fractal((x,y,z), 1.0, 2.0, 1.0, basis) * 0.5
+ r = ridged_multi_fractal((x + n, y + n, z + n), H, lacunarity, octaves, offset, gain, vlbasis)
+ return (n + (n * r)) * 0.5
+
+
+## vlhTerrain
+def vl_hTerrain(coords, H, lacunarity, octaves, offset, basis, vlbasis, distort):
+ x, y, z = coords
+ ht = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, basis ) * 0.25
+ vl = ht * variable_lacunarity((x, y, z), distort, basis, vlbasis) * 0.5 + 0.5
+ return vl * ht
+
+
+# another turbulence
+def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion):
+ a = amp
+ x, y, z = coords
+ tv = turbulence_vector((x + 3, y, z), depth, hardnoise, nbasis, a, freq)
+ d = (distortion * tv[0]) * 0.25
+ return (d + ((tv[0] - tv[1]) * (tv[2])**2))
+
+
+# shattered_hterrain:
+def shattered_hterrain(coords, H, lacunarity, octaves, offset, distort, basis):
+ x, y, z = coords
+ d = (turbulence_vector(coords, 6, 0, 0)[0] * 0.5 + 0.5) * distort * 0.5
+ t1 = (turbulence_vector((x + d, y + d, z + d), 0, 0, 7)[0] + 0.5)
+ t2 = (hetero_terrain((x * 2, y * 2, z * 2), H, lacunarity, octaves, offset, basis) * 0.5)
+ return ((t1 * t2) + t2 * 0.5) * 0.5
+
+
+# strata_hterrain
+def strata_hterrain(coords, H, lacunarity, octaves, offset, distort, basis):
+ x, y, z = coords
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list