[Bf-extensions-cvs] [e3f4241] master: update add_mesh_ant_landscape.py add Farsthary planet noise re: T48967

meta-androcto noreply at git.blender.org
Sun Jul 31 13:03:49 CEST 2016


Commit: e3f4241e295df0e1efa725606b3823f06db7a36b
Author: meta-androcto
Date:   Sun Jul 31 21:03:24 2016 +1000
Branches: master
https://developer.blender.org/rBAe3f4241e295df0e1efa725606b3823f06db7a36b

update add_mesh_ant_landscape.py add Farsthary planet noise re: T48967

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

M	add_mesh_ant_landscape.py

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

diff --git a/add_mesh_ant_landscape.py b/add_mesh_ant_landscape.py
index e4a1a29..262d06a 100644
--- a/add_mesh_ant_landscape.py
+++ b/add_mesh_ant_landscape.py
@@ -19,13 +19,14 @@
 bl_info = {
     "name": "ANT Landscape",
     "author": "Jimmy Hazevoet",
-    "version": (0,1,3),
+    "version": (0, 1, 4),
     "blender": (2, 77, 0),
     "location": "View3D > Add > Mesh",
     "description": "Add a landscape primitive",
     "warning": "", # used for warning icon and text in addons panel
     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Add_Mesh/ANT_Landscape",
+    "tracker_url": "https://developer.blender.org/maniphest/task/create/?project=3&type=Bug",
     "category": "Add Mesh",
 }
 
@@ -34,15 +35,17 @@ Another Noise Tool: Landscape mesh generator
 
 MESH OPTIONS:
 Mesh update:     Turn this on for interactive mesh update.
-Sphere:          Generate sphere or a grid mesh. (Turn height falloff off for sphere mesh)
+Sphere:          Generate sphere or a grid mesh.
 Smooth:          Generate smooth shaded mesh.
 Subdivision:     Number of mesh subdivisions, higher numbers gives more detail but also slows down the script.
-Mesh size:       X,Y size of the grid mesh (in blender units).
+Mesh size:       X,Y size of the grid mesh in blender units.
+X_Offset:        Noise x offset in blender units (make tiled terrain)
+Y_Offset:        Noise y offset in blender units
 
 NOISE OPTIONS: ( Most of these options are the same as in blender textures. )
 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, hybridMFractal, heteroTerrain, Turbulence, Distorted Noise, Cellnoise, Shattered_hTerrain, Marble
+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
 VLNoise basis:   Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1, Voronoi Crackle, Cellnoise
 Distortion:      Distortion amount.
@@ -92,75 +95,6 @@ def create_mesh_object(context, verts, edges, faces, name):
     from bpy_extras import object_utils
     return object_utils.object_data_add(context, mesh, operator=None)
 
-# A very simple "bridge" tool.
-# Connects two equally long vertex rows with faces.
-# Returns a list of the new faces (list of  lists)
-#
-# vertIdx1 ... First vertex list (list of vertex indices).
-# vertIdx2 ... Second vertex list (list of vertex indices).
-# closed ... Creates a loop (first & last are closed).
-# flipped ... Invert the normal of the face(s).
-#
-# Note: You can set vertIdx1 to a single vertex index to create
-#    a fan/star of faces.
-# Note: If both vertex idx list are the same length they have
-#    to have at least 2 vertices.
-def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
-    faces = []
-
-    if not vertIdx1 or not vertIdx2:
-        return None
-
-    if len(vertIdx1) < 2 and len(vertIdx2) < 2:
-        return None
-
-    fan = False
-    if (len(vertIdx1) != len(vertIdx2)):
-        if (len(vertIdx1) == 1 and len(vertIdx2) > 1):
-            fan = True
-        else:
-            return None
-
-    total = len(vertIdx2)
-
-    if closed:
-        # Bridge the start with the end.
-        if flipped:
-            face = [
-                vertIdx1[0],
-                vertIdx2[0],
-                vertIdx2[total - 1]]
-            if not fan:
-                face.append(vertIdx1[total - 1])
-            faces.append(face)
-
-        else:
-            face = [vertIdx2[0], vertIdx1[0]]
-            if not fan:
-                face.append(vertIdx1[total - 1])
-            face.append(vertIdx2[total - 1])
-            faces.append(face)
-
-    # Bridge the rest of the faces.
-    for num in range(total - 1):
-        if flipped:
-            if fan:
-                face = [vertIdx2[num], vertIdx1[0], vertIdx2[num + 1]]
-            else:
-                face = [vertIdx2[num], vertIdx1[num],
-                    vertIdx1[num + 1], vertIdx2[num + 1]]
-            faces.append(face)
-        else:
-            if fan:
-                face = [vertIdx1[0], vertIdx2[num], vertIdx2[num + 1]]
-            else:
-                face = [vertIdx1[num], vertIdx2[num],
-                    vertIdx2[num + 1], vertIdx1[num + 1]]
-            faces.append(face)
-
-    return faces
-
-
 ###------------------------------------------------------------
 ###------------------------------------------------------------
 # some functions for marble_noise
@@ -259,14 +193,30 @@ def strata_hterrain( x,y,z, H, lacunarity, octaves, offset, distort, basis ):
     steps = ( sin( value*(distort*5)*pi ) * ( 0.1/(distort*5)*pi ) )
     return ( value * (1.0-0.5) + steps*0.5 )
 
+# planet_noise by Farsthary: https://blenderartists.org/forum/showthread.php?202944-New-quot-Planet-quot-procedural-texture-by-Farsthary
+def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001):
+    x,y,z = coords
+    d = 0.001
+    offset = nabla * 1000
+    x = turbulence((x, y, z), oct, hard, noisebasis)
+    y = turbulence((x + offset, y , z), oct, hard, noisebasis)
+    z = turbulence((x, y + offset, z), oct, hard, noisebasis)
+    xdy = x - turbulence((x, y + d, z), oct, hard, noisebasis)
+    xdz = x - turbulence((x, y, z + d), oct, hard, noisebasis)
+    ydx = y - turbulence((x + d, y, z), oct, hard, noisebasis)
+    ydz = y - turbulence((x, y, z + d), oct, hard, noisebasis)
+    zdx = z - turbulence((x + d, y, z), oct, hard, noisebasis)
+    zdy = z - turbulence((x, y + d, z), oct, hard, noisebasis)
+    return (zdy - ydz), (zdx - xdz), (ydx - xdy)
+
 ###------------------------------------------------------------
 # landscape_gen
-def landscape_gen(x,y,z,falloffsize,options=[0,1.0,1, 0,0,1.0,0,6,1.0,2.0,1.0,2.0,0,0,0, 1.0,0.0,1,0.0,1.0,0,0,0,0.0,0.0]):
+def landscape_gen(x,y,z,falloffsize,options=[0,1.0,'multi_fractal', 0,0,1.0,0,6,1.0,2.0,1.0,2.0,0,0,0, 1.0,0.0,1,0.0,1.0,0,0,0,0.0,0.0]):
 
     # options
     rseed    = options[0]
     nsize    = options[1]
-    ntype      = int( options[2][0] )
+    ntype      = options[2]
     nbasis     = int( options[3][0] )
     vlbasis    = int( options[4][0] )
     distortion = options[5]
@@ -312,16 +262,17 @@ def landscape_gen(x,y,z,falloffsize,options=[0,1.0,1, 0,0,1.0,0,6,1.0,2.0,1.0,2.
     if nbasis == 9: nbasis = 14  # to get cellnoise basis you must set 14 instead of 9
     if vlbasis ==9: vlbasis = 14
     # noise type's
-    if ntype == 0:   value = multi_fractal(        ncoords, dimension, lacunarity, depth, nbasis ) * 0.5
-    elif ntype == 1: value = ridged_multi_fractal( ncoords, dimension, lacunarity, depth, offset, gain, nbasis ) * 0.5
-    elif ntype == 2: value = hybrid_multi_fractal( ncoords, dimension, lacunarity, depth, offset, gain, nbasis ) * 0.5
-    elif ntype == 3: value = hetero_terrain(       ncoords, dimension, lacunarity, depth, offset, nbasis ) * 0.25
-    elif ntype == 4: value = fractal(              ncoords, dimension, lacunarity, depth, nbasis )
-    elif ntype == 5: value = turbulence_vector(    ncoords, depth, hardnoise, nbasis )[0]
-    elif ntype == 6: value = variable_lacunarity(            ncoords, distortion, nbasis, vlbasis ) + 0.5
-    elif ntype == 7: value = marble_noise( x*2.0/falloffsize,y*2.0/falloffsize,z*2/falloffsize, origin, nsize, marbleshape, marblebias, marblesharpnes, distortion, depth, hardnoise, nbasis )
-    elif ntype == 8: value = shattered_hterrain( ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis )
-    elif ntype == 9: value = strata_hterrain( ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis )
+    if ntype ==   'multi_fractal':          value = multi_fractal(        ncoords, dimension, lacunarity, depth, nbasis ) * 0.5
+    elif ntype == 'ridged_multi_fractal':   value = ridged_multi_fractal( ncoords, dimension, lacunarity, depth, offset, gain, nbasis ) * 0.5
+    elif ntype == 'hybrid_multi_fractal':   value = hybrid_multi_fractal( ncoords, dimension, lacunarity, depth, offset, gain, nbasis ) * 0.5
+    elif ntype == 'hetero_terrain':         value = hetero_terrain(       ncoords, dimension, lacunarity, depth, offset, nbasis ) * 0.25
+    elif ntype == 'fractal':                value = fractal(              ncoords, dimension, lacunarity, depth, nbasis )
+    elif ntype == 'turbulence_vector':      value = turbulence_vector(    ncoords, depth, hardnoise, nbasis )[0]
+    elif ntype == 'variable_lacunarity':    value = variable_lacunarity(  ncoords, distortion, nbasis, vlbasis ) + 0.5
+    elif ntype == 'marble_noise':           value = marble_noise( x*2.0/falloffsize,y*2.0/falloffsize,z*2/falloffsize, origin, nsize, marbleshape, marblebias, marblesharpnes, distortion, depth, hardnoise, nbasis )
+    elif ntype == 'shattered_hterrain':     value = shattered_hterrain( ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis )
+    elif ntype == 'strata_hterrain':        value = strata_hterrain( ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis )
+    elif ntype == 'planet_noise':           value = planet_noise(ncoords, depth, hardnoise, nbasis)[2]*0.5+0.5
     else:
         value = 0.0
 
@@ -370,64 +321,73 @@ def landscape_gen(x,y,z,falloffsize,options=[0,1.0,1, 0,0,1.0,0,6,1.0,2.0,1.0,2.
 
     return value
 
-
+###------------------------------------------------------------
 # generate grid
 def grid_gen( sub_d, size_me, options ):
-
+    # mesh arrays
     verts = []
     faces = []
-    edgeloop_prev = []
-
-    delta = size_me / (sub_d - 1)
-    start = -(size_me / 2.0)
 
-    for row_x in range(sub_d):
-        edgeloop_cur = []
-        x = start + row_x * delta
-        for row_y in range(sub_d):
-            y = start + row_y * delta
+    # fill verts array
+    for i in range (0, sub_d):
+        for j in

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list