Example #1
0
 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)
Example #2
0
 def draw_link(self, link):
     pos = link.child.localPos3
     r = utils.norm(pos)
     if r < 1e-8:
         return
     n = np.cross((0, 0, 1), pos / r)
     a = np.arccos(np.dot((0, 0, 1), pos / r))
     with utils.glPreserveMatrix():
         if utils.norm(n) > 1e-8:
             glRotated(a * 180 / np.pi, *n/utils.norm(n))
         quad = gluNewQuadric()
         G.glMaterialfv(GL_FRONT, GL_DIFFUSE, self.LINK_COLOR)
         gluCylinder(quad, self.LINK_RADIUS, self.LINK_RADIUS, r, 16, 1)
         gluDeleteQuadric(quad)
Example #3
0
 def draw(self):
     # glViewport(0, 0, self.size[0], self.size[1])
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     width, height = self.size
     far = 1000
     for win in self.subWindows:
         win.adjust_view()
         glLoadIdentity()
         with utils.glPreserveMatrix():
             win.set_camera()
             self.set_light()
             # draw sprites for this window
             for sp in self.sprites:
                 sp.draw()
     self.draw_borders()
 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)