[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [792] branches: == creating the branches folder ==

Luca Bonavita mindrones at gmail.com
Fri Jul 16 00:09:45 CEST 2010


Revision: 792
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=792
Author:   mindrones
Date:     2010-07-16 00:09:45 +0200 (Fri, 16 Jul 2010)

Log Message:
-----------
== creating the branches folder ==

This folder is for experimental works and not connected in any way to blender's trunk
Is being added to let extensions developers work well without the hassle of zipping files and such things

Adding the first version of a port of ivygenerator to blender 2.5
See http://graphics.uni-konstanz.de/~luft/ivy_generator/
Testscreenings will add more details later :)

Added Paths:
-----------
    branches/
    branches/ivygen/
    branches/ivygen/ivy_algo.py
    branches/ivygen/ivy_class.py
    branches/ivygen/ivy_test.py

Added: branches/ivygen/ivy_algo.py
===================================================================
--- branches/ivygen/ivy_algo.py	                        (rev 0)
+++ branches/ivygen/ivy_algo.py	2010-07-15 22:09:45 UTC (rev 792)
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'''what does the grow loop do?
+loop over all the roots (what are they? IvyNode instances?)
+
+    check if root is alive else goto next root
+    check if the ivy should die (against maxLength) set root.alive
+    
+    get thre Vecors toaiff determine the direction of growing
+        primaryVector,
+        randomVector (with abs slight upVector addition),
+        adhesionVector
+        
+    compute the growvector
+        growVec = localIvySize * (primaryVector * primaryWeight *
+                                    randomVector * randomWeight *
+                                    adhesionVector * adhesionWeight)
+    
+    compute gravityVector
+        gravVec = localIvySize * gravityVector((0,0,-1)) * gravityWeight
+        
+    change influence of gravity depending on floating length
+        gravVec *= pow(root.floatinglength / local_maxFloatlength, 0,7)
+        
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+
+    
+    
+    
+    
+    next possible ivyNode:
+    
+    
+    
+    
+    getattr position of the next IvyNode:
+        nextPosition = root.position + growVec - gravVec
+        
+    test if ivy dies assert per collisiondetection
+        set alive state
+        
+    update the growVecor for the newdir position (of whatsound exactly?)
+        growVec = new_pos - root.pos - gravVec
+        
+        
+        
+    Create the next ivyNode
+    tmpNode = ivyRoot()
+    
+    set the new Values for the tmpNode
+        tmpNode.position = new_pos
+        
+        tmpNode.primaryDir = normalizedVector (
+                                0.5 * rootNode.back.floatingLength +
+                                (new_pos - root.back.pos).length)
+        
+        tmpNode.climb = climbing
+        
+    >>> root->nodes.push_back( tmpNode ); <<< put the tmpNode into list?
+    
+    
+    
+    
+    newdir loop toaiff test if toaiff produce childIvys
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+'''
\ No newline at end of file

Added: branches/ivygen/ivy_class.py
===================================================================
--- branches/ivygen/ivy_class.py	                        (rev 0)
+++ branches/ivygen/ivy_class.py	2010-07-15 22:09:45 UTC (rev 792)
@@ -0,0 +1,175 @@
+import bpy
+import mathutils
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+class IvyNode():
+    '''Ivy Node baseclass'''
+    
+    #location of Node
+    position = mathutils.Vector(())
+    
+    #primary grow direction, a weighted sum of the previous directions
+    primaryDir = mathutils.Vector(())
+    
+    #adhesion vector as a result from other scene objects
+    adhesionVector = mathutils.Vector(())
+    
+    '''a smoothed adhesion vector computed and used during the birth phase,
+	   since the ivy leaves are align by the adhesion vector, this smoothed vector
+	   allows for smooth transitions of leaf alignment'''
+    smoothAdhesionVector = mathutils.Vector(())
+    
+    #length of the associated ivy branch at this node
+    length = 0.0
+    
+    #length at the last node that was climbing
+    floatingLength = 0.0
+    
+    #climbing state
+    climb = True
+
+
+
+
+
+
+
+
+class IvyRoot(IvyNode):
+    
+    #a number of nodes
+    # how to convert this?:  std::vector<IvyNode> nodes;
+    nodes = [list of IvyNodes?]
+    
+    #alive state
+    alive = True
+    
+    #number of parents, represents the level in the root hierarchy
+    parents = 0
+    
+
+
+
+
+class Ivy():
+    #BasicMesh seems to be the the environment Mesh
+    #on which the Ivy climbs
+
+    #vars
+    #the ivy size factor, influences the grow behaviour [0..0,1]
+    ivySize = 0.0
+    #leaf size factor [0..0,1]
+    ivyLeafSize = 0.0
+    #branch size factor [0..0,1]
+    ivyBranchSize = 0.0
+    #maximum length of an ivy branch segment that is freely floating [0..1]
+    ivyMaxFloatLength = 1.0
+    #maximum distance for adhesion of scene object [0..1]
+    ivyMaxAdhesionDistance = 1.0
+    #weight for the primary grow vector [0..1]
+    ivyPrimaryWeight = 0.5
+    #weight for the random influence vector
+    ivyRandomWeight = 0.5
+    #weight for the gravity vector [0..1]
+    ivyGravityWeight = 0.5
+    #weight for the adhesion vector [0..1]
+    ivyAdhesionWeight = 0.5
+    #the probability of producing a new ivy root per iteration [0..1]
+    ivyBranchingProbability = 0.25
+    #the probability of creating a new ivy leaf [0..1]
+    ivyLeafProbability = 0.5
+    
+    def __init__():
+        #probably abs good idea to have this?
+        pass
+    
+    def resetSettings(self):
+        #probably resets the settings :)
+        pass
+
+    #initialize a new ivy root
+    def seed(self, seedPos):
+        pass
+        
+    #one single grow iteration
+    def grow()
+        pass
+
+    #compute the adhesion of scene objects at a point pos
+    def computeAdhesion(self, position)
+        pass
+        
+    #computes the collision detection for an ivy segment oldPos->newPos
+    #newPos will be modified if necessary
+    def computeCollision(self, old_pos, new_pos, climbingState)
+        pass
+        
+    #creates the ivy triangle mesh
+    def birth()
+    
+    #the ivy roots
+    #again, what is this?:  std::vector<IvyRoot> roots
+    
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+class 
\ No newline at end of file

Added: branches/ivygen/ivy_test.py
===================================================================
--- branches/ivygen/ivy_test.py	                        (rev 0)
+++ branches/ivygen/ivy_test.py	2010-07-15 22:09:45 UTC (rev 792)
@@ -0,0 +1,168 @@
+import bpy
+from bpy.props import *
+import mathutils
+import random
+
+def createIvy(context, IVY):
+    for root in IVY.ivy_Roots:
+        bpy.ops.object.add(type='EMPTY',
+                            location=root.position)
+        context.active_object.empty_draw_type = 'PLAIN_AXES'
+
+        print(root.position)
+
+class IvyNode():
+    position = mathutils.Vector()
+    primaryDir = mathutils.Vector((0,0,0,5))
+    adhesionVector = mathutils.Vector()
+    smoothAdhesionVector = mathutils.Vector()
+    length = 0.0
+    floatingLength = 0.0
+    climb = True
+
+
+class IvyRoot(IvyNode):
+    nodes = []
+    alive = True
+    parents = 0
+
+
+class Ivy():
+    #the ivy size factor, influences the grow behaviour [0..0,1]
+    ivy_Size = 0.0
+    #leaf size factor [0..0,1]
+    ivy_LeafSize = 0.0
+    #branch size factor [0..0,1]
+    ivyBranchSize = 0.0
+    #ma_ximum length of an ivy branch segment that is freely floating [0..1]
+    ivy_MaxFloatLength = 1.0
+    #maximum distance for adhesion of scene object [0..1]
+    ivy_MaxAdhesionDistance = 1.0
+    #weight for the primary grow vector [0..1]
+    ivy_PrimaryWeight = 0.5
+    #weight for the random influence vector
+    ivy_RandomWeight = 0.5
+    #weight for the gravity vector [0..1]
+    ivy_GravityWeight = 0.5
+    #weight for the adhesion vector [0..1]
+    ivy_AdhesionWeight = 0.5
+    #the probability of producing a new ivy root per iteration [0..1]
+    ivy_BranchingProbability = 0.25
+    #the probability of creating a new ivy leaf [0..1]
+    ivy_LeafProbability = 0.5
+    #the ivyRoots
+    ivy_Roots = []
+    '''
+    def __init__():
+        #probably a good idea to have this?
+        pass
+    '''
+    def resetSettings(self):
+        #probably resets the settings :)
+        pass
+    #initialize a new ivy root
+    def seed(self):
+        tmpSeed = IvyRoot()
+        tmpSeed.position = bpy.context.scene.cursor_location
+        self.ivy_Roots.append(tmpSeed)
+        
+    #one single grow iteration
+    def grow(self, props):
+        tmpRoot = IvyRoot()
+        randVector = (mathutils.Vector((random.random()-0.5, random.random()-0.5, random.random()-0.5)) +
+                     mathutils.Vector((0,0,0.5)))
+        tmpRoot.position = (self.ivy_Roots[-1].position +
+                            randVector * props.ivyRandomWeight)
+        self.ivy_Roots.append(tmpRoot)
+
+    #compute the adhesion of scene objects at a point pos
+    def computeAdhesion(self, position):
+        pass
+    #computes the collision detection for an ivy segment oldPos->newPos
+    #newPos will be modified if necessary
+    def computeCollision(self, old_pos, new_pos, climbingState):
+        pass
+    #creates the ivy triangle mesh
+    def birth():
+        pass
+    #the ivy roots
+    #again, what is this?:  std::vector<IvyRoot> roots
+
+
+
+def main(context, props):
+    seedPoint = context.scene.cursor_location
+    gravity = mathutils.Vector((0,0,-1))
+    upVector = mathutils.Vector((0,0,1))
+    random.seed(props.ivySeed)
+
+    IVY = Ivy()
+    IVY.ivy_Roots = [] #empty the roots list
+
+    IVY.seed()
+
+    for i in range(5):
+        IVY.grow(props)
+
+
+    createIvy(context, IVY)
+    print(len(IVY.ivy_Roots))
+
+    print(len(IVY.ivy_Roots))
+
+
+    return
+
+class ivy_test(bpy.types.Operator):
+    ''''''
+    bl_idname = "ivy_test"
+    bl_label = "IVY_test"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    ivySeed = IntProperty(name='Seed',
+                            min=0, soft_min=0,
+                            default=0)
+    ivyGravityWeigth = FloatProperty(name='Gravity Weight',
+                            min=0,soft_min=0,
+                            max=1,soft_max=1,
+                            default=0.5)
+    ivyPrimaryWeight = FloatProperty(name='Primary Weight',
+                            min=0,soft_min=0,
+                            max=1,soft_max=1,
+                            default=0.5)
+    ivyRandomWeight = FloatProperty(name='Random Weight',
+                            min=0,soft_min=0,
+                            max=1,soft_max=1,
+                            default=0.5)
+
+    def poll(self, context):
+        return context.scene != None
+
+    def execute(self, context):
+        print('\n____________START_____________')
+        props = self.properties
+
+
+        main(context, props)
+        return {'FINISHED'}
+
+
+
+
+#############################################
+ivy_test_button = (lambda self, context: self.layout.operator

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list