예제 #1
0
 def draw_focused_block(self):
     """Draw black edges around the block that is currently under the
     crosshairs.
     """
     block = self.player.hit(self.world.area.blocks)[0]
     if block:
         x, y, z = block
         vertex_data = cube_vertices(x, y, z, 0.51)
         GL.glColor3d(0, 0, 0)
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
         pyglet.graphics.draw(24, GL.GL_QUADS, ('v3f/static', vertex_data))
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
예제 #2
0
 def draw_focused_block(self):
     """Draw black edges around the block that is currently under the
     crosshairs.
     """
     block = self.player.hit(self.world.area.blocks)[0]
     if block:
         x, y, z = block
         vertex_data = cube_vertices(x, y, z, 0.51)
         GL.glColor3d(0, 0, 0)
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
         pyglet.graphics.draw(24, GL.GL_QUADS, ('v3f/static', vertex_data))
         GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
예제 #3
0
파일: window.py 프로젝트: siper92/pycraft
 def draw_focused_block(self):
     """Draw black edges around the block that is currently under the
     crosshairs.
     """
     vector = self.player.get_sight_vector()
     block = self.world.hit_test(self.player.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)
예제 #4
0
파일: window.py 프로젝트: Mrkebubun/pycraft
 def draw_focused_block(self):
     """Draw black edges around the block that is currently under the
     crosshairs.
     """
     vector = self.player.get_sight_vector()
     block = self.world.hit_test(self.player.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)
예제 #5
0
    def _show_block(self, position, block):
        """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)
        self.__show_block(position, vertex_data, block)
예제 #6
0
    def _show_block(self, position, block):
        """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)
        self.__show_block(position,vertex_data,block)
예제 #7
0
    def _show_block(self, position, block):
        """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 = block.texture
        self._shown[position] = self.batch.add(
            24, GL_QUADS, self.group,
            ('v3f/static', vertex_data),
            ('t2f/static', texture_data))
예제 #8
0
파일: world.py 프로젝트: tsukori/pycraft
    def _show_block(self, position, block):
        """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)
        shade_data = cube_shade(1, 1, 1, 1)
        texture_data = block.texture
        if block.identifier not in self.texture_group:
            self.texture_group[block.identifier] = TextureGroup(
                image.load(block.texture_path).get_texture())
        self._shown[position] = self.batch.add(
            24, GL_QUADS, self.texture_group[block.identifier],
            ('v3f/static', vertex_data), ('c3f/static', shade_data),
            ('t2f/static', texture_data))
예제 #9
0
파일: world.py 프로젝트: PythonJedi/pycraft
    def _show_block(self, position, block):
        """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)
        shade_data = cube_shade(1, 1, 1, 1)
        texture_data = block.texture
        if block.identifier not in self.texture_group:
            self.texture_group[block.identifier] = TextureGroup(image.load(block.texture_path).get_texture())
        self._shown[position] = self.batch.add(
            24, GL_QUADS, self.texture_group[block.identifier],
            ('v3f/static', vertex_data),
            ('c3f/static', shade_data),
            ('t2f/static', texture_data))
예제 #10
0
def test_cube_vertices():
    """
    Test cube_vertices function.
    """
    vertices = util.cube_vertices(0, 10, 20, 0.5)

    # 6 groups of each 12 numbers. those numbers are 4 3-tuple coordinates
    # making up the 6 sides of a cube
    groups = [vertices[i:i + 12] for i in range(0, 72, 12)]
    total_coords = set()
    for i, group in enumerate(groups):
        coords = [tuple(group[j:j + 3]) for j in range(0, 12, 3)]
        total_coords |= set(coords)
        assert len(coords) == len(set(coords)), 'Face coords not unique'
        if i in (0, 1):
            # top/bottom: y should always be the same
            assert len(set(c[1] for c in coords)) == 1
        elif i in (2, 3):
            # left/right, x should always be the same
            assert len(set(c[0] for c in coords)) == 1
        elif i in (4, 5):
            # front/back, z should always be the same
            assert len(set(c[2] for c in coords)) == 1
    assert len(total_coords) == 8, 'A cube has exactly 8 corners'
예제 #11
0
파일: test_util.py 프로젝트: Hispar/pycraft
def test_cube_vertices():
    """
    Test cube_vertices function.
    """
    vertices = util.cube_vertices(0, 10, 20, 0.5)

    # 6 groups of each 12 numbers. those numbers are 4 3-tuple coordinates
    # making up the 6 sides of a cube
    groups = [vertices[i:i + 12] for i in range(0, 72, 12)]
    total_coords = set()
    for i, group in enumerate(groups):
        coords = [tuple(group[j:j + 3]) for j in range(0, 12, 3)]
        total_coords |= set(coords)
        assert len(coords) == len(set(coords)), 'Face coords not unique'
        if i in (0, 1):
            # top/bottom: y should always be the same
            assert len(set(c[1] for c in coords)) == 1
        elif i in (2, 3):
            # left/right, x should always be the same
            assert len(set(c[0] for c in coords)) == 1
        elif i in (4, 5):
            # front/back, z should always be the same
            assert len(set(c[2] for c in coords)) == 1
    assert len(total_coords) == 8, 'A cube has exactly 8 corners'