| |
---|
| | glPopMatrix(); |
---|
| | |
---|
| | } |
---|
| | |
---|
| | Fractal::Fractal() { |
---|
| | init(4, 30); |
---|
| | } |
---|
| | |
---|
| | void Fractal::init(float _iters, float _len) { |
---|
| | iters = _iters; |
---|
| | len = _len / (iters*iters*iters); |
---|
| | |
---|
| | //arbitrary values, to be reset |
---|
| | //used to draw several instances of same fractal |
---|
| | multiplicity = 1; |
---|
| | mult_angle = 90; |
---|
| | } |
---|
| | |
---|
| | KochFractal::KochFractal() { |
---|
| | iters = 4; |
---|
| | len = 30 / (iters*iters*iters); |
---|
| | Fractal::init(3, 30); |
---|
| | multiplicity = 6; |
---|
| | mult_angle = 60; |
---|
| | } |
---|
| | |
---|
| | void KochFractal::draw() { |
---|
| | //TODO: move draw function to Fractal class, it's common for all |
---|
| | //inheriting fractals.... |
---|
| | glPushMatrix(); |
---|
| | for (int i = 0; i < 6; i++) { |
---|
| | for (int i = 0; i < multiplicity; i++) { |
---|
| | iter(iters); |
---|
| | glRotatef(60, 1,0,0); |
---|
| | glRotatef(mult_angle, 1,0,0); |
---|
| | } |
---|
| | glPopMatrix(); |
---|
| | } |
---|
| | |
---|
| |
---|
| | glRotatef(-120,1,0,0); |
---|
| | iter(n); |
---|
| | glRotatef(60,1,0,0); |
---|
| | iter(n); |
---|
| | //glRotatef(30,1,0,0); |
---|
| | |
---|
| | } else { |
---|
| | glBegin(GL_LINES); |
---|
| | glVertex3f(0,0,0); |
---|
| | glVertex3f(0,len,0); |
---|
| |
---|
| | |
|