def updateCube(self, cube, customColor=None): shown = any(cube.shown.values()) if shown: if (cube.name != 'water' and cube.name != 'lava') and cube.p not in self.collidable: self.collidable[cube.p] = cube else: if cube.p in self.collidable: del self.collidable[cube.p] return show = self.show v = cube_vertices(cube.p) f = 'left', 'right', 'bottom', 'top', 'back', 'front' for i in (0, 1, 2, 3, 4, 5): if cube.shown[f[i]] and not cube.faces[f[i]]: cube.faces[f[i]] = show(v[i], cube.t[i], f[i], clrC=customColor) elif customColor: if cube.color[f[i]] != customColor[f[i]]: if cube.shown[f[i]]: cube.faces[f[i]].delete() cube.faces[f[i]] = show(v[i], cube.t[i], f[i], clrC=customColor) cube.color[f[i]] = customColor[f[i]]
def draw_focused_block(self): """ Draw black edges around the block that is currently under the crosshairs. """ vector = self.get_sight_vector() block = self.model.hit_test(self.position, vector)[0] if block: x, y, z = block vertex_data = cube_vertices(x, y, z, 0.51) glColor3d(0, 0, 0) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) pyglet.graphics.draw(24, GL_QUADS, ('v3f/static', vertex_data)) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
def _show_block(self, position, texture): """ Private implementation of the `show_block()` method. Parameters ---------- position : tuple of len 3 The (x, y, z) position of the block to show. texture : list of len 3 The coordinates of the texture squares. Use `tex_coords()` to generate. """ x, y, z = position vertex_data = cube_vertices(x, y, z, 0.5) texture_data = list(texture) # create vertex list # FIXME Maybe `add_indexed()` should be used instead self._shown[position] = self.batch.add(24, GL_QUADS, self.group, ('v3f/static', vertex_data), ('t2f/static', texture_data))