[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [814] branches/ivygen/ivy_test.py: -plugged in gravity

Florian Meyer florianfelix at web.de
Tue Jul 20 02:52:01 CEST 2010


Revision: 814
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=814
Author:   testscreenings
Date:     2010-07-20 02:52:01 +0200 (Tue, 20 Jul 2010)

Log Message:
-----------
-plugged in gravity
-enabled dying of roots based on floating length
--> doesn't matter much because they are all always floating now

Modified Paths:
--------------
    branches/ivygen/ivy_test.py

Modified: branches/ivygen/ivy_test.py
===================================================================
--- branches/ivygen/ivy_test.py	2010-07-19 23:36:41 UTC (rev 813)
+++ branches/ivygen/ivy_test.py	2010-07-20 00:52:01 UTC (rev 814)
@@ -112,23 +112,11 @@
     branchSize = 1.0
     
     # maximum length of an ivy branch segment that is freely floating [0..1]
-    maxFloatingLength = 0.1
+    maxFloatingLength = 8
     
     # maximum distance for adhesion of scene object [0..1]
     maxAdhesionDistance = 0.1
-    
-    # weight for the primary grow vector [0..1]
-    primaryWeight = 0.5
-    
-    # weight for the random influence vector [0..1]
-    randomWeight = 0.5
-    
-    # weight for the gravity vector [0..1]
-    gravityWeight = 0.5
-    
-    # weight for the adhesion vector [0..1]
-    adhesionWeight = 0.5
-    
+
     # the probability of producing a new ivy root per iteration [0..1]
     branchingProbability = 0.95
     
@@ -165,6 +153,13 @@
             prevIvy = root.ivyNodes[-1]
             #print('rootstart', root.ivyNodes[0].position)
             # RANDOM VECTOR
+            
+            # check if it dies of old age
+            if prevIvy.length > self.maxFloatingLength:
+                root.alive = False
+                continue
+            
+            
             randomVector = (mathutils.Vector((random.random()-0.5,
                                               random.random()-0.5,
                                               random.random()-0.5)) +
@@ -180,15 +175,18 @@
             growVector = (randomVector * props.ivyRandomWeight +
                           primaryVector * props.ivyPrimaryWeight)
 
-            # modify with GRAVITY VECTOR
-
+            # GRAVITY VECTOR
+            gravityVector = mathutils.Vector((0,0,-1)) * props.ivyGravityWeight
+            gravityVector *= math.pow(prevIvy.floatingLength / self.maxFloatingLength, 0.7)
+            
             # compute COLLISION
 
+
             # create new IvyNode
             tmpIvy = IvyNode()
 
             # set position
-            tmpIvy.position = prevIvy.position + growVector
+            tmpIvy.position = prevIvy.position + growVector + gravityVector
             #print('tmpIvy.position', tmpIvy.position)
 
             # set new PRIMARY VECTOR
@@ -197,6 +195,11 @@
 
             # length to this IvyNode from start of root
             tmpIvy.length = prevIvy.length + mathutils.Vector((tmpIvy.position - prevIvy.position)).length
+
+            # floating length
+            if prevIvy.climbing == False:
+                tmpIvy.floatingLength = (prevIvy.floatingLength +
+                                        (tmpIvy.position - prevIvy.position).length)
             
             # put IvyNode into ROOT
             root.ivyNodes.append(tmpIvy)
@@ -245,7 +248,7 @@
     for i in range(props.ivyIter): #for now usercontrollable growiterations
         IVY.grow(props)
 
-    print('IvyNodes:', len(IVY.ivyRoots[0].ivyNodes))
+    print('IvyNodes[root[0]:', len(IVY.ivyRoots[0].ivyNodes))
     print('IvyRoots:', len(IVY.ivyRoots))
     #createIvy(context, IVY) # create emptis at IvyRoots
     createIvyCurves(context, IVY) #create Curverepresentation of the Ivy
@@ -265,10 +268,10 @@
     ivyIter = IntProperty(name='Iterations',
                             min=0, soft_min=0,
                             default=9)
-    ivyGravityWeigth = FloatProperty(name='Gravity Weight',
+    ivyGravityWeight = FloatProperty(name='Gravity Weight',
                             min=0,soft_min=0,
                             max=1,soft_max=1,
-                            default=0.5)
+                            default=0.2)
     ivyPrimaryWeight = FloatProperty(name='Primary Weight',
                             min=0,soft_min=0,
                             max=1,soft_max=1,




More information about the Bf-extensions-cvs mailing list