def draw_joint(self, joint):
     with utils.glPreserveMatrix():
         mat = joint.localMat
         glMultMatrixf(utils.npmat_to_glmat(mat))
         self.cylinder.draw()
         # draw links
         for link in joint.links:
             self.draw_link(link)
             self.draw_joint(link.child)
 def draw(self):
     glColor3f(0., 0., 0.)
     height = 0.002
     glDisable(GL_LIGHTING)
     with utils.glPreserveMatrix():
         glMultMatrixf(utils.npmat_to_glmat(self.localMat))
         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
         with utils.glPrimitive(GL_POLYGON):
             glVertex3f(0, -self.top / 2, 0)
             glVertex3f(0, self.top / 2, 0)
             glVertex3f(self.length, self.bottom / 2, 0)
             glVertex3f(self.length, -self.bottom / 2, 0)
         with utils.glPrimitive(GL_LINES):
             y1 = self.top / 2
             y2 = self.bottom / 2
             l = self.length
             # draw bars
             for x in self.bars[1:]:
                 h = y1 + (y2 - y1) / l * x
                 glVertex3f(x, -h, 0)
                 glVertex3f(x, h, 0)
             # draw strings
             for i in range(1, 7):
                 y1, y2 = self.get_string_ys(i)
                 glVertex3f(0, y1, height)
                 glVertex3f(l, y2, height)
             # draw marks
             d = self.top / 12
             glColor3f(1., .2, .2)
             for fp in self.marks:
                 x, y = self.pos_fret_to_plane(fp)
                 glVertex3f(x - d, y + d, 0)
                 glVertex3f(x + d, y - d, 0)
                 glVertex3f(x + d, y + d, 0)
                 glVertex3f(x - d, y - d, 0)
         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
     glEnable(GL_LIGHTING)