예제 #1
0
파일: sky.py 프로젝트: metehanboy/mcedit2
    def drawSelf(self):
        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glLoadIdentity()
            with gl.glPushMatrix(GL.GL_PROJECTION):
                GL.glLoadIdentity()
                with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
                    GL.glClear(GL.GL_COLOR_BUFFER_BIT)
                    GL.glEnableClientState(GL.GL_COLOR_ARRAY)
                    quad = numpy.array([-1, -1, -1, 1, 1, 1, 1, -1],
                                       dtype='float32')
                    colors = numpy.array([
                        0x48,
                        0x49,
                        0xBA,
                        0xff,
                        0x8a,
                        0xaf,
                        0xff,
                        0xff,
                        0x8a,
                        0xaf,
                        0xff,
                        0xff,
                        0x48,
                        0x49,
                        0xBA,
                        0xff,
                    ],
                                         dtype='uint8')

                    with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT):
                        GL.glDepthMask(False)
                        GL.glVertexPointer(2, GL.GL_FLOAT, 0, quad)
                        GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, colors)
                        GL.glDrawArrays(GL.GL_QUADS, 0, 4)
예제 #2
0
파일: sky.py 프로젝트: 101baja202/mcedit2
    def drawSelf(self):
        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glLoadIdentity()
            with gl.glPushMatrix(GL.GL_PROJECTION):
                GL.glLoadIdentity()
                with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
                    GL.glClear(GL.GL_COLOR_BUFFER_BIT)
                    GL.glEnableClientState(GL.GL_COLOR_ARRAY)
                    quad = numpy.array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32')
                    colors = numpy.array([0x48, 0x49, 0xBA, 0xff,
                                          0x8a, 0xaf, 0xff, 0xff,
                                          0x8a, 0xaf, 0xff, 0xff,
                                          0x48, 0x49, 0xBA, 0xff, ], dtype='uint8')

                    with gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT):
                        GL.glDepthMask(False)
                        GL.glVertexPointer(2, GL.GL_FLOAT, 0, quad)
                        GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, colors)
                        GL.glDrawArrays(GL.GL_QUADS, 0, 4)
예제 #3
0
    def drawSelf(self):
        with gl.glPushAttrib(GL.GL_FOG_BIT | GL.GL_ENABLE_BIT):
            with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
                GL.glDisable(GL.GL_FOG)

                GL.glEnable(GL.GL_BLEND)
                GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
                GL.glPolygonOffset(DepthOffset.ChunkMarkers, DepthOffset.ChunkMarkers)
                GL.glEnable(GL.GL_DEPTH_TEST)

                GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
                GL.glEnable(GL.GL_TEXTURE_2D)
                GL.glColor(1.0, 1.0, 1.0, 1.0)

                self.floorTexture.bind()

                for vertexArray in self.sceneNode.createVertexArrays():
                    GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray.ravel())
                    # chunkPositions *= 8
                    GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, (vertexArray[..., (0, 2)] / 32).ravel())
                    GL.glDrawArrays(GL.GL_QUADS, 0, len(vertexArray) * 4)
예제 #4
0
    def drawSelf(self):
        with gl.glPushAttrib(GL.GL_FOG_BIT | GL.GL_ENABLE_BIT):
            with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
                GL.glDisable(GL.GL_FOG)

                GL.glEnable(GL.GL_BLEND)
                GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
                GL.glPolygonOffset(DepthOffset.ChunkMarkers,
                                   DepthOffset.ChunkMarkers)
                GL.glEnable(GL.GL_DEPTH_TEST)

                GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
                GL.glEnable(GL.GL_TEXTURE_2D)
                GL.glColor(1.0, 1.0, 1.0, 1.0)

                self.floorTexture.bind()

                for vertexArray in self.sceneNode.createVertexArrays():
                    GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray.ravel())
                    # chunkPositions *= 8
                    GL.glTexCoordPointer(2, GL.GL_FLOAT, 0,
                                         (vertexArray[...,
                                                      (0, 2)] / 32).ravel())
                    GL.glDrawArrays(GL.GL_QUADS, 0, len(vertexArray) * 4)
예제 #5
0
파일: cubes.py 프로젝트: 101baja202/mcedit2
def drawBox(box, cubeType=GL.GL_QUADS, texture=None, textureVertices=None, selectionBox=False):
    """ pass a different cubeType e.g. GL_LINE_STRIP for wireframes """
    x, y, z, = box.origin
    x2, y2, z2 = box.maximum
    dx, dy, dz = x2 - x, y2 - y, z2 - z
    cubeVertices = numpy.array(
        (
            x, y, z,
            x, y2, z,
            x2, y2, z,
            x2, y, z,

            x2, y, z2,
            x2, y2, z2,
            x, y2, z2,
            x, y, z2,

            x2, y, z2,
            x, y, z2,
            x, y, z,
            x2, y, z,

            x2, y2, z,
            x, y2, z,
            x, y2, z2,
            x2, y2, z2,

            x, y2, z2,
            x, y2, z,
            x, y, z,
            x, y, z2,

            x2, y, z2,
            x2, y, z,
            x2, y2, z,
            x2, y2, z2,
        ), dtype='f4')
    if textureVertices is None and texture is not None:
        textureVertices = numpy.array(
            (
                0, -dy * 16,
                0, 0,
                dx * 16, 0,
                dx * 16, -dy * 16,

                dx * 16, -dy * 16,
                dx * 16, 0,
                0, 0,
                0, -dy * 16,

                dx * 16, -dz * 16,
                0, -dz * 16,
                0, 0,
                dx * 16, 0,

                dx * 16, 0,
                0, 0,
                0, -dz * 16,
                dx * 16, -dz * 16,

                dz * 16, 0,
                0, 0,
                0, -dy * 16,
                dz * 16, -dy * 16,

                dz * 16, -dy * 16,
                0, -dy * 16,
                0, 0,
                dz * 16, 0,

            ), dtype='f4')

        textureVertices.shape = (6, 4, 2)

        if selectionBox:
            textureVertices[0:2] += (16 * (x & 15), 16 * (y2 & 15))
            textureVertices[2:4] += (16 * (x & 15), -16 * (z & 15))
            textureVertices[4:6] += (16 * (z & 15), 16 * (y2 & 15))
            textureVertices[:] += 0.5

    with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
        with gl.glPushAttrib(GL.GL_TEXTURE_BIT):
            GL.glVertexPointer(3, GL.GL_FLOAT, 0, cubeVertices)
            if texture is not None:
                GL.glEnable(GL.GL_TEXTURE_2D)
                GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)

                texture.bind()
                GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, textureVertices),

            with gl.glPushAttrib(GL.GL_POLYGON_BIT):
                GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
                GL.glEnable(GL.GL_POLYGON_OFFSET_LINE)

                GL.glDrawArrays(cubeType, 0, 24)
예제 #6
0
파일: cubes.py 프로젝트: metehanboy/mcedit2
def drawBox(box,
            cubeType=GL.GL_QUADS,
            texture=None,
            textureVertices=None,
            selectionBox=False):
    """ pass a different cubeType e.g. GL_LINE_STRIP for wireframes """
    x, y, z, = box.origin
    x2, y2, z2 = box.maximum
    dx, dy, dz = x2 - x, y2 - y, z2 - z
    cubeVertices = numpy.array((
        x,
        y,
        z,
        x,
        y2,
        z,
        x2,
        y2,
        z,
        x2,
        y,
        z,
        x2,
        y,
        z2,
        x2,
        y2,
        z2,
        x,
        y2,
        z2,
        x,
        y,
        z2,
        x2,
        y,
        z2,
        x,
        y,
        z2,
        x,
        y,
        z,
        x2,
        y,
        z,
        x2,
        y2,
        z,
        x,
        y2,
        z,
        x,
        y2,
        z2,
        x2,
        y2,
        z2,
        x,
        y2,
        z2,
        x,
        y2,
        z,
        x,
        y,
        z,
        x,
        y,
        z2,
        x2,
        y,
        z2,
        x2,
        y,
        z,
        x2,
        y2,
        z,
        x2,
        y2,
        z2,
    ),
                               dtype='f4')
    if textureVertices is None and texture is not None:
        textureVertices = numpy.array((
            0,
            -dy * 16,
            0,
            0,
            dx * 16,
            0,
            dx * 16,
            -dy * 16,
            dx * 16,
            -dy * 16,
            dx * 16,
            0,
            0,
            0,
            0,
            -dy * 16,
            dx * 16,
            -dz * 16,
            0,
            -dz * 16,
            0,
            0,
            dx * 16,
            0,
            dx * 16,
            0,
            0,
            0,
            0,
            -dz * 16,
            dx * 16,
            -dz * 16,
            dz * 16,
            0,
            0,
            0,
            0,
            -dy * 16,
            dz * 16,
            -dy * 16,
            dz * 16,
            -dy * 16,
            0,
            -dy * 16,
            0,
            0,
            dz * 16,
            0,
        ),
                                      dtype='f4')

        textureVertices.shape = (6, 4, 2)

        if selectionBox:
            textureVertices[0:2] += (16 * (x & 15), 16 * (y2 & 15))
            textureVertices[2:4] += (16 * (x & 15), -16 * (z & 15))
            textureVertices[4:6] += (16 * (z & 15), 16 * (y2 & 15))
            textureVertices[:] += 0.5

    with gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT):
        with gl.glPushAttrib(GL.GL_TEXTURE_BIT):
            GL.glVertexPointer(3, GL.GL_FLOAT, 0, cubeVertices)
            if texture is not None:
                GL.glEnable(GL.GL_TEXTURE_2D)
                GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)

                texture.bind()
                GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, textureVertices),

            with gl.glPushAttrib(GL.GL_POLYGON_BIT):
                GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
                GL.glEnable(GL.GL_POLYGON_OFFSET_LINE)

                GL.glDrawArrays(cubeType, 0, 24)