def on_draw(): """ Redraw the screen """ # reset window and set all needed opengl flags window.clear() glPushAttrib(GL_ENABLE_BIT) glEnable(GL_DEPTH_TEST) glEnable(GL_BLEND) glEnable(GL_CULL_FACE) glCullFace(GL_BACK) glEnable(GL_COLOR_MATERIAL) glShadeModel(GL_SMOOTH) # draw skybox if requested if draw_skybox: glPushAttrib(GL_ENABLE_BIT) skybox_matrix = mvp.__copy__() skybox_matrix.translate(camera.position.x, camera.position.y, camera.position.z) skybox_matrix.rotate_axis(math.radians(-90), Vector3(1, 0, 0)) glLoadMatrixd(toGlMatrix(skybox_matrix)) skybox.draw() glPopAttrib() # loop through bodies and draw for planet in bodies: glPushAttrib(GL_ENABLE_BIT) planet.draw(mvp.__copy__()) glPopAttrib() glPopAttrib() # ====== START GUI ====== # create an orthographic projection (2d) glPushAttrib(GL_ENABLE_BIT) glMatrixMode(GL_PROJECTION) glLoadIdentity() glMatrixMode(GL_MODELVIEW) glLoadIdentity() glOrtho(0, window.width, 0, window.height, -1, 1) gui.draw() glColor3f(1, 1, 0) glLineWidth(1.0) glBegin(GL_LINES) cross_len = 10 glVertex2f(window.width / 2 - cross_len, window.height / 2) glVertex2f(window.width / 2 + cross_len, window.height / 2) glVertex2f(window.width / 2, window.height / 2 - cross_len) glVertex2f(window.width / 2, window.height / 2 + cross_len) glEnd() glColor3f(1, 1, 1) glPopAttrib()
def draw(self, body, matrix): matrix.translate(body.xyz.x, body.xyz.y, body.xyz.z) matrix.rotate_axis(radians(-90), Vector3(1, 0, 0)) matrix.rotate_axis(body.axial_tilt, Vector3(0, 1, 0)) matrix.rotate_axis(radians(-360 * body.time), Vector3(0, 0, 1)) glLoadMatrixd(toGlMatrix(matrix)) if body.texture_visible: body.texture.draw() else: glColor3f(r(), r(), r()) gluSphere(body.sphere, body.radius, 50, 50) glDisable(GL_TEXTURE_2D)
def draw(self, body, matrix): matrix.translate(body.xyz.x, body.xyz.y, body.xyz.z) matrix.rotate_axis(math.radians(-90), Vector3(1, 0, 0)) matrix.rotate_axis(body.axial_tilt, Vector3(0, 1, 0)) matrix.rotate_axis(math.radians(-360 * body.timefactor), Vector3(0, 0, 1)) glLoadMatrixd(toGlMatrix(matrix)) if body.draw_texture: body.texture.draw() else: glColor3f(body.color["r"] / 255.0, body.color["g"] / 255.0, body.color["b"] / 255.0) gluSphere(body.sphere, body.radius, 50, 50) glDisable(GL_TEXTURE_2D)
def draw(self, body, matrix): if body.orbit_visible: linematrix = matrix.__copy__() if body.parent is not None: linematrix.translate(body.parent.xyz.x, body.parent.xyz.y, body.parent.xyz.z) glLoadMatrixd(toGlMatrix(linematrix)) glLineWidth(1.25) glColor3f(r(), r(), r()) body.orbit_line_batch.draw() glColor3f(1.0, 1.0, 1.0) super().draw(body, matrix)
def draw(self, body, matrix): # draw the in the constructor plotted line if requested if body.draw_orbit: linematrix = matrix.__copy__() if body.parent is not None: linematrix.translate(body.parent.xyz.x, body.parent.xyz.y, body.parent.xyz.z) glLoadMatrixd(toGlMatrix(linematrix)) glLineWidth(1.25) glColor3f(body.color["r"] / 255.0, body.color["g"] / 255.0, body.color["b"] / 255.0) body.orbit_line_batch.draw() glColor3f(1.0, 1.0, 1.0) super().draw(body, matrix)
def draw(self, body, mat): if body.texture_visible: matrix = mat.__copy__() matrix.translate(body.xyz.x, body.xyz.y, body.xyz.z) matrix.rotate_axis(radians(-90), Vector3(1, 0, 0)) matrix.rotate_axis(body.axial_tilt, Vector3(0, 1, 0)) glLoadMatrixd(toGlMatrix(matrix)) glDisable(GL_DEPTH_TEST) glDisable(GL_CULL_FACE) body.ring_texture.draw() gluDisk(body.ring_disk, body.ring_inner_radius, body.ring_outer_radius, 50, 50) glEnable(GL_CULL_FACE) glEnable(GL_DEPTH_TEST) glDisable(GL_TEXTURE_2D) super().draw(body, mat)