[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [678] trunk/py/scripts/addons/ add_curve_aceous_galore.py: addons/add_curve_aceous_galore.py

Brendon Murphy meta.androcto1 at gmail.com
Sun May 23 06:44:44 CEST 2010


Revision: 678
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=678
Author:   meta-androcto
Date:     2010-05-23 06:44:25 +0200 (Sun, 23 May 2010)

Log Message:
-----------
addons/add_curve_aceous_galore.py
added to trunk.
also a "curve menu" script.

Added Paths:
-----------
    trunk/py/scripts/addons/add_curve_aceous_galore.py

Added: trunk/py/scripts/addons/add_curve_aceous_galore.py
===================================================================
--- trunk/py/scripts/addons/add_curve_aceous_galore.py	                        (rev 0)
+++ trunk/py/scripts/addons/add_curve_aceous_galore.py	2010-05-23 04:44:25 UTC (rev 678)
@@ -0,0 +1,1150 @@
+# ##### 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_addon_info = {
+    'name': 'Add Curve: Curveaceous Galore!',
+    'author': 'Jimmy Hazevoet, testscreenings',
+    'version': '0.1',
+    'blender': (2, 5, 2),
+    'location': 'Add Curve menu',
+    'url': '',
+    'description': 'adds many types of curves',
+    'url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
+        'Scripts/Curve/Curves_Galore',
+    'category': 'Add Curve'}
+##------------------------------------------------------------
+#### import modules
+import bpy
+from bpy.props import *
+from mathutils import *
+from math import *
+###------------------------------------------------------------
+#### Some functions to use with others:
+###------------------------------------------------------------
+'''
+#------------------------------------------------------------
+# Generate random number:
+def randnum( low=0.0, high=1.0, seed=0 ):
+    """
+    randnum( low=0.0, high=1.0, seed=0 )
+    
+    Create random number
+    
+        Parameters:
+            low - lower range
+                (type=float)
+            high - higher range
+                (type=float)
+            seed - the random seed number, if seed is 0, the current time will be used instead
+                (type=int)
+        Returns:
+            a random number
+                (type=float)
+    """
+
+    s = Noise.setRandomSeed( seed )
+    rnum = Noise.random()
+    rnum = rnum*(high-low)
+    rnum = rnum+low
+    return rnum
+
+
+
+#------------------------------------------------------------
+# Make some noise:
+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 )
+    
+    Create randomised vTurbulence noise
+    
+        Parameters:
+            xyz - (x,y,z) float values.
+                (type=3-float tuple)
+            iScale - noise intensity scale
+                (type=float)
+            Size - noise size
+                (type=float)
+            Depth - number of noise values added.
+                (type=int)
+            Hard - noise hardness: 0 - soft noise; 1 - hard noise
+                (type=int)
+            basis - type of noise used for turbulence
+                (type=int)
+            Seed - the random seed number, if seed is 0, the current time will be used instead
+                (type=int)
+        Returns:
+            the generated turbulence vector.
+                (type=3-float list)
+    """
+
+    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 )
+    tx = vTurb[0]*iScale
+    ty = vTurb[1]*iScale
+    tz = vTurb[2]*iScale
+    return tx,ty,tz
+
+
+
+#------------------------------------------------------------
+# Axis: ( used in 3DCurve Turbulence )
+def AxisFlip((x,y,z), x_axis=1, y_axis=1, z_axis=1, flip=0 ):
+    if flip != 0:
+        flip *= -1
+    else: flip = 1
+    x *= x_axis*flip
+    y *= y_axis*flip
+    z *= z_axis*flip
+    return x,y,z
+'''
+
+###-------------------------------------------------------------------
+#### 2D Curve shape functions:
+###-------------------------------------------------------------------
+
+##------------------------------------------------------------
+# 2DCurve: Profile:  L, H, T, U, Z
+def ProfileCurve(type=0, a=0.25, b=0.25):
+    """
+    ProfileCurve( type=0, a=0.25, b=0.25 )
+    
+    Create profile curve 
+        
+        Parameters:
+            type - select profile type, L, H, T, U, Z
+                (type=int)
+            a - a scaling parameter
+                (type=float)
+            b - b scaling parameter
+                (type=float)
+        Returns:
+            a list with lists of x,y,z coordinates for curve points, [[x,y,z],[x,y,z],...n]
+            (type=list)
+    """
+
+    newpoints = []
+    if type ==1:
+        ## H:
+        a*=0.5
+        b*=0.5
+        newpoints = [ [ -1.0, 1.0, 0.0 ], [ -1.0+a, 1.0, 0.0 ],
+        [ -1.0+a, b, 0.0 ], [ 1.0-a, b, 0.0 ], [ 1.0-a, 1.0, 0.0 ],
+        [ 1.0, 1.0, 0.0 ],  [ 1.0, -1.0, 0.0 ], [ 1.0-a, -1.0, 0.0 ],
+        [ 1.0-a, -b, 0.0 ], [ -1.0+a, -b, 0.0 ], [ -1.0+a, -1.0, 0.0 ],
+        [ -1.0, -1.0, 0.0 ] ]
+    elif type ==2:
+        ## T:
+        a*=0.5
+        newpoints = [ [ -1.0, 1.0, 0.0 ], [ 1.0, 1.0, 0.0 ],
+        [ 1.0, 1.0-b, 0.0 ], [ a, 1.0-b, 0.0 ], [ a, -1.0, 0.0 ],
+        [ -a, -1.0, 0.0 ], [ -a, 1.0-b, 0.0 ], [ -1.0, 1.0-b, 0.0 ] ]
+    elif type ==3:
+        ## U:
+        a*=0.5
+        newpoints = [ [ -1.0, 1.0, 0.0 ], [ -1.0+a, 1.0, 0.0 ],
+        [ -1.0+a, -1.0+b, 0.0 ], [ 1.0-a, -1.0+b, 0.0 ], [ 1.0-a, 1.0, 0.0 ],
+        [ 1.0, 1.0, 0.0 ], [ 1.0, -1.0, 0.0 ], [ -1.0, -1.0, 0.0 ] ]
+    elif type ==4:
+        ## Z:
+        a*=0.5
+        newpoints = [ [ -0.5, 1.0, 0.0 ], [ a, 1.0, 0.0 ],
+        [ a, -1.0+b, 0.0 ], [ 1.0, -1.0+b, 0.0 ], [ 1.0, -1.0, 0.0 ],
+        [ -a, -1.0, 0.0 ], [ -a, 1.0-b, 0.0 ], [ -1.0, 1.0-b, 0.0 ],
+        [ -1.0, 1.0, 0.0 ] ]
+    else:
+        ## L:
+        newpoints = [ [ -1.0, 1.0, 0.0 ], [ -1.0+a, 1.0, 0.0 ],
+        [ -1.0+a, -1.0+b, 0.0 ], [ 1.0, -1.0+b, 0.0 ],
+        [ 1.0, -1.0, 0.0 ], [ -1.0, -1.0, 0.0 ] ]
+    return newpoints
+
+##------------------------------------------------------------
+# 2DCurve: Miscellaneous.: Diamond, Arrow1, Arrow2, Square, ....
+def MiscCurve(type=1, a=1.0, b=0.5, c=90.0):
+    """
+    MiscCurve( type=1, a=1.0, b=0.5, c=90.0 )
+    
+    Create miscellaneous curves
+    
+        Parameters:
+            type - select type, Diamond, Arrow1, Arrow2, Square
+                (type=int)
+            a - a scaling parameter
+                (type=float)
+            b - b scaling parameter
+                (type=float)
+            c - c scaling parameter
+                (type=float)
+                doesn't seem to do anything
+        Returns:
+            a list with lists of x,y,z coordinates for curve points, [[x,y,z],[x,y,z],...n]
+            (type=list)
+    """
+
+    newpoints = []
+    a*=0.5
+    b*=0.5
+    if type ==1:
+        ## diamond:
+        newpoints = [ [ 0.0, b, 0.0 ], [ a, 0.0, 0.0 ], [ 0.0, -b, 0.0 ], [ -a, 0.0, 0.0 ]  ]
+    elif type ==2:
+        ## Arrow1:
+        newpoints = [ [ -a, b, 0.0 ], [ a, 0.0, 0.0 ], [ -a, -b, 0.0 ], [ 0.0, 0.0, 0.0 ]  ]
+    elif type ==3:
+        ## Arrow2:
+        newpoints = [ [ -1.0, b, 0.0 ], [ -1.0+a, b, 0.0 ],
+        [ -1.0+a, 1.0, 0.0 ], [ 1.0, 0.0, 0.0 ],
+        [ -1.0+a, -1.0, 0.0 ], [ -1.0+a, -b, 0.0 ],
+        [ -1.0, -b, 0.0 ] ]
+    elif type ==4:
+        ## Rounded square:
+        newpoints = [ [ -a, b-b*0.2, 0.0 ], [ -a+a*0.05, b-b*0.05, 0.0 ], [ -a+a*0.2, b, 0.0 ],
+        [ a-a*0.2, b, 0.0 ], [ a-a*0.05, b-b*0.05, 0.0 ], [ a, b-b*0.2, 0.0 ],
+        [ a, -b+b*0.2, 0.0 ], [ a-a*0.05, -b+b*0.05, 0.0 ], [ a-a*0.2, -b, 0.0 ],
+        [ -a+a*0.2, -b, 0.0 ], [ -a+a*0.05, -b+b*0.05, 0.0 ], [ -a, -b+b*0.2, 0.0 ] ]
+
+    #elif type ==15:
+        ## :
+        #newpoints = [ [ x,y,z ] ]
+    else:
+        ## Square:
+        newpoints = [ [ -a, b, 0.0 ], [ a, b, 0.0 ], [ a, -b, 0.0 ], [ -a, -b, 0.0 ]  ]
+    return newpoints
+
+##------------------------------------------------------------
+# 2DCurve: Star:
+def StarCurve(starpoints=8, innerradius=0.5, outerradius=1.0, twist=0.0):
+    """
+    StarCurve( starpoints=8, innerradius=0.5, outerradius=1.0, twist=0.0 )
+    
+    Create star shaped curve
+    
+        Parameters:
+            starpoints - the number of points
+                (type=int)
+            innerradius - innerradius
+                (type=float)
+            outerradius - outerradius
+                (type=float)
+            twist - twist amount
+                (type=float)
+        Returns:
+            a list with lists of x,y,z coordinates for curve points, [[x,y,z],[x,y,z],...n]
+            (type=list)
+    """
+
+    newpoints = []
+    step = (2.0/(starpoints))
+    i = 0
+    while i < starpoints:
+        t = (i*step)
+        x1 = cos(t*pi)*outerradius
+        y1 = sin(t*pi)*outerradius
+        newpoints.append([x1,y1,0])
+        x2 = cos(t*pi+(pi/starpoints+twist))*innerradius
+        y2 = sin(t*pi+(pi/starpoints+twist))*innerradius
+        newpoints.append([x2,y2,0])
+        i+=1
+    return newpoints
+
+##------------------------------------------------------------
+# 2DCurve: Flower:
+def FlowerCurve(petals=8, innerradius=0.5, outerradius=1.0, petalwidth=2.0):
+    """
+    FlowerCurve( petals=8, innerradius=0.5, outerradius=1.0, petalwidth=2.0 )
+    
+    Create flower shaped curve
+    
+        Parameters:
+            petals - the number of petals
+                (type=int)
+            innerradius - innerradius
+                (type=float)
+            outerradius - outerradius
+                (type=float)
+            petalwidth - width of petals
+                (type=float)
+        Returns:
+            a list with lists of x,y,z coordinates for curve points, [[x,y,z],[x,y,z],...n]
+            (type=list)
+    """
+
+    newpoints = []
+    step = (2.0/(petals))
+    pet = (step/pi*2)*petalwidth
+    i = 0
+    while i < petals:
+        t = (i*step)
+        x1 = cos(t*pi-(pi/petals))*innerradius
+        y1 = sin(t*pi-(pi/petals))*innerradius
+        newpoints.append([x1,y1,0])

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list