当前位置: 首页>>代码示例>>Python>>正文


Python glutils.DisplayList类代码示例

本文整理汇总了Python中glutils.DisplayList的典型用法代码示例。如果您正苦于以下问题:Python DisplayList类的具体用法?Python DisplayList怎么用?Python DisplayList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DisplayList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BlockView

class BlockView(GLOrtho):
    def __init__(self, materials, blockInfo=None):
        GLOrtho.__init__(self)
        self.list = DisplayList(self._gl_draw)
        self.blockInfo = blockInfo or materials.Air
        self.materials = materials

    listBlockInfo = None

    def gl_draw(self):
        if self.listBlockInfo != self.blockInfo:
            self.list.invalidate()
            self.listBlockInfo = self.blockInfo

        self.list.call()

    def _gl_draw(self):
        blockInfo = self.blockInfo
        if blockInfo.ID is 0:
            return

        GL.glColor(1.0, 1.0, 1.0, 1.0)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glEnable(GL.GL_ALPHA_TEST)
        self.materials.terrainTexture.bind()
        pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
        texSize = 16 * pixelScale

        GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                     - 1, 1,
                                                     1, 1,
                                                     1, -1, ], dtype='float32'))
        # hack to get end rod to render properly
        # we really should use json models?
        if blockInfo.ID == 198:
            texOrigin = array([17*16, 20*16])
        else:
            texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
        texOrigin = texOrigin.astype(float) * pixelScale

        GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
                                                       texOrigin[0], texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1] + texSize],
                                                      dtype='float32'))

        GL.glDrawArrays(GL.GL_QUADS, 0, 4)

        GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glDisable(GL.GL_ALPHA_TEST)
        GL.glDisable(GL.GL_TEXTURE_2D)

    @property
    def tooltipText(self):
        #&# Prototype for blocks/items names
        #return str(self.blockInfo.name)
        return mclangres.translate(self.blockInfo.name)
开发者ID:KevinKelley,项目名称:MCEdit-Unified,代码行数:58,代码来源:blockview.py

示例2: BlockView

class BlockView(GLOrtho):
    def __init__(self, materials, blockInfo=None):
        GLOrtho.__init__(self)
        self.list = DisplayList(self._gl_draw)
        self.blockInfo = blockInfo or materials.Air
        self.materials = materials

    listBlockInfo = None

    def gl_draw(self):
        if self.listBlockInfo != self.blockInfo:
            self.list.invalidate()
            self.listBlockInfo = self.blockInfo

        self.list.call()

    def _gl_draw(self):
        blockInfo = self.blockInfo
        if blockInfo.ID is 0:
            return

        GL.glColor(1.0, 1.0, 1.0, 1.0)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glEnable(GL.GL_ALPHA_TEST)
        self.materials.terrainTexture.bind()
        pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
        texSize = 16 * pixelScale

        GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                     - 1, 1,
                                                     1, 1,
                                                     1, -1, ], dtype='float32'))
        texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
        texOrigin *= pixelScale

        GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
                                                       texOrigin[0], texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1] + texSize],
                                                      dtype='float32'))

        GL.glDrawArrays(GL.GL_QUADS, 0, 4)

        GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glDisable(GL.GL_ALPHA_TEST)
        GL.glDisable(GL.GL_TEXTURE_2D)

    @property
    def tooltipText(self):
        return "{0}".format(self.blockInfo.name)
开发者ID:Aiybe,项目名称:MCEdit-Unified,代码行数:51,代码来源:blockview.py

示例3: drawToolMarkers

    def drawToolMarkers(self):
        if self._displayList is None:
            self._displayList = DisplayList(self._drawToolMarkers)

        # print len(self._selectedChunks) if self._selectedChunks else None, "!=", len(self.editor.selectedChunks)

        if self._selectedChunks != self.editor.selectedChunks or True:  # xxx
            self._selectedChunks = set(self.editor.selectedChunks)
            self._displayList.invalidate()

        self._displayList.call()
开发者ID:KevinKelley,项目名称:MCEdit-Unified,代码行数:11,代码来源:chunk.py

示例4: __init__

    def __init__(self, *args):
        EditorTool.__init__(self, *args)
        self.reloadTextures()

        textureVertices = numpy.array(
            (
                24, 16,
                24, 8,
                32, 8,
                32, 16,

                8, 16,
                8, 8,
                16, 8,
                16, 16,

                24, 0,
                16, 0,
                16, 8,
                24, 8,

                16, 0,
                8, 0,
                8, 8,
                16, 8,

                8, 8,
                0, 8,
                0, 16,
                8, 16,

                16, 16,
                24, 16,
                24, 8,
                16, 8,

            ), dtype='f4')

        textureVertices.shape = (24, 2)

        textureVertices *= 4
        textureVertices[:, 1] *= 2

        self.texVerts = textureVertices

        self.playerPos = {}
        self.playerTexture = {}
        self.revPlayerPos = {}

        self.markerList = DisplayList()
开发者ID:Alexhb61,项目名称:MCEdit-Unified,代码行数:50,代码来源:player.py

示例5: __init__

    def __init__(self, *args):
        EditorTool.__init__(self, *args)
        self.reloadTextures()
        self.nonSavedPlayers = []

        textureVerticesHead = numpy.array(
            (
                # Backside of Head
                24, 16, # Bottom Left
                24, 8, # Top Left
                32, 8, # Top Right
                32, 16, # Bottom Right

                # Front of Head
                8, 16,
                8, 8,
                16, 8,
                16, 16,

                #
                24, 0,
                16, 0,
                16, 8,
                24, 8,

                #
                16, 0,
                8, 0,
                8, 8,
                16, 8,

                #
                8, 8,
                0, 8,
                0, 16,
                8, 16,

                16, 16,
                24, 16,
                24, 8,
                16, 8,

            ), dtype='f4')
        
        textureVerticesHat = numpy.array(
            (
                56, 16,
                56, 8,
                64, 8,
                64, 16,
                
                48, 16,
                48, 8,
                40, 8,
                40, 16,
                
                56, 0,
                48, 0,
                48, 8,
                56, 8,
                
                48, 0,
                40, 0,
                40, 8,
                48, 8,
                
                40, 8,
                32, 8,
                32, 16,
                40, 16,
                
                48, 16,
                56, 16,
                56, 8,
                48, 8,
                
            ), dtype='f4')
        

        textureVerticesHead.shape = (24, 2)
        textureVerticesHat.shape = (24, 2)

        textureVerticesHead *= 4
        textureVerticesHead[:, 1] *= 2
        
        textureVerticesHat *= 4
        textureVerticesHat[:, 1] *= 2

        self.texVerts = (textureVerticesHead, textureVerticesHat) 

        self.playerPos = {0:{}, -1:{}, 1:{}}
        self.playerTexture = {}
        self.revPlayerPos = {0:{}, -1:{}, 1:{}}
        self.inOtherDimension = {0: [], 1: [], -1: []}
        self.playercache = PlayerCache()

        self.markerList = DisplayList()
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:97,代码来源:player.py

示例6: PlayerPositionTool


#.........这里部分代码省略.........
                40, 8,
                48, 8,
                
                40, 8,
                32, 8,
                32, 16,
                40, 16,
                
                48, 16,
                56, 16,
                56, 8,
                48, 8,
                
            ), dtype='f4')
        

        textureVerticesHead.shape = (24, 2)
        textureVerticesHat.shape = (24, 2)

        textureVerticesHead *= 4
        textureVerticesHead[:, 1] *= 2
        
        textureVerticesHat *= 4
        textureVerticesHat[:, 1] *= 2

        self.texVerts = (textureVerticesHead, textureVerticesHat) 

        self.playerPos = {0:{}, -1:{}, 1:{}}
        self.playerTexture = {}
        self.revPlayerPos = {0:{}, -1:{}, 1:{}}
        self.inOtherDimension = {0: [], 1: [], -1: []}
        self.playercache = PlayerCache()

        self.markerList = DisplayList()

    panel = None

    def showPanel(self):
        if not self.panel:
            self.panel = PlayerPositionPanel(self)

        self.panel.centery = (self.editor.mainViewport.height - self.editor.toolbar.height) / 2 + self.editor.subwidgets[0].height
        self.panel.left = self.editor.left

        self.editor.add(self.panel)

    def hidePanel(self):
        if self.panel and self.panel.parent:
            self.panel.parent.remove(self.panel)
        self.panel = None

    def drawToolReticle(self):
        if self.movingPlayer is None:
            return

        pos, direction = self.editor.blockFaceUnderCursor
        dim = self.editor.level.getPlayerDimension(self.movingPlayer)
        pos = (pos[0], pos[1] + 2, pos[2])

        x, y, z = pos

        # x,y,z=map(lambda p,d: p+d, pos, direction)
        GL.glEnable(GL.GL_BLEND)
        GL.glColor(1.0, 1.0, 1.0, 0.5)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
        GL.glDisable(GL.GL_BLEND)
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:67,代码来源:player.py

示例7: __init__

 def __init__(self, materials, blockInfo=None):
     GLOrtho.__init__(self)
     self.list = DisplayList(self._gl_draw)
     self.blockInfo = blockInfo or materials.Air
     self.materials = materials
开发者ID:KevinKelley,项目名称:MCEdit-Unified,代码行数:5,代码来源:blockview.py

示例8: PlayerPositionTool


#.........这里部分代码省略.........
                8, 8,
                16, 8,
                16, 16,

                24, 0,
                16, 0,
                16, 8,
                24, 8,

                16, 0,
                16, 8,
                8, 8,
                8, 0,

                8, 8,
                0, 8,
                0, 16,
                8, 16,

                16, 16,
                24, 16,
                24, 8,
                16, 8,

            ), dtype='f4')

        textureVertices.shape = (24, 2)

        textureVertices *= 4
        textureVertices[:, 1] *= 2

        self.texVerts = textureVertices

        self.markerList = DisplayList()

    panel = None

    def showPanel(self):
        if not self.panel:
            self.panel = PlayerPositionPanel(self)

        self.panel.left = self.editor.left
        self.panel.centery = self.editor.centery

        self.editor.add(self.panel)

    def hidePanel(self):
        if self.panel and self.panel.parent:
            self.panel.parent.remove(self.panel)
        self.panel = None

    def drawToolReticle(self):
        if self.movingPlayer is None:
            return

        pos, direction = self.editor.blockFaceUnderCursor
        pos = (pos[0], pos[1] + 2, pos[2])

        x, y, z = pos

        #x,y,z=map(lambda p,d: p+d, pos, direction)
        GL.glEnable(GL.GL_BLEND)
        GL.glColor(1.0, 1.0, 1.0, 0.5)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5)
        GL.glDisable(GL.GL_BLEND)
开发者ID:s32ialx,项目名称:mcedit,代码行数:66,代码来源:player.py

示例9: ChunkTool

class ChunkTool(EditorTool):
    toolIconName = "chunk"
    tooltipText = "Chunk Control"

    @property
    def statusText(self):
        return _("Click and drag to select chunks. Hold {0} to deselect chunks. Hold {1} to select chunks.").format(_(config.keys.deselectChunks.get()), _(config.keys.selectChunks.get()))

    def toolEnabled(self):
        return isinstance(self.editor.level, pymclevel.ChunkedLevelMixin)

    _selectedChunks = None
    _displayList = None

    def drawToolMarkers(self):
        if self._displayList is None:
            self._displayList = DisplayList(self._drawToolMarkers)

        # print len(self._selectedChunks) if self._selectedChunks else None, "!=", len(self.editor.selectedChunks)

        if self._selectedChunks != self.editor.selectedChunks or True:  # xxx
            self._selectedChunks = set(self.editor.selectedChunks)
            self._displayList.invalidate()

        self._displayList.call()

    def _drawToolMarkers(self):

        lines = (
            ((-1, 0), (0, 0, 0, 1), []),
            ((1, 0), (1, 0, 1, 1), []),
            ((0, -1), (0, 0, 1, 0), []),
            ((0, 1), (0, 1, 1, 1), []),
        )
        for ch in self._selectedChunks:
            cx, cz = ch
            for (dx, dz), points, positions in lines:
                n = (cx + dx, cz + dz)
                if n not in self._selectedChunks:
                    positions.append([ch])

        color = self.editor.selectionTool.selectionColor + (0.3, )
        GL.glColor(*color)
        with gl.glEnable(GL.GL_BLEND):

            import renderer

            sizedChunks = renderer.chunkMarkers(self._selectedChunks)
            for size, chunks in sizedChunks.iteritems():
                if not len(chunks):
                    continue
                chunks = numpy.array(chunks, dtype='float32')

                chunkPosition = numpy.zeros(shape=(chunks.shape[0], 4, 3), dtype='float32')
                chunkPosition[..., (0, 2)] = numpy.array(((0, 0), (0, 1), (1, 1), (1, 0)), dtype='float32')
                chunkPosition[..., (0, 2)] *= size
                chunkPosition[..., (0, 2)] += chunks[:, newaxis, :]
                chunkPosition *= 16
                chunkPosition[..., 1] = self.editor.level.Height
                GL.glVertexPointer(3, GL.GL_FLOAT, 0, chunkPosition.ravel())
                # chunkPosition *= 8
                GL.glDrawArrays(GL.GL_QUADS, 0, len(chunkPosition) * 4)

        for d, points, positions in lines:
            if 0 == len(positions):
                continue
            vertexArray = numpy.zeros((len(positions), 4, 3), dtype='float32')
            vertexArray[..., [0, 2]] = positions
            vertexArray.shape = len(positions), 2, 2, 3

            vertexArray[..., 0, 0, 0] += points[0]
            vertexArray[..., 0, 0, 2] += points[1]
            vertexArray[..., 0, 1, 0] += points[2]
            vertexArray[..., 0, 1, 2] += points[3]
            vertexArray[..., 1, 0, 0] += points[2]
            vertexArray[..., 1, 0, 2] += points[3]
            vertexArray[..., 1, 1, 0] += points[0]
            vertexArray[..., 1, 1, 2] += points[1]

            vertexArray *= 16

            vertexArray[..., 1, :, 1] = self.editor.level.Height

            GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray)
            GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
            GL.glDrawArrays(GL.GL_QUADS, 0, len(positions) * 4)
            GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
            with gl.glEnable(GL.GL_BLEND, GL.GL_DEPTH_TEST):
                GL.glDepthMask(False)
                GL.glDrawArrays(GL.GL_QUADS, 0, len(positions) * 4)
                GL.glDepthMask(True)

    @property
    def worldTooltipText(self):
        box = self.editor.selectionTool.selectionBoxInProgress()
        if box:
            box = box.chunkBox(self.editor.level)
            l, w = box.length // 16, box.width // 16
            return _("%s x %s chunks") % (l, w)

#.........这里部分代码省略.........
开发者ID:KevinKelley,项目名称:MCEdit-Unified,代码行数:101,代码来源:chunk.py

示例10: ChunkTool

class ChunkTool(EditorTool):
    toolIconName = "chunk"
    tooltipText = "Chunk Control"

    @property
    def statusText(self):
        return _("Click and drag to select chunks. Hold {0} to deselect chunks. Hold {1} to select chunks.").format(_(config.keys.deselectChunks.get()), _(config.keys.selectChunks.get()))

    def toolEnabled(self):
        return isinstance(self.editor.level, pymclevel.ChunkedLevelMixin)

    _selectedChunks = None
    _displayList = None

    def drawToolMarkers(self):
        if self._displayList is None:
            self._displayList = DisplayList(self._drawToolMarkers)

        # print len(self._selectedChunks) if self._selectedChunks else None, "!=", len(self.editor.selectedChunks)

        if self._selectedChunks != self.editor.selectedChunks or True:  # xxx # TODO Pod
            self._selectedChunks = set(self.editor.selectedChunks)
            self._displayList.invalidate()

        self._displayList.call()

    def _drawToolMarkers(self):

        lines = (
            ((-1, 0), (0, 0, 0, 1), []),
            ((1, 0), (1, 0, 1, 1), []),
            ((0, -1), (0, 0, 1, 0), []),
            ((0, 1), (0, 1, 1, 1), []),
        )
        for ch in self._selectedChunks:
            cx, cz = ch
            for (dx, dz), points, positions in lines:
                n = (cx + dx, cz + dz)
                if n not in self._selectedChunks:
                    positions.append([ch])

        color = self.editor.selectionTool.selectionColor + (0.3, )
        GL.glColor(*color)
        with gl.glEnable(GL.GL_BLEND):

            #import renderer

            sizedChunks = renderer.chunkMarkers(self._selectedChunks)
            for size, chunks in sizedChunks.iteritems():
                if not len(chunks):
                    continue
                chunks = numpy.array(chunks, dtype='float32')

                chunkPosition = numpy.zeros(shape=(chunks.shape[0], 4, 3), dtype='float32')
                chunkPosition[..., (0, 2)] = numpy.array(((0, 0), (0, 1), (1, 1), (1, 0)), dtype='float32')
                chunkPosition[..., (0, 2)] *= size
                chunkPosition[..., (0, 2)] += chunks[:, newaxis, :]
                chunkPosition *= 16
                chunkPosition[..., 1] = self.editor.level.Height
                GL.glVertexPointer(3, GL.GL_FLOAT, 0, chunkPosition.ravel())
                # chunkPosition *= 8
                GL.glDrawArrays(GL.GL_QUADS, 0, len(chunkPosition) * 4)

        for d, points, positions in lines:
            if 0 == len(positions):
                continue
            vertexArray = numpy.zeros((len(positions), 4, 3), dtype='float32')
            vertexArray[..., [0, 2]] = positions
            vertexArray.shape = len(positions), 2, 2, 3

            vertexArray[..., 0, 0, 0] += points[0]
            vertexArray[..., 0, 0, 2] += points[1]
            vertexArray[..., 0, 1, 0] += points[2]
            vertexArray[..., 0, 1, 2] += points[3]
            vertexArray[..., 1, 0, 0] += points[2]
            vertexArray[..., 1, 0, 2] += points[3]
            vertexArray[..., 1, 1, 0] += points[0]
            vertexArray[..., 1, 1, 2] += points[1]

            vertexArray *= 16

            vertexArray[..., 1, :, 1] = self.editor.level.Height

            GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArray)
            GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)
            GL.glDrawArrays(GL.GL_QUADS, 0, len(positions) * 4)
            GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
            with gl.glEnable(GL.GL_BLEND, GL.GL_DEPTH_TEST):
                GL.glDepthMask(False)
                GL.glDrawArrays(GL.GL_QUADS, 0, len(positions) * 4)
                GL.glDepthMask(True)

    @property
    def worldTooltipText(self):
        box = self.editor.selectionTool.selectionBoxInProgress()
        if box:
            box = box.chunkBox(self.editor.level)
            l, w = box.length // 16, box.width // 16
            return _("%s x %s chunks") % (l, w)
        else:
#.........这里部分代码省略.........
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:101,代码来源:chunk.py

示例11: PlayerPositionTool


#.........这里部分代码省略.........
                24, 0,
                16, 0,
                16, 8,
                24, 8,

                16, 0,
                8, 0,
                8, 8,
                16, 8,

                8, 8,
                0, 8,
                0, 16,
                8, 16,

                16, 16,
                24, 16,
                24, 8,
                16, 8,

            ), dtype='f4')

        textureVertices.shape = (24, 2)

        textureVertices *= 4
        textureVertices[:, 1] *= 2

        self.texVerts = textureVertices

        self.playerPos = {}
        self.playerTexture = {}
        self.revPlayerPos = {}

        self.markerList = DisplayList()

    panel = None

    def showPanel(self):
        if not self.panel:
            self.panel = PlayerPositionPanel(self)

        self.panel.left = self.editor.left
        self.panel.centery = self.editor.centery

        self.editor.add(self.panel)

    def hidePanel(self):
        if self.panel and self.panel.parent:
            self.panel.parent.remove(self.panel)
        self.panel = None

    def drawToolReticle(self):
        if self.movingPlayer is None:
            return

        pos, direction = self.editor.blockFaceUnderCursor
        pos = (pos[0], pos[1] + 2, pos[2])

        x, y, z = pos

        # x,y,z=map(lambda p,d: p+d, pos, direction)
        GL.glEnable(GL.GL_BLEND)
        GL.glColor(1.0, 1.0, 1.0, 0.5)
        self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[self.movingPlayer])
        GL.glDisable(GL.GL_BLEND)
开发者ID:Alexhb61,项目名称:MCEdit-Unified,代码行数:66,代码来源:player.py


注:本文中的glutils.DisplayList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。