예제 #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 setup_lighting(self):
     if self.flag_use_lights:
         gl.glEnable(gl.GL_LIGHTING)
         gl.glEnable(gl.GL_LIGHT0)
         gl.glEnable(gl.GL_BLEND)
         # gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
         gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ZERO)
         gl.glLightModeli(gl.GL_LIGHT_MODEL_TWO_SIDE, gl.GL_TRUE)
         gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, [0.0, 0.0, 0.0, 1.0])
         gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, [1, 1, 1, 1])
         gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, [0.5, 0.5, 0.5, 1.0])