def _paint_block(self, position): """ Creates vertexes for the block. Parameters ---------- position : tuple of len 3 The (x, y, z) position of the block to show. """ x, y, z = position try: block = self.world.getBlock(position) if block.getVertex(): return vertex_data = Transform.cube_vertices(x, y, z, 0.5) texture_data = list(block.getTexture()) # create vertex list # FIXME Maybe `add_indexed()` should be used instead block.setVertex(self.batch.add(24, GL_QUADS, self._materialFactory.getMaterial(block.getMaterial()).textureGroup, ('v3f/static', vertex_data), ('t2f/static', texture_data))) #self.log.debug('Block at %s made visible' % (position,)) except Exception, e: self.log.error("Painting block at %s failed: %s" % (position, e))
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._player.position, vector)[0] if block: x, y, z = block self.focusedBlock = block vertex_data = Transform.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)