fractal and kochfractal separated.
1 parent 1b98134 commit 871649c1202ee97e48c32c7f178ef7507d7700c3
@glproj03 glproj03 authored on 3 Feb 2006
Showing 2 changed files
View
12
include/glumodel.h
void init(Vec _pos, Material _mat, float _rad);
void draw();
};
 
class KochFractal : public GenericModel {
class Fractal : public GenericModel {
public:
float iters;
float len;
float multiplicity;
float mult_angle;
Fractal();
void init(float _iters, float _len);
};
 
class KochFractal : public Fractal {
public:
KochFractal();
//TODO: move draw function to Fractal class, it's common for all
//inheriting fractals....
void draw();
void iter(float nbit);
};
 
View
28
sources/glumodel.cpp
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);