def __init__(self, content_manager, asset_name): asset_name = 'art objects/' + asset_name art_object = content_manager.load(asset_name, expected_type='FezEngine.Structure.ArtObject') try: cubemap_name = 'art objects/' + art_object.cubemap_path cubemap = content_manager.load(cubemap_name, expected_type='Microsoft.Xna.Framework.Graphics.Texture2D') except AttributeError: cubemap = art_object.cubemap self.texture = pyglet.image.ImageData(cubemap.width, cubemap.height, 'RGBA', cubemap.full_data()).get_texture() indices = art_object.geometry.indices vertices = [] normals = [] texture_coords = [] for cur_vertex in art_object.geometry.vertices: vertices.append(cur_vertex.position.x / art_object.size.x) vertices.append(cur_vertex.position.y / art_object.size.y) vertices.append(cur_vertex.position.z / art_object.size.z) cur_normal = NORMALS[cur_vertex.normal] normals.append(cur_normal.x) normals.append(cur_normal.y) normals.append(cur_normal.z) texture_coords.append(cur_vertex.texture_coord.x * self.texture.tex_coords[2 * 3 + 0]) texture_coords.append(cur_vertex.texture_coord.y * self.texture.tex_coords[2 * 3 + 1]) self.vli = pyglet.graphics.vertex_list_indexed(len(vertices) // 3, indices, ('v3f', vertices), ('n3f', normals), ('t2f', texture_coords)) glDisable(self.texture.target) glTexParameteri(self.texture.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glTexParameteri(self.texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, vec_args(0.6, 0.6, 0.6, 1.0))
def gl_setup(): glClearColor(0.3926, 0.5843, 0.9294, 1.0) glClearDepth(1.0) glColor3f(1.0, 1.0, 1.0) glDisable(GL_CULL_FACE) glFrontFace(GL_CW) glEnable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) glPolygonOffset(1, 1) glDisable(GL_LIGHTING) glEnable(GL_LIGHT0) glLightfv(GL_LIGHT0, GL_POSITION, vec_args(0.5, 0.5, 10.0, 1.0)) glLightfv(GL_LIGHT0, GL_AMBIENT, vec_args(0.5, 0.5, 0.5, 1.0)) glLightfv(GL_LIGHT0, GL_DIFFUSE, vec_args(1.0, 1.0, 1.0, 1.0))
def __init__(self, content_manager, asset_name): asset_name = 'art objects/' + asset_name art_object = content_manager.load( asset_name, expected_type='FezEngine.Structure.ArtObject') try: cubemap_name = 'art objects/' + art_object.cubemap_path cubemap = content_manager.load( cubemap_name, expected_type='Microsoft.Xna.Framework.Graphics.Texture2D') except AttributeError: cubemap = art_object.cubemap self.texture = pyglet.image.ImageData( cubemap.width, cubemap.height, 'RGBA', cubemap.full_data()).get_texture() indices = art_object.geometry.indices vertices = [] normals = [] texture_coords = [] for cur_vertex in art_object.geometry.vertices: vertices.append(cur_vertex.position.x / art_object.size.x) vertices.append(cur_vertex.position.y / art_object.size.y) vertices.append(cur_vertex.position.z / art_object.size.z) cur_normal = NORMALS[cur_vertex.normal] normals.append(cur_normal.x) normals.append(cur_normal.y) normals.append(cur_normal.z) texture_coords.append(cur_vertex.texture_coord.x * self.texture.tex_coords[2 * 3 + 0]) texture_coords.append(cur_vertex.texture_coord.y * self.texture.tex_coords[2 * 3 + 1]) self.vli = pyglet.graphics.vertex_list_indexed( len(vertices) // 3, indices, ('v3f', vertices), ('n3f', normals), ('t2f', texture_coords)) glDisable(self.texture.target) glTexParameteri(self.texture.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glTexParameteri(self.texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, vec_args(0.6, 0.6, 0.6, 1.0))