[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [807] branches/ivygen: - many chnages after testing
Florian Meyer
florianfelix at web.de
Sat Jul 17 05:32:09 CEST 2010
Revision: 807
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=807
Author: testscreenings
Date: 2010-07-17 05:32:05 +0200 (Sat, 17 Jul 2010)
Log Message:
-----------
- many chnages after testing
- very serious bug with ray_cast()
- why doesn't it work, it should
Modified Paths:
--------------
branches/ivygen/ivy_functions.py
branches/ivygen/ivy_test.py
Modified: branches/ivygen/ivy_functions.py
===================================================================
--- branches/ivygen/ivy_functions.py 2010-07-17 01:41:04 UTC (rev 806)
+++ branches/ivygen/ivy_functions.py 2010-07-17 03:32:05 UTC (rev 807)
@@ -3,7 +3,7 @@
-def computeCollision(obj, old_pos, new_pos, climbing):
+def computeCollision(obj, old_pos, new_pos, tmpRoot):
'''basic steps:
thought: maybe implement and octree for the faces
to efficently discard the one too far away?
@@ -56,38 +56,26 @@
'''
#reset climbing state
- climbing = false # why this, not clear yet
-
+ climbing = False
intersection = False
- #test for intersections with all faces of the mesh
- intersect_faces = []
- for fa in obj.data.faces:
- ray_result = obj.ray_cast(old_pos, new_pos)
- if ray_result[2] == -1:
- continue
- else:
- intersect_faces.append(ray_result)
+ print(obj)
+ #print(obj.data.faces.values())
+
+ ray_result = obj.ray_cast(old_pos, new_pos) #when changing props this can't find the meshdata?
- # set climbing_bool if we have intersections
- if intersect_faces:
+ # need a test if old_pos starts on the outside of the mesh?
+
+ print('ray_result', ray_result)
+
+ if ray_result[2] != -1: #if raycasting doesn't yield an intersection
+ climbing = False
+ intersection = True
+ else:
climbing = True
-
- # now we have to determine which face was intersected first
- shortest_dist = None
- faceOfInterest = None
- if intersect_faces: #if there are intersections at all
- for fa in intersect_faces: #go through the intersecting faces
- dist = (fa[0] - old_pos).length #distance from old_pos to interection on face
+ print('intersection',intersection)
- # save the face with the closest intersection point
- if not shortest_dist:
- shortest_dist = dist
- else:
- if dist < shortest_dist:
- shortest_dist = dist
- faceOfInterest = fa
-
+
#now modifiy new_pos
#project newPos to triangle plane --> don't know yet what he did here
# Vector3d p0 = newPos - t->norm * Vector3d::dotProduct(t->norm, newPos - t->v0->pos)
@@ -97,7 +85,7 @@
-def computeAdhesion(old_pos?): #tmp, needs to be filled :)
+def computeAdhesion(obj, old_pos): #tmp, needs to be filled :)
'''
ok, first: what does he exactly wnat to do here?
the function returns the adhesionVector. so my best guess would be that
Modified: branches/ivygen/ivy_test.py
===================================================================
--- branches/ivygen/ivy_test.py 2010-07-17 01:41:04 UTC (rev 806)
+++ branches/ivygen/ivy_test.py 2010-07-17 03:32:05 UTC (rev 807)
@@ -39,12 +39,12 @@
class IvyNode(): #IvyNode Baseclass
position = mathutils.Vector()
- primaryVector = mathutils.Vector((0,0,0.25))
+ primaryVector = mathutils.Vector((0,0,0.1))
adhesionVector = mathutils.Vector()
smoothAdhesionVector = mathutils.Vector()
length = 0.0
floatingLength = 0.0
- climb = True
+ climbing = True
class IvyRoot(IvyNode): #not sure about this. why subclassing. can put everything into IvyNode
@@ -56,6 +56,11 @@
class Ivy():
+ obj = None
+
+ def __init__(self, obj):
+ self.obj = obj
+
#the ivyRoots
ivy_Roots = []
@@ -75,23 +80,27 @@
#generate random Vector with slight upvector
randomVector = (mathutils.Vector((random.random()-0.5, random.random()-0.5, random.random()-0.5)) +
- mathutils.Vector((0,0,0.2)))
+ mathutils.Vector((0,0,0.1)))
#primaryVector
primaryVector = self.ivy_Roots[-1].primaryVector
#AdhesionVector
- adhesionVector = computeAdhesion()
+ adhesionVector = computeAdhesion(self.obj, self.ivy_Roots[-1].position)
#compute the growVector
'''growVec = localIvySize * (primaryVector * primaryWeight *
randomVector * randomWeight *
adhesionVector * adhesionWeight)'''
-
+
#set position of new RootNode --> replace with growVector
tmpRoot.position = (self.ivy_Roots[-1].position + #just using the randomVector for now
- randomVector * props.ivyRandomWeight) #
+ randomVector * props.ivyRandomWeight +
+ primaryVector * props.ivyPrimaryWeight) #
+ #do the collisiondetection
+ computeCollision(obj=self.obj, old_pos=self.ivy_Roots[-1].position, new_pos=tmpRoot.position, tmpRoot=tmpRoot)
+
# add to the chainNumber
if tmpRoot.chainNumber == 0 or tmpRoot.chainNumber == self.ivy_Roots[-1].chainNumber:
tmpRoot.chainNumber = self.ivy_Roots[-1].chainNumber + 1
@@ -99,18 +108,12 @@
#compute this Roots primaryVector
- tmpRoot.primaryVector = (self.ivy_Roots[-1].primaryVector + (tmpRoot.position - self.ivy_Roots[-1].position)).normalize()
+ tmpRoot.primaryVector = ((self.ivy_Roots[-1].primaryVector +
+ (tmpRoot.position - self.ivy_Roots[-1].position)).normalize())
self.ivy_Roots.append(tmpRoot) #put into list of IvyNodes
- #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
@@ -119,13 +122,14 @@
-def main(context, props):
+def main(context, props, data):
seedPoint = context.scene.cursor_location #start the Ivy at the cursor
gravity = mathutils.Vector((0,0,-1)) #not used yet
upVector = mathutils.Vector((0,0,1)) #not used yet
random.seed(props.ivySeed) #controlling the random seed
- IVY = Ivy() #create main IvyObject stores all the IvyNodes
+ obj = context.active_object
+ IVY = Ivy(obj) #create main IvyObject stores all the IvyNodes
IVY.ivy_Roots = [] #empty the roots list
IVY.seed() #set inital IvyNode
@@ -170,13 +174,17 @@
def execute(self, context):
print('\n____________START_____________')
props = self.properties
+ data = []
print(props)
# compute boundingSphere and put into props if abs mesh is selected
- if context.active_object and context.active_object.type == 'MESH':
+ if (context.active_object
+ and context.active_object.select
+ and context.active_object.type == 'MESH'):
targetBoundingSphere = computeBoundingSphere(bpy.context.selected_editable_objects)
+ data.append(targetBoundingSphere)
- main(context, props)
+ main(context, props, data)
return {'FINISHED'}
More information about the Bf-extensions-cvs
mailing list