def cylinder(self, position1, position2, radius=1.0, material=None, name=None): if material is not None: color = self.materials[material] glColor3f(color[0], color[1], color[2]) z = Vector(0.0, 0.0, 1.0) d = position2 - position1 if d.length() < 1e-10: return d = d.normal() axis = z.cross(d) glPushMatrix() glTranslatef(position1[0], position1[1], position1[2]) if axis.length() > 0.0000001: axis = axis.normal() glRotatef(acos(z * d) * 180 / pi, axis[0], axis[1], axis[2]) else: if d[2] < 0: glRotatef(180, 1, 0, 0) gluCylinder(self.quadratic, radius, radius, (position2 - position1).length(), self.n, 2) glPopMatrix()
def orthographicCamera(self, position, look_at, right, up, name=None): glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-right.length(), right.length(), -up.length(), up.length(), -100, 100) z = Vector(0.0, 0.0, 1.0) d = (look_at - position).normal() axis = z.cross(d) if axis.length() > 0.0000001: axis = axis.normal() glRotatef(z * d, axis[0], axis[1], axis[2]) glTranslatef(-position[0], -position[1], -position[2]) glMatrixMode(GL_MODELVIEW)