示例#1
0
 def draw_spheres(self, solid=False):
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gray = 0.3
     gl.glColor3f(gray, gray, gray)
     if solid:
         gl.glEnable(gl.GL_LIGHTING)
         gl.glEnable(gl.GL_LIGHT0)
         gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, [1, 1, 1, 1])
         gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, [0, 0, 1, 0])
         gl.glEnable(gl.GL_BLEND)
         gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
         gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, [1, 1, 1, 0.5])
         sphere = gltbx.util.SolidSphere
         grid = 50
     else:
         sphere = gltbx.util.WireSphere
         grid = 20
     for i, (x, r) in enumerate(self.spheres):
         gl.glPushMatrix()
         gl.glTranslated(*(x))
         sphere(radius=r, slices=grid, stacks=grid)
         gl.glPopMatrix()
     if solid:
         gl.glDisable(gl.GL_LIGHTING)
         gl.glDisable(gl.GL_LIGHT0)
         gl.glDisable(gl.GL_BLEND)
示例#2
0
 def execute(self, specular=True):
   from gltbx.gl import glMaterialfv, glMaterialf
   glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, self.ambient_back_colour)
   glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, self.ambient_front_colour)
   glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, self.diffuse_back_colour)
   glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, self.diffuse_front_colour)
   if specular:
     glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, self.specular_back_colour)
     glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, self.specular_front_colour)
     glMaterialf(gl.GL_FRONT_AND_BACK, gl.GL_SHININESS, self.specular_focus)