Hello there,
I just want to share with you a simple that draws a ternary tree.
The algorithm is very simple and uses recursion. Here is what it does in pseudocode (for n-ary tree):
main{
…
max_levels = 10
tree(initLenght, 1);
…
}
tree(length, level){
…
if(level
n = 3 //it is a ternary tree
for(x=0; x
pushMatrix()
rotate ((360 / n)*x) along y axis
rotate (aperture) along z axis
drawLine(0,0,0, 0,length,0) //from 0,0,0 to 0,length,0
translate(0,length,0)
tree(lenght/2, level+1) //recursive call
popMatrix()
}
}
}
As you can see, I used glRotate/glTranslate and glBegin(GL_LINES)/glEnd() calls, in old OpenGL style. Maybe this is the reason why with more than 8/9 levels I don’t obtain good performance. Using vbo will result in better performance, but I’m still not sure about how to do that.
It is a very simple plugin, but if used in audio-reaction compositions I think it can produce interesting results. So let me know if someone use it in some cool way! 🙂
- Download (plugin and example composition)

