# [Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [851] trunk/py/scripts/addons/ add_curve_aceous_galore.py: minor update on Curveaceous Galore, now with: ' Splat' and 'Turbulence' curves.

Brendon Murphy meta.androcto1 at gmail.com
Mon Jul 26 23:50:04 CEST 2010

```Revision: 851
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=851
Author:   meta-androcto
Date:     2010-07-26 23:50:03 +0200 (Mon, 26 Jul 2010)

Log Message:
-----------
minor update on Curveaceous Galore, now with: 'Splat' and 'Turbulence' curves.

Modified Paths:
--------------

===================================================================
@@ -20,7 +20,7 @@
'author': 'Jimmy Hazevoet, testscreenings',
-    'version': '0.1',
+    'version': '0.1.1',
'blender': (2, 5, 3),
'location': 'View3D > Add > Curve',
'description': 'Adds many types of curves',
@@ -38,10 +38,12 @@
from bpy.props import *
from mathutils import *
from math import *
+from noise import *
+
###------------------------------------------------------------
#### Some functions to use with others:
###------------------------------------------------------------
-'''
+
#------------------------------------------------------------
# Generate random number:
def randnum( low=0.0, high=1.0, seed=0 ):
@@ -62,8 +64,8 @@
(type=float)
"""

-    s = Noise.setRandomSeed( seed )
-    rnum = Noise.random()
+    seed_set( seed )
+    rnum = random_unit_vector()[0]
rnum = rnum*(high-low)
rnum = rnum+low
return rnum
@@ -72,7 +74,7 @@

#------------------------------------------------------------
# Make some noise:
-def vTurbNoise((x,y,z), iScale=0.25, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 ):
+def vTurbNoise(x,y,z, iScale=0.25, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 ):
"""
vTurbNoise((x,y,z), iScale=0.25, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 )

@@ -100,7 +102,7 @@

rand = randnum(-100,100,Seed)
if Basis ==9: Basis = 14
-    vTurb = Noise.vTurbulence(( x/Size+rand, y/Size+rand, z/Size+rand ), Depth, Hard, Basis )
+    vTurb = turbulence_vector(( x/Size+rand, y/Size+rand, z/Size+rand ), Depth, Hard, Basis )
tx = vTurb[0]*iScale
ty = vTurb[1]*iScale
tz = vTurb[2]*iScale
@@ -110,7 +112,7 @@

#------------------------------------------------------------
# Axis: ( used in 3DCurve Turbulence )
-def AxisFlip((x,y,z), x_axis=1, y_axis=1, z_axis=1, flip=0 ):
+def AxisFlip(x,y,z, x_axis=1, y_axis=0, z_axis=0, flip=0 ):
if flip != 0:
flip *= -1
else: flip = 1
@@ -118,8 +120,8 @@
y *= y_axis*flip
z *= z_axis*flip
return x,y,z
-'''

+
###-------------------------------------------------------------------
#### 2D Curve shape functions:
###-------------------------------------------------------------------
@@ -446,7 +448,7 @@
i+=1
return newpoints

-'''
+
##------------------------------------------------------------
# 2DCurve: Splat:
def SplatCurve(sides=24, scale=1.0, seed=0, basis=0, radius=1.0):
@@ -476,14 +478,14 @@
i = 0
while i < sides:
t = (i*step)
-        turb = vTurbNoise(t, 1.0, scale, 6, 0, basis, seed )
-        turb = turb[2] * 0.5 + 0.5
+        turb = vTurbNoise(t,t,t, 1.0, scale, 6, 0, basis, seed )
+        turb = turb[0] * 0.5 + 0.5
newpoints.append([x,y,0])
i+=1
return newpoints
-'''
+
###-----------------------------------------------------------
#### 3D curve shape functions:
###-----------------------------------------------------------
@@ -573,6 +575,46 @@
newpoints = [[-1,-1,0], [-1,1,0], [1,1,0], [1,-1,0]]
return newpoints

+
+###------------------------------------------------------------
+# 3DCurve: Turbulence: tnoise=[ iScale, Size, Depth, Hard, Basis, Seed ], axis=[x,y,z]
+def TurbulenceCurve( number=24, length=2.0, iScale=0.25, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 ):
+    """
+    TurbulenceCurve( number=24, length=2.0, iScale=0.25, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 )
+
+    Create turbulence curve
+
+        Parameters:
+            number - the number of points
+                (type=int)
+            length - length of curve
+                (type=float)
+            Size - Noise size - float 0.0,inf
+            Depth - Noise depth - int 0,8
+            Hard - Noise hard - int 0,1
+            Basis - Noise basis - int 0,9
+            Seed
+        Returns:
+            a list with lists of x,y,z coordinates for curve points, [[x,y,z],[x,y,z],...n]
+            (type=list)
+    """
+
+    newpoints = []
+    step = (length/(number-1))
+    i = 0
+    while i < number:
+        t = (i*step)
+        x,y,z = AxisFlip(t,t,t, 0, 0, 1, 0 )
+        turb = vTurbNoise(x,y,z, iScale, Size=1.0, Depth=6, Hard=0, Basis=0, Seed=0 )
+        if i==0:
+            newpoints.append([x,y,z])
+        else:
+            newpoints.append([x+turb[0], y+turb[1], z+turb[2] ])
+        i+=1
+    return newpoints
+
+
+
##------------------------------------------------------------
# calculates the matrix for the new object
# depending on user pref
@@ -693,13 +735,15 @@
if galType == 'Nsided':
-#    if galType == 'Splat':
-#        verts = SplatCurve(options[23], options[24], options[25], options[26], outerRadius)
+    if galType == 'Splat':
+        verts = SplatCurve(options[23], options[24], options[25], options[26], outerRadius)
if galType == 'Helix':
verts = HelixCurve(options[27], options[28], options[29], options[30], options[31], options[32], options[33])
if galType == 'Cycloid':
verts = CycloidCurve(options[34], options[35], options[36], options[37], options[38], options[39], options[40])
-
+    if galType == 'Turbulence':
+        verts = TurbulenceCurve(options[41], options[42], options[43], options[44], options[45], options[46], options[47], options[48])
+
# turn verts into array
vertArray = vertsToPoints(verts, splineType)

@@ -727,9 +771,10 @@
('Arc', 'Arc', 'Arc'),
('Cogwheel', 'Cogwheel', 'Cogwheel'),
('Nsided', 'Nsided', 'Nsided'),
-#                ('Splat', 'Splat', 'Splat'),
+                ('Splat', 'Splat', 'Splat'),
('Cycloid', 'Cycloid', 'Cycloid'),
-                ('Helix', 'Helix (3D)', 'Helix')]
+                ('Helix', 'Helix (3D)', 'Helix'),
+                ('Turbulence', 'Turbulence (3D)', 'Turbulence')]
GalloreType = EnumProperty(name="Type",
description="Form of Curve to create",
items=GalloreTypes)
@@ -871,6 +916,8 @@
default=1.0,
min=0, soft_min=0,
description="Splat scale")
+
+    ###### Splat + Turbulence props
seed = IntProperty(name="Seed",
default=0,
min=0, soft_min=0,
@@ -933,6 +980,32 @@
default=360.0,
description="Cycloid end angle")

+    #### Turbulence properties
+    turb_points = IntProperty(name="Resolution",
+                            default=100,
+                            min=3, soft_min=3,
+                            description="Resolution")
+    turb_length = FloatProperty(name="Length",
+                            default=2.0,
+                            description="Length")
+    turb_iscale = FloatProperty(name="Intensity scale",
+                            default=0.25,
+                            min=0.01, soft_min=0.01,
+                            description="Intensity scale")
+    turb_size = FloatProperty(name="Noise size",
+                            default=0.25,
+                            min=0.01, soft_min=0.01,
+                            description="Noise size")
+    turb_depth = IntProperty(name="Depth",
+                            default=6,
+                            min=1, max=8,
+                            description="Noise depth")
+    turb_hard = BoolProperty(name="Hard",
+                            default=0,
+                            description="Hard noise")
+
+
+
##### DRAW #####
def draw(self, context):
props = self.properties
@@ -980,14 +1053,14 @@
if props.GalloreType == 'Nsided':
box.prop(props, 'Nsides')
-        '''
+
if props.GalloreType == 'Splat':
box.prop(props, 'splatSides')
box.prop(props, 'splatScale')
box.prop(props, 'seed')
box.prop(props, 'basis')
-        '''
+
if props.GalloreType == 'Helix':
box.prop(props, 'helixPoints')
box.prop(props, 'helixHeight')
@@ -1005,6 +1078,16 @@
box.prop(props, 'cyclo_b')
box.prop(props, 'cyclo_d')

+        if props.GalloreType == 'Turbulence':
+            box.prop(props, 'turb_points')
+            box.prop(props, 'turb_length')
+            box.prop(props, 'turb_size')
+            box.prop(props, 'turb_iscale')
+            box.prop(props, 'turb_depth')
+            box.prop(props, 'seed')
+            box.prop(props, 'basis')
+            #box.prop(props, 'turb_hard')
+
col = layout.column()
col.label(text="Output Curve Type")
row = layout.row()
@@ -1041,9 +1124,9 @@
bpy.context.user_preferences.edit.global_undo = False

props = self.properties
-        if props.GalloreType in ['Helix', 'Cycloid']:
+        if props.GalloreType in ['Helix', 'Cycloid', 'Turbulence']:
props.shape = '3D'
-        if props.GalloreType in ['Helix']:
+        if props.GalloreType in ['Helix', 'Turbulence']:
props.cyclic_u = False

# Options
@@ -1095,12 +1178,21 @@
props.helix_b,              #33
# Cycloid properties
props.cycloPoints,          #34
-            props.cyclo_d,          #35
+            props.cyclo_d,              #35
props.cycloType,            #36
props.cyclo_a,              #37
props.cyclo_b,              #38
props.cycloStart,           #39
-            props.cycloEnd              #40
+            props.cycloEnd,             #40
+            # Turbulence properties
+            props.turb_points,          #41
+            props.turb_length,          #42
+            props.turb_iscale,          #43
+            props.turb_size,            #44

@@ Diff output truncated at 10240 characters. @@

```