Changeset View
Changeset View
Standalone View
Standalone View
add_curve_ivygen.py
| Context not available. | |||||
| from bpy.props import FloatProperty, IntProperty, BoolProperty | from bpy.props import FloatProperty, IntProperty, BoolProperty | ||||
| from mathutils import Vector, Matrix | from mathutils import Vector, Matrix | ||||
| from collections import deque | from collections import deque | ||||
| from math import pow, cos, pi, atan2 | from math import cos, pi, atan2 | ||||
| from random import random as rand_val, seed as rand_seed | from random import random as rand_val, seed as rand_seed | ||||
| import time | import time | ||||
| Context not available. | |||||
| nodeNext = root.ivyNodes[i + 1] | nodeNext = root.ivyNodes[i + 1] | ||||
| # Find the weight and normalize the smooth adhesion vector | # Find the weight and normalize the smooth adhesion vector | ||||
| weight = pow(node.length * prevIvyLength, 0.7) | weight = (node.length * prevIvyLength) ** 0.7 | ||||
| # Calculate the ground ivy and the new weight | # Calculate the ground ivy and the new weight | ||||
| groundIvy = max(0.0, -node.smoothAdhesionVector.z) | groundIvy = max(0.0, -node.smoothAdhesionVector.z) | ||||
| weight += groundIvy * pow(1 - node.length * | weight += groundIvy * (1 - node.length * prevIvyLength) ** 2 | ||||
| prevIvyLength, 2) | |||||
| # Find the alignment weight | # Find the alignment weight | ||||
| alignmentWeight = node.adhesionLength | alignmentWeight = node.adhesionLength | ||||
| Context not available. | |||||
| # Find the gravity vector | # Find the gravity vector | ||||
| gravityVector = (self.ivySize * self.gravityWeight * | gravityVector = (self.ivySize * self.gravityWeight * | ||||
| Vector((0, 0, -1))) | Vector((0, 0, -1))) | ||||
| gravityVector *= pow(prevIvy.floatingLength / self.maxFloatLength, | gravityVector *= (prevIvy.floatingLength / self.maxFloatLength) ** 0.7 | ||||
| 0.7) | |||||
| # Determine the new position vector | # Determine the new position vector | ||||
| newPos = prevIvy.pos + growVector + gravityVector | newPos = prevIvy.pos + growVector + gravityVector | ||||
| Context not available. | |||||