def initData(filepath=None, texpath=None): global objs if not filepath: filepath=Path("files/sphere.obj") if not texpath: texpath=Path("texture/earth") obj_data = io.read_obj(filepath) sphere = io.read_obj("files/sphere.obj") # cube_data = io.read_obj("files/cube.obj") obj = Object(obj_data, [1.0, 1.0, 1.0]) light = Object(sphere, [1.0, 1.0, 1.0]) sky = Object(sphere, [0.8, 0.8, 0.8]) if Path(texpath).is_dir(): obj_tex = Cubemap() else: obj_tex = Texture() obj_tex.load(Path(texpath)) stars = Texture() stars.load("texture/milky_way.jpg") moon = Texture() moon.load("texture/moon.jpg") # for key in earth.faces: # print(f'{key}: {earth.faces[key].filename}') sky.create(stars) obj.create(obj_tex) # obj.create() light.create(moon) objs = [obj, light, sky] # objs = [obj, light] # Place objects in center light.translate(-light.x, -light.y, -light.z) obj.translate(-obj.x, -obj.y, -obj.z) sky.translate(-sky.x, -sky.y, -sky.z-1) light.scale(0.1, 0.1, 0.1) sky.scale(10,10,10) sky.rotate('y', 145) gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthFunc(gl.GL_LESS) # Unbind Vertex Array Object. gl.glBindVertexArray(0)
mesh2.load() mesh2.create() mesh2_mat = pyrr.matrix44.create_from_translation(pyrr.Vector3([0, 0, 0])) # mesh3 = Mesh("resources/meshes/Dragon.ply") # mesh3.load() # mesh3.create() # mesh3_mat = pyrr.matrix44.create_from_translation(pyrr.Vector3([2, 1, .5])) shader1 = Shader("resources/shaders/shader1.vs", "resources/shaders/shader1.fs") shader1.load() shader1.create() # shader1.use() # needed tex1 = Texture("resources/images/marble.jpg") tex1.load() tex1.create() tex2 = Texture("resources/images/brickwall.jpg") tex2.load() tex2.create() tex3 = Texture("resources/images/StoneMarbleCalacatta004_COL_2K.jpg") tex3.load() tex3.create() light_pos = [0.0, 1.0, 3.0] # set global render states glClearColor(0, 0.1, 0.1, 1) glEnable(GL_DEPTH_TEST)