Vine Code
Scatter points on a user defined mesh
initialize a root point with a random direction vector
types of points (point groups)
root points: will search for “nodes” to turn into roots, they will “die” the next frame (points that are “dead” can not grow and can not be grown to)
node points: valid points to grow to
stem points: a collection of all root points that have died
the root node look for a specified number of points in a specified radius
(the close points are put into an array)
loop through the close points
draw a vector between the root and all close points
compare the created vector to the direction vector on the current root
find the close point that has the vector that most closely matches the direction of the direction vector, that point will be the new root node
kill the current root and place it in the stem group node and apply the drawn vector to the new root as its direction vector
create a poly line and assign it 2 vertices the first is the old root the second is the new root
We now have a new root node with a new direction vector and this process is repeated every frame
Leaf Code
In the Vine Vex create a new “leaf root” at each frame positioned at the normal, if a probability is true (place new leaf root into leaf group)
Create an array of every point in the leaf group and loop through it
Get position and normal of leaf root
Subtract a gravity vector from the normal at each frame
Create a new point at the edited normal + position
Set a “leaf id” attribute to keep track of how many points have been generated per stem
Also transfer edited normal on to the created point to get an iterativly add the gravity vector
Add primitive just like vine
Set primitive to new group for skinning
Check the “leaf id “ at start of for-each and if it is larger then a user defined range of numbers than stop the current loop there and continue to the next loop