teeth_length = 5;
thickness = 5;
bevel = 1.5;
+ init_angle = 0;
mesh = 0;
}
delete mesh;
}
+void Gear::set_teeth(int nt, float tooth_pitch)
+{
+ float circ = tooth_pitch * nt;
+ radius = circ / (2.0 * M_PI);
+ nteeth = nt;
+ init_angle = get_angular_pitch() * 3.0 / 8.0;
+}
+
+float Gear::get_rotation() const
+{
+ return fmod(init_angle + angle, M_PI * 2.0);
+}
+
+float Gear::get_angular_pitch() const
+{
+ return 2.0 * M_PI / (float)nteeth;
+}
+
void Gear::draw() const
{
if(!mesh) {
mesh->draw();
- /*
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
- glColor3f(0, 1, 0);
- mesh->draw_normals();
+
+ glLineWidth(2.0);
+ glBegin(GL_LINES);
+ glColor3f(0, 0, 1);
+ glVertex3f(0, 0, -10);
+ glVertex3f(0, 0, 10);
+ glEnd();
+ glLineWidth(1.0);
glPopAttrib();
- */
glPopMatrix();
}
up = cross(axis, right);
xform = Mat4(right, up, axis);
+ xform.rotate_z(get_rotation());
xform.translate(pos);
}