[Bf-extensions-cvs] [85e50368] master: update ANT displace

meta-androcto noreply at git.blender.org
Mon May 15 01:41:34 CEST 2017


Commit: 85e50368806cc7b99a05d77673e0239c1e961b5d
Author: meta-androcto
Date:   Mon May 15 09:41:13 2017 +1000
Branches: master
https://developer.blender.org/rBAC85e50368806cc7b99a05d77673e0239c1e961b5d

update ANT displace

===================================================================

M	mesh_ant_displace.py

===================================================================

diff --git a/mesh_ant_displace.py b/mesh_ant_displace.py
index 8d9e956d..c4cf236d 100644
--- a/mesh_ant_displace.py
+++ b/mesh_ant_displace.py
@@ -17,12 +17,12 @@
 # ##### END GPL LICENSE BLOCK #####
 
 bl_info = {
-    "name": "ANT Displace",
+    "name": "A.N.T. Displace",
     "author": "Jimmy Hazevoet",
     "version": (0, 1, 6),
     "blender": (2, 77, 0),
     "location": "View3D > Tool Shelf",
-    "description": "Displace vertices of selected mesh",
+    "description": "Another Noise Tool: Displace vertices of selected mesh",
     "warning": "",
     "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Add_Mesh/ANT_Landscape",
@@ -31,17 +31,19 @@ bl_info = {
 
 """
 # -------------------------------------------------------------
---- UPDATE:     - VERSION 0,1,6 (5/2017) - Vert Displace Version
+- UPDATE: A.N.T. Displace - Version 0,1,6 (5/2017)
 # -------------------------------------------------------------
                 - NEW:
                 -
-                - Vert Displace Version
+                - Displace vertices of selected mesh
+                - Use Blender internal texture data block - texture nodes
+                - Use vertex group weight of active group
                 - Slope map, z normal to vertex group weight,
                     and optional select vertices on flat area's
+                - Use Blender internal texture data block - texture nodes
                 - 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)
+                - Variable X, Y, Z noise Size and Offset
+                - Plateau and Sealevel renamed to Maximum and Minimum 
                 -
 # -------------------------------------------------------------
 # Another Noise Tool: Vert Displace Version
@@ -77,18 +79,14 @@ 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
+Vertex Group:    Use vertex group weight
 """
 
 # ------------------------------------------------------------
 # import modules
 import bpy
-import os
 from bpy.props import (
         BoolProperty,
         EnumProperty,
@@ -193,7 +191,7 @@ def marble_noise(x, y, z, origin, size, shape, bias, sharpnes, turb, depth, hard
     x += origin[0]
     y += origin[1]
     z += origin[2]
-    value = s + turb * turbulence_vector((x, y, z), depth, hard, basis)[0]
+    value = s + turb * turbulence_vector((x, y, z), depth, hard, basis)[2]
 
     if bias is 1:
         value = cos_bias(value)
@@ -260,12 +258,10 @@ def distorted_heteroTerrain(coords, H, lacunarity, octaves, offset, distort, bas
 
 
 ## SlickRock:
-def slick_rock(coords, H, lacunarity, octaves, offset, gain, basis, vlbasis):
+def slick_rock(coords, H, lacunarity, octaves, offset, gain, distort, 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)
+    n = multi_fractal((x,y,z), 1.0, 2.0, 2.0, basis) * distort * 0.5
+    r = ridged_multi_fractal((x + n, y + n, z + n), H, lacunarity, octaves, offset + 0.1, gain * 2, vlbasis)
     return (n + (n * r)) * 0.5
 
 
@@ -279,9 +275,8 @@ def vl_hTerrain(coords, H, lacunarity, octaves, offset, basis, vlbasis, distort)
 
 # 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)
+    tv = turbulence_vector((x+1, y+2, z+3), depth, hardnoise, nbasis, amp, freq)
     d = (distortion * tv[0]) * 0.25
     return (d + ((tv[0] - tv[1]) * (tv[2])**2))
 
@@ -321,49 +316,48 @@ def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001):
 
 
 # ------------------------------------------------------------
-# landscape_gen
-def landscape_gen(x, y, z, meshsize_x, meshsize_y, options):
-
-    rseed = options[0]
-    nsize = options[1]
-    ntype = options[2]
-    nbasis = int(options[3][0])
-    vlbasis = int(options[4][0])
-    distortion = options[5]
-    hardnoise = int(options[6])
-    depth = options[7]
-    dimension = options[8]
-    lacunarity = options[9]
-    offset = options[10]
-    gain = options[11]
-    marblebias = int(options[12][0])
-    marblesharpnes = int(options[13][0])
-    marbleshape = int(options[14][0])
-    invert = options[15]
-    height = options[16]
-    heightoffset = options[17]
-    falloff = int(options[18][0])
-    sealevel = options[19]
-    platlevel = options[20]
-    strata = options[21]
-    stratatype = options[22]
-    sphere = options[23]
-    x_offset = options[24]
-    y_offset = options[25]
-    edge_level = options[26]
-    falloffsize_x = options[27]
-    falloffsize_y = options[28]
-    size_x = options[29]
-    size_y = options[30]
-    amp = options[31]
-    freq = options[32]
+# noise_gen
+def noise_gen(coords, props):
+
+    rseed = props[0]
+    nsize = props[1]
+    ntype = props[2]
+    nbasis = int(props[3][0])
+    vlbasis = int(props[4][0])
+    distortion = props[5]
+    hardnoise = int(props[6])
+    depth = props[7]
+    dimension = props[8]
+    lacunarity = props[9]
+    offset = props[10]
+    gain = props[11]
+    marblebias = int(props[12][0])
+    marblesharpnes = int(props[13][0])
+    marbleshape = int(props[14][0])
+    invert = props[15]
+    height = props[16]
+    heightoffset = props[17]
+    minimum = props[18]
+    maximum = props[19]
+    strata = props[20]
+    stratatype = props[21]
+    x_offset = props[22]
+    y_offset = props[23]
+    z_offset = props[24]
+    size_x = props[25]
+    size_y = props[26]
+    size_z = props[27]
+    amp = props[28]
+    freq = props[29]
+    texture_name = props[30]
 
+    x, y, z = coords
     # origin
     if rseed is 0:
-        origin = x_offset, y_offset, 0
+        origin = x_offset, y_offset, z_offset
         origin_x = x_offset
         origin_y = y_offset
-        origin_z = 0
+        origin_z = z_offset
         o_range = 1.0
     else:
         # randomise origin
@@ -375,15 +369,9 @@ def landscape_gen(x, y, z, meshsize_x, meshsize_y, options):
         oz = (origin[2] * o_range)
         origin_x = (ox - (ox / 2)) + x_offset
         origin_y = (oy - (oy / 2)) + y_offset
-        origin_z = (oz - (oz / 2))
-
-    ncoords = (x / (nsize * size_x) + origin_x, y / (nsize * size_y) + origin_y, z / nsize + origin_z)
+        origin_z = (oz - (oz / 2)) + z_offset
 
-    # noise basis type's
-    if nbasis is 9:
-        nbasis = 14
-    if vlbasis is 9:
-        vlbasis = 14
+    ncoords = (x / (nsize * size_x) + origin_x, y / (nsize * size_y) + origin_y, z / (nsize * size_z) + origin_z)
 
     # noise type's
     if ntype == 'multi_fractal':
@@ -438,10 +426,16 @@ def landscape_gen(x, y, z, meshsize_x, meshsize_y, options):
         value = double_multiFractal(ncoords, dimension, lacunarity, depth, offset, gain, nbasis, vlbasis)
 
     elif ntype == 'slick_rock':
-        value = slick_rock(ncoords,dimension, lacunarity, depth, offset, gain, nbasis, vlbasis)
+        value = slick_rock(ncoords,dimension, lacunarity, depth, offset, gain, distortion, nbasis, vlbasis)
 
     elif ntype == 'planet_noise':
         value = planet_noise(ncoords, depth, hardnoise, nbasis)[2] * 0.5 + 0.5
+
+    elif ntype == 'blender_texture':
+        if texture_name in bpy.data.textures:
+            value = bpy.data.textures[texture_name].evaluate(ncoords)[3]
+        else:
+            value = 0.0
     else:
         value = 0.0
 
@@ -452,23 +446,7 @@ def landscape_gen(x, y, z, meshsize_x, meshsize_y, options):
     else:
         value = value * height + heightoffset
 
-    # Edge falloff:
-    if falloff:
-        ratio_x, ratio_y = abs(x) * 2 / meshsize_x, abs(y) * 2 / meshsize_y
-        fallofftypes = [0,
-                        sqrt(ratio_y**falloffsize_y),
-                        sqrt(ratio_x**falloffsize_x),
-                        sqrt(ratio_x**falloffsize_x + ratio_y**falloffsize_y)
-                       ]
-        dist = fallofftypes[falloff]
-        value -= edge_level
-        if(dist < 1.0):
-            dist = (dist * dist * (3 - 2 * dist))
-            value = (value - value * dist) + edge_level
-        else:
-            value = edge_level
-
-    # strata / terrace / layered
+    # strata / terrace / layers
     if stratatype != '0':
         strata = strata / height
 
@@ -492,11 +470,11 @@ def landscape_gen(x, y, z, meshsize_x, meshsize_y, options):
         steps = (int( value * strata ) * 1.0 / strata)
         value = (value * (1.0 - 0.5) + steps * 0.5)
 
-    # clamp height
-    if (value < sealevel):
-        value = sealevel
-    if (value > platlevel):
-        value = platlevel
+    # clamp height min max
+    if (value < minimum):
+        value = minimum
+    if (value > maximum):
+        value = maximum
 
     return value
 
@@ -509,13 +487,25 @@ class ANTSlopeVGroup(bpy.types.Operator):
     bl_description = "Slope map - z normal value to vertex group weight"
     #bl_options = {'REGISTER'} 
 
+    z_method = EnumProperty(
+            name="Method:",
+            default='SLOPE_Z',
+            items=[
+                ('SLOPE_Z', "Slope Z", "Slope for planar mesh"),
+                ('SLOPE_XYZ', "Slope XYZ", "Slope for spherical mesh")
+                ])
+    group_name = StringProperty(
+            name="Vertex Group Name:",
+            default="Slope",
+            description="Name"
+            )
     select_flat = BoolProperty(
-            name="Vert

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list