Exemple #1
0
    def __init__(self, molecule, hide_hydrogens=False, randomize_single_bonds=False,
                       bond_width=.1, bond_length=2):
        self.molecule = molecule
        self.hide_hydrogens = hide_hydrogens
        self.randomize_single_bonds = randomize_single_bonds
        self.rotate_atoms(self.molecule)

        self.bond_width = bond_width
        self.bond_length = bond_length

        self.quad = glu.gluNewQuadric()
        glu.gluQuadricNormals(self.quad, glu.GLU_SMOOTH)
        glu.gluQuadricDrawStyle(self.quad, glu.GLU_FILL)

        self.cylinder_resolution = 100
        self.sphere_resolution = 100

        self.zoom = 5
        self.rotations = []

        self.scroll_up_button = 3
        self.scroll_down_button = 4
        self.scroll_buttons = [self.scroll_up_button,
                               self.scroll_down_button]
        self.zoom_increment = 0.2

        self.default_element_color = (221/255, 119/255, 1)
        self.bond_color = (128/255,) * 3

        self.drag_start = None
Exemple #2
0
def gl_init( width, height ):
    global __legocaptex,__quadratic
    
    setviewport(width, height)
    
    __legocaptex = layer_manager.load_2d_texture(pygame.image.tostring(__image, "RGBA"), LEGO_CAP_WIDTH, LEGO_CAP_HEIGHT)
    __quadratic = GLU.gluNewQuadric()
    
    GLU.gluQuadricTexture(__quadratic, GLU.GLU_TRUE)
    GLU.gluQuadricDrawStyle(__quadratic,GLU.GLU_FILL)    
    GLU.gluQuadricOrientation(__quadratic, GLU.GLU_OUTSIDE)
    GLU.gluQuadricNormals(__quadratic, GLU.GLU_SMOOTH)
    
    GL.glClearColor( 0.0, 0.2, 0.5, 1.0 )
    
    GL.glEnable(GL.GL_POINT_SMOOTH)
    GL.glEnable(GL.GL_LINE_SMOOTH)
    GL.glEnable(GL.GL_TEXTURE_2D)
    GL.glEnable(GL.GL_ALPHA_TEST)
    GL.glEnable(GL.GL_COLOR_MATERIAL)
    GL.glDisable(GL.GL_CULL_FACE)
    GL.glAlphaFunc(GL.GL_GREATER,0.1)
    
    GL.glClearAccum(0.0, 0.0, 0.0, 1.0)
    GL.glClear(GL.GL_ACCUM_BUFFER_BIT)
    
    #GL.glGenLists(1)
    
    draw_mode_3d()
Exemple #3
0
    def __init__(self,
                 molecule,
                 hide_hydrogens=False,
                 randomize_single_bonds=False,
                 bond_width=.1,
                 bond_length=2):
        self.molecule = molecule
        self.hide_hydrogens = hide_hydrogens
        self.randomize_single_bonds = randomize_single_bonds
        self.rotate_atoms(self.molecule)

        self.bond_width = bond_width
        self.bond_length = bond_length

        self.quad = glu.gluNewQuadric()
        glu.gluQuadricNormals(self.quad, glu.GLU_SMOOTH)
        glu.gluQuadricDrawStyle(self.quad, glu.GLU_FILL)

        self.cylinder_resolution = 100
        self.sphere_resolution = 100

        self.zoom = 5
        self.rotations = []

        self.scroll_up_button = 3
        self.scroll_down_button = 4
        self.scroll_buttons = [self.scroll_up_button, self.scroll_down_button]
        self.zoom_increment = 0.2

        self.default_element_color = (221 / 255, 119 / 255, 1)
        self.bond_color = (128 / 255, ) * 3

        self.drag_start = None
 def init_gl(self):
     """
         Initialise OpenGL settings
     """
     self.sphere = GL.glGenLists(1)
     GL.glNewList(self.sphere, GL.GL_COMPILE)
     quad_obj = GLU.gluNewQuadric()
     GLU.gluQuadricDrawStyle(quad_obj, GLU.GLU_FILL)
     GLU.gluQuadricNormals(quad_obj, GLU.GLU_SMOOTH)
     GLU.gluSphere(quad_obj, 1, 16, 16)
     GL.glEndList()
     GL.glShadeModel(GL.GL_SMOOTH)
     GL.glEnable(GL.GL_DEPTH_TEST)
     GL.glEnable(GL.GL_CULL_FACE)
     GL.glEnable(GL.GL_LIGHTING)
     # make sure normal vectors of scaled spheres are normalised
     GL.glEnable(GL.GL_NORMALIZE)
     GL.glEnable(GL.GL_LIGHT0)
     light_pos = list(_LIGHT_POSITION) + [1]
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_pos)
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, [1.0, 1.0, 1.0, 1.0])
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
     GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
     GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, [0.2, .2, .2, 1])
     GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, [0.7, 0.7, 0.7, 1])
     GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, [0.1, 0.1, 0.1, 1])
     GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 20)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GLU.gluPerspective(60, 1, .01, 10)
     GL.glMatrixMode(GL.GL_MODELVIEW)
Exemple #5
0
 def display(self):
     ogl.glPushMatrix()
     ogl.glTranslate(-1, -3.3, 1)
     ang = ((time.time() / 40) % 1) * 360  # 2*3.14
     ogl.glRotate(ang, 0, 0, 1)
     quad = oglu.gluNewQuadric()
     oglu.gluQuadricDrawStyle(quad, oglu.GLU_LINE)
     oglu.gluSphere(quad, 0.7, 15, 15)
     ogl.glPopMatrix()
Exemple #6
0
    def __init__(self, width: int, height: int):
        """
        Arguments:
            width {int} -- Window width in pixels
            height {int} -- Window height in pixels
        """
        self.resize(width, height)

        self.quad = glu.gluNewQuadric()
        glu.gluQuadricDrawStyle(self.quad, gl.GL_LINE)
        glu.gluQuadricTexture(self.quad, gl.GL_TRUE)
Exemple #7
0
def drawSolidSphere(radius=1.0, slices=16, stacks=16, Color=None):
    if (Color != None):
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)  # Orig
        gl.glEnable(gl.GL_BLEND)

        gl.glColor4fv(Color)
    else:
        gl.glColor3f(0.0, 0.0, 0.0)

    glu.gluQuadricDrawStyle(QUADRIC, glu.GLU_FILL)
    glu.gluSphere(QUADRIC, radius, slices, stacks)
Exemple #8
0
 def paintGL(self):
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glColor3f(1.0, 1.0, 1.0)  # Default color is white
     # Draw the flashlight
     self.drawFlashLight()
     # Draw the sphere
     glMaterialfv(GL_FRONT, GL_AMBIENT, [0.3, 0.3, 0.3, 1.0])
     glMaterialfv(GL_FRONT, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
     glMaterialfv(GL_FRONT, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
     glLightfv(self.light, GL_POSITION, self.lightposition)
     glMaterialf(GL_FRONT, GL_SHININESS, 25.0)
     quad = GLU.gluNewQuadric()
     GLU.gluQuadricDrawStyle(quad, GLU.GLU_FILL)
     GLU.gluQuadricNormals(quad, GLU.GLU_SMOOTH)
     GLU.gluSphere(quad, 3.0, 30, 30)
     glFlush()
Exemple #9
0
 def paintGL(self):
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glColor3f(1.0, 1.0, 1.0)  # Default color is white
     # Draw the flashlight
     self.drawFlashLight()
     # Draw the sphere
     glMaterialfv(GL_FRONT, GL_AMBIENT, [0.3, 0.3, 0.3, 1.0])
     glMaterialfv(GL_FRONT, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
     glMaterialfv(GL_FRONT, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
     glLightfv(self.light, GL_POSITION, self.lightposition)
     glMaterialf(GL_FRONT, GL_SHININESS, 25.0)
     quad = GLU.gluNewQuadric()
     GLU.gluQuadricDrawStyle(quad, GLU.GLU_FILL)
     GLU.gluQuadricNormals(quad, GLU.GLU_SMOOTH)
     GLU.gluSphere(quad, 3.0, 30, 30)
     glFlush()
Exemple #10
0
 def visualisation_particle(self):
     #print('visualisation_particle')
     if len(self.list_of_solar_system) == 9:
         for k in range(len(self.list_of_solar_system)):
             sphere = glu.gluNewQuadric() 
             gl.glPushMatrix()                      
             gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, self.list_of_solar_system[k].color) #цвет задаем
             gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, self.list_of_solar_system[k].color)
             gl.glTranslatef(self.list_of_solar_system[k].x*7, self.list_of_solar_system[k].y*7, self.list_of_solar_system[k].z*7)
             glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL) 
             if k == 0:   
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m / 150000.0, 16, 16) 
             if k == 1:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m * 20, 16, 16) 
             if k == 2:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m * 2, 16, 16) 
             if k == 3:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m * 1.5, 16, 16) 
             if k == 4:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m * 7, 16, 16) 
             if k == 5:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m / 30, 16, 16)
             if k == 6:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m / 12, 16, 16)
             if k == 7:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m / 2.3, 16, 16)
             if k == 8:
                 glu.gluSphere(sphere, self.list_of_solar_system[k].m / 3.2, 16, 16)
             
             gl.glTranslatef(-self.list_of_solar_system[k].x*7, -self.list_of_solar_system[k].y*7, -self.list_of_solar_system[k].z*7)
             gl.glPopMatrix() 
             glu.gluDeleteQuadric(sphere)
             self.update()
     else:
         for k in range(len(self.list_of_particles)):
             sphere = glu.gluNewQuadric() 
             gl.glPushMatrix()                      
             gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, self.list_of_particles[k].color) #цвет задаем
             gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, self.list_of_particles[k].color)
             gl.glTranslatef(self.list_of_particles[k].x, self.list_of_particles[k].y, self.list_of_particles[k].z)
             glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)    
             glu.gluSphere(sphere, self.list_of_particles[k].m / 100.0, 16, 16) 
             gl.glTranslatef(-self.list_of_particles[k].x, -self.list_of_particles[k].y, -self.list_of_particles[k].z)
             gl.glPopMatrix() 
             glu.gluDeleteQuadric(sphere)
             self.update()
Exemple #11
0
    def paint_enter(self):
        """
        Implements the GLNodeAdapter's paint_enter method for an OpenGL Render operation.
        """
        GL.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_LINE_BIT | GL.GL_CURRENT_BIT)
        GL.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPushMatrix()
        GL.glMultMatrixf(self._node.matrix().data())
        GL.glColor(self._node.color.getRgbF())

        q = self.__quadric
        r = self._node.radius
        sl = self._node.slices
        st = self._node.stacks
        GLU.gluQuadricNormals(q, GLU.GLU_SMOOTH )
        GLU.gluQuadricDrawStyle(q, GLU.GLU_FILL );
        GLU.gluSphere(q, r, sl, st)
Exemple #12
0
    def paint_enter(self):
        """
        Implements the GLNodeAdapter's paint_enter method for an OpenGL Render operation.
        """
        GL.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_LINE_BIT | GL.GL_CURRENT_BIT)
        GL.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPushMatrix()
        GL.glMultMatrixf(self._node.matrix().data())
        GL.glColor(self._node.color.getRgbF())
        
        # The positive Z-axis is the default direction for Cylinder Quadrics in OpenGL.
        # If our vector is not parallel to the z-axis, e.g. (0, 0, Z), then rotate it.
        #   1) Get a normal from the z-v plane
        #   2) Get the angle inbetween z-v on the plane (see vector dot product)
        #   3) Rotate the normal by that angle.
        v = self._node.axis
        m = Matrix4x4.identity()
        if v.x != 0 or v.y != 0:
            zaxis  = Vector3D(0,0,1)
            angle  = zaxis.angle(v)
            normal = zaxis.crossproduct(v, True)
            m *= Matrix4x4.rotation(angle, normal)

        # The positive Z-axis is the default direction fo Cylinder Quadrics in OpenGL.
        # If our z is negative, we need to flip the cylinder
        if v.z < 0:
            yaxis  = Vector3D(1,0,0)
            m *= Matrix4x4.rotation(math.radians(180), yaxis)       
        GL.glMultMatrixf(m.data())

        q = self.__quadric
        r = self._node.radius
        h = self._node.length
        sl = self._node.slices
        st = self._node.stacks
        lp = self._node.loops
        GLU.gluQuadricDrawStyle (q, GLU.GLU_FILL)
        GLU.gluQuadricNormals (q, GLU.GLU_SMOOTH)
        GLU.gluQuadricOrientation(q, GLU.GLU_OUTSIDE)
        self._glcylinder(q, r, h, sl, st, lp)
Exemple #13
0
 def drawFlashLight(self):
     glPushMatrix()
     glRotate(-self.phi, 1.0, 0.0, 0.0)
     glRotate(-self.theta, 0.0, 1.0, 0.0)
     glTranslate(0, 0, 4)
     glMaterialfv(GL_FRONT, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_DIFFUSE, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_SPECULAR, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 1.0, 0.0, 1.0])
     flashlight = GLU.gluNewQuadric()
     GLU.gluQuadricDrawStyle(flashlight, GLU.GLU_FILL)
     GLU.gluCylinder(flashlight, 0.3, 0.3, 1.5, 30, 30)
     GLU.gluCylinder(flashlight, 0.5, 0.3, 0.4, 30, 30)
     glPushMatrix()
     glTranslate(0, 0, 1.5)
     GLU.gluDisk(flashlight, 0.0, 0.3, 30, 30)
     glPopMatrix()
     glMaterialfv(GL_FRONT, GL_EMISSION, self.diffuse)
     GLU.gluDisk(flashlight, 0.0, 0.5, 30, 30)
     glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0, 1.0])
     glPopMatrix()
Exemple #14
0
 def drawFlashLight(self):
     glPushMatrix()
     glRotate(-self.phi, 1.0, 0.0, 0.0)
     glRotate(-self.theta, 0.0, 1.0, 0.0)
     glTranslate(0, 0, 4)
     glMaterialfv(GL_FRONT, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_DIFFUSE, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_SPECULAR, [0.0, 0.0, 0.0, 1.0])
     glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 1.0, 0.0, 1.0])
     flashlight = GLU.gluNewQuadric()
     GLU.gluQuadricDrawStyle(flashlight, GLU.GLU_FILL)
     GLU.gluCylinder(flashlight, 0.3, 0.3, 1.5, 30, 30)
     GLU.gluCylinder(flashlight, 0.5, 0.3, 0.4, 30, 30)
     glPushMatrix()
     glTranslate(0, 0, 1.5)
     GLU.gluDisk(flashlight, 0.0, 0.3, 30, 30)
     glPopMatrix()
     glMaterialfv(GL_FRONT, GL_EMISSION, self.diffuse)
     GLU.gluDisk(flashlight, 0.0, 0.5, 30, 30)
     glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0, 1.0])
     glPopMatrix()
Exemple #15
0
    def init_gl(self):
        """
            Initialise OpenGL settings
        """
        self.sphere = GL.glGenLists(1)

        # creates model for planet
        GL.glNewList(self.sphere, GL.GL_COMPILE)
        quad_obj = GLU.gluNewQuadric()
        GLU.gluQuadricDrawStyle(quad_obj, GLU.GLU_FILL)
        GLU.gluQuadricNormals(quad_obj, GLU.GLU_SMOOTH)
        GLU.gluSphere(quad_obj, 1, 16, 16)
        GL.glEndList()

        GL.glShadeModel(GL.GL_SMOOTH)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glEnable(GL.GL_CULL_FACE)
        GL.glEnable(GL.GL_LIGHTING)
        # make sure normal vectors of scaled spheres are normalised
        GL.glEnable(GL.GL_NORMALIZE)
        GL.glEnable(GL.GL_LIGHT0)
Exemple #16
0
def drawGLScene():
	
	GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
	for object in sceneObjects.values():

		# apply camera transform for > 3 dimensions
		iterateCamerasD()
		
		# apply 3D camera transform
		iterateCamerasD()
		
		# first we need to project geometry from > 3 dimensions to 3D
		projectFromHigherDimensions(object)

		vertexBuffer = object.getVertexData3D()
		edgesData = object.getEdgesData()		
		
		#print "edges:", edgesData
		#print "vertex:", vertexBuffer
		
		if vertexBuffer != None:		
		
			if renderingMode == RENDER_MODE_1:
				# in this rendering mode we represent edges as
				# cylinders and vertices as spheres
				
				if len(vertexBuffer) == 0: return
				
				# draw vertices (spheres)
				quadObj1 = GLU.gluNewQuadric()
				GLU.gluQuadricDrawStyle(quadObj1, GLU.GLU_FILL)
				#GLU.gluQuadricDrawStyle(quadObj1, GL.GL_WIREFRAME)
				
				for vertex in vertexBuffer.values():
					GL.glLoadIdentity()
					iterateCameras3D()			
					GL.glTranslatef(vertex[0], vertex[1], vertex[2])		
					GLU.gluSphere(quadObj1, 0.1, 15, 15)

				# draw faces
				GL.glBegin(GL.GL_TRIANGLES)
				
				GL.glEnd()
				
				# draw edges (cylinders)
				# initially all the cylinders must points towards the positive z
				# direction
				quadObj2 = GLU.gluNewQuadric()
				GLU.gluQuadricDrawStyle(quadObj2, GLU.GLU_FILL)
				for edge in edgesData.values():
                    
					GL.glLoadIdentity()
					
					iterateCameras3D()			
                    
					#modelview = GL.glGetDouble(GL.GL_MODELVIEW_MATRIX)
					#print "before"
					#dumpOGLMatrix(modelview)
					
					# get 'from' and 'to' vectors for the edge
					x0, y0, z0 = vertexBuffer[int(edge[0])]
					x1, y1, z1 = vertexBuffer[int(edge[1])]
                   
					# position a cylinder
					GL.glTranslatef(x0, y0, z0)
					
					# calculate edge length
					length = math.sqrt( (x1 - x0) ** 2 + (y1 - y0) ** 2 + (z1 - z0) ** 2 )
					
					tmp = Vector([x1 - x0, y1 - y0, z1 - z0])	
                    
					# get the cross products
					if (negZ == tmp.inv().normalize()):
						axis1 = Vector([0,1.0,0])						
					else:
						axis1 = Matrix.crossProduct3D(negZ, tmp.normalize())
					axis2 = Matrix.crossProduct3D(negZ, axis1)				
					axis3 = posZ
                    
					# get the angle we need to rotate to
					cos_angle = posZ.dotProduct(tmp.normalize())
					angle = math.degrees(math.acos(cos_angle))
					
					# calculate the transformation
					axis1.normalizeSelf()
					axis2.normalizeSelf()
                    
					# we need an inverse matrix and we know that the transpose of the rotation matrix is equal to its inverse
					a1, a2, a3 = axis1.getComponents(), axis2.getComponents(), axis3.getComponents()
					v1 = [ a1[0], a2[0], a3[0], 0 ]
					v2 = [ a1[1], a2[1], a3[1], 0 ]
					v3 = [ a1[2], a2[2], a3[2], 0 ]							
					axis1, axis2, axis3 = v1, v2, v3
					
					# feed to openGL				
					rotTransform = createOGLMatrixFromLists(axis1, axis2, axis3)
					rotTransform.extend(homogenousVec)				
					GL.glMultMatrixf(rotTransform)
					
					# rotate a cylinder around axis1
					GL.glRotatef(angle, 1.0, 0.0, 0.0)
				
					# draw a cylinder
					GLU.gluCylinder(quadObj2, 0.05, 0.05, length, 12, 12)					
				
				GLU.gluDeleteQuadric(quadObj1)
				GLU.gluDeleteQuadric(quadObj2)
				
	GL.glUseProgram(shaders[0])
				
	#renderString(100, 100, GLUT.GLUT_BITMAP_8_BY_13, "Hello World", (1.0, 0.0, 0.0))
	
	GLUT.glutSwapBuffers()
    def draw(self):
        global _particle_list
        sphere = glu.gluNewQuadric()

        #Solar system drawing
        if self.checkBox.isChecked():
            #Sun
            gl.glPushMatrix()

            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[0].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[0].color)
            gl.glTranslatef(_particle_list[0].x, _particle_list[0].y,
                            _particle_list[0].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[0].m / 120000.0, 16, 16)
            gl.glTranslatef(-_particle_list[0].x, -_particle_list[0].y,
                            -_particle_list[0].z)
            gl.glPopMatrix()

            #Mercury
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[1].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[1].color)
            gl.glTranslatef(_particle_list[1].x, _particle_list[1].y,
                            _particle_list[1].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[1].m * 10, 16, 16)
            gl.glTranslatef(-_particle_list[1].x, -_particle_list[1].y,
                            -_particle_list[1].z)
            gl.glPopMatrix()

            #Venus
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[2].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[2].color)
            gl.glTranslatef(_particle_list[2].x, _particle_list[2].y,
                            _particle_list[2].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[2].m, 16, 16)
            gl.glTranslatef(-_particle_list[2].x, -_particle_list[2].y,
                            -_particle_list[2].z)
            gl.glPopMatrix()

            #Earth
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[3].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[3].color)
            gl.glTranslatef(_particle_list[3].x, _particle_list[3].y,
                            _particle_list[3].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[3].m, 16, 16)
            gl.glTranslatef(-_particle_list[3].x, -_particle_list[3].y,
                            -_particle_list[3].z)
            gl.glPopMatrix()

            #Mars
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[4].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[4].color)
            gl.glTranslatef(_particle_list[4].x, _particle_list[4].y,
                            _particle_list[4].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[4].m * 7, 16, 16)
            gl.glTranslatef(-_particle_list[4].x, -_particle_list[4].y,
                            -_particle_list[4].z)
            gl.glPopMatrix()

            #Jupiter
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[5].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[5].color)
            gl.glTranslatef(_particle_list[5].x, _particle_list[5].y,
                            _particle_list[5].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[5].m / 30.0, 16, 16)
            gl.glTranslatef(-_particle_list[5].x, -_particle_list[5].y,
                            -_particle_list[5].z)
            gl.glPopMatrix()

            #Saturn
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[6].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[6].color)
            gl.glTranslatef(_particle_list[6].x, _particle_list[6].y,
                            _particle_list[6].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[6].m / 12.0, 16, 16)
            gl.glTranslatef(-_particle_list[6].x, -_particle_list[6].y,
                            -_particle_list[6].z)
            gl.glPopMatrix()

            #Uran
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[7].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[7].color)
            gl.glTranslatef(_particle_list[7].x, _particle_list[7].y,
                            _particle_list[7].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[7].m / 2.3, 16, 16)
            gl.glTranslatef(-_particle_list[7].x, -_particle_list[7].y,
                            -_particle_list[7].z)
            gl.glPopMatrix()

            #Neptune
            gl.glPushMatrix()
            gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                              _particle_list[8].color)
            gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                            _particle_list[8].color)
            gl.glTranslatef(_particle_list[8].x, _particle_list[8].y,
                            _particle_list[8].z)
            glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
            glu.gluSphere(sphere, _particle_list[8].m / 3.2, 16, 16)
            gl.glTranslatef(-_particle_list[8].x, -_particle_list[8].y,
                            -_particle_list[8].z)
            gl.glPopMatrix()

        #other
        else:
            _particle_list = [p for p in _particle_list if p.alive == True]
            for i in range(len(_particle_list)):
                if ((_particle_list[i].x > -2000) &
                    (_particle_list[i].x < 2000)
                        & (_particle_list[i].y > -2000) &
                    (_particle_list[i].y < 2000)
                        & (_particle_list[i].z > -2000) &
                    (_particle_list[i].z < 2000)):
                    gl.glPushMatrix()
                    gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,
                                      _particle_list[i].color)
                    gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR,
                                    _particle_list[i].color)
                    gl.glTranslatef(_particle_list[i].x, _particle_list[i].y,
                                    _particle_list[i].z)
                    glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL)
                    glu.gluSphere(sphere, _particle_list[i].m / 100.0, 16, 16)
                    gl.glTranslatef(-_particle_list[i].x, -_particle_list[i].y,
                                    -_particle_list[i].z)
                    gl.glPopMatrix()
                else:
                    _particle_list[i].alive = False
            glu.gluDeleteQuadric(sphere)

        glu.gluDeleteQuadric(sphere)
        label = str(len(_particle_list))
        self.label_12.setText(label)