本文整理汇总了Python中glutils.DisplayList.call方法的典型用法代码示例。如果您正苦于以下问题:Python DisplayList.call方法的具体用法?Python DisplayList.call怎么用?Python DisplayList.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glutils.DisplayList
的用法示例。
在下文中一共展示了DisplayList.call方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BlockView
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
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)
示例2: BlockView
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
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)
示例3: PlayerPositionTool
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
#.........这里部分代码省略.........
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)
GL.glEnable(GL.GL_DEPTH_TEST)
self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[dim][self.movingPlayer], dim)
drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
#drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
GL.glDisable(GL.GL_DEPTH_TEST)
markerLevel = None
def drawToolMarkers(self):
if not config.settings.drawPlayerHeads.get():
return
if self.markerLevel != self.editor.level:
self.markerList.invalidate()
self.markerLevel = self.editor.level
self.markerList.call(self._drawToolMarkers)
def _drawToolMarkers(self):
GL.glColor(1.0, 1.0, 1.0, 0.5)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glMatrixMode(GL.GL_MODELVIEW)
for player in self.editor.level.players:
try:
pos = self.editor.level.getPlayerPosition(player)
yaw, pitch = self.editor.level.getPlayerOrientation(player)
dim = self.editor.level.getPlayerDimension(player)
self.inOtherDimension[dim].append(player)
self.playerPos[dim][pos] = player
self.revPlayerPos[dim][player] = pos
if player != "Player" and config.settings.downloadPlayerSkins.get():
# print 7
r = self.playercache.getPlayerSkin(player, force_download=False)
if not isinstance(r, (str, unicode)):
r = r.join()
self.playerTexture[player] = loadPNGTexture(r)
else:
self.playerTexture[player] = self.charTex
if dim != self.editor.level.dimNo:
continue
x, y, z = pos
GL.glPushMatrix()
GL.glTranslate(x, y, z)
GL.glRotate(-yaw, 0, 1, 0)
GL.glRotate(pitch, 1, 0, 0)
GL.glColor(1, 1, 1, 1)
self.drawCharacterHead(0, 0, 0, (x,y,z), self.editor.level.dimNo)
GL.glPopMatrix()
# GL.glEnable(GL.GL_BLEND)
drawTerrainCuttingWire(FloatBox((x - .5, y - .5, z - .5), (1, 1, 1)),
c0=(0.3, 0.9, 0.7, 1.0),
c1=(0, 0, 0, 0),
)
#GL.glDisable(GL.GL_BLEND)
except Exception, e:
print "Exception in editortools.player.PlayerPositionTool._drawToolMarkers:", repr(e)
import traceback
print traceback.format_exc()
continue
GL.glDisable(GL.GL_DEPTH_TEST)
示例4: PlayerPositionTool
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
#.........这里部分代码省略.........
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)
GL.glEnable(GL.GL_DEPTH_TEST)
self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5)
drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
#drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
GL.glDisable(GL.GL_DEPTH_TEST)
markerLevel = None
def drawToolMarkers(self):
if self.markerLevel != self.editor.level:
self.markerList.invalidate()
self.markerLevel = self.editor.level
self.markerList.call(self._drawToolMarkers)
def _drawToolMarkers(self):
GL.glColor(1.0, 1.0, 1.0, 0.5)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glMatrixMode(GL.GL_MODELVIEW)
for player in self.editor.level.players:
try:
pos = self.editor.level.getPlayerPosition(player)
yaw, pitch = self.editor.level.getPlayerOrientation(player)
dim = self.editor.level.getPlayerDimension(player)
if dim != self.editor.level.dimNo:
continue
x, y, z = pos
GL.glPushMatrix()
GL.glTranslate(x, y, z)
GL.glRotate(-yaw, 0, 1, 0)
GL.glRotate(pitch, 1, 0, 0)
GL.glColor(1, 1, 1, 1)
self.drawCharacterHead(0, 0, 0)
GL.glPopMatrix()
#GL.glEnable(GL.GL_BLEND)
drawTerrainCuttingWire(FloatBox((x - .5, y - .5, z - .5), (1, 1, 1)),
c0=(0.3, 0.9, 0.7, 1.0),
c1=(0, 0, 0, 0),
)
#GL.glDisable(GL.GL_BLEND)
except Exception, e:
print repr(e)
continue
GL.glDisable(GL.GL_DEPTH_TEST)
示例5: ChunkTool
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
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)
#.........这里部分代码省略.........
示例6: ChunkTool
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
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:
#.........这里部分代码省略.........
示例7: PlayerPositionTool
# 需要导入模块: from glutils import DisplayList [as 别名]
# 或者: from glutils.DisplayList import call [as 别名]
#.........这里部分代码省略.........
), 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)
GL.glEnable(GL.GL_DEPTH_TEST)
self.drawCharacterHead(x + 0.5, y + 0.75, z + 0.5, self.revPlayerPos[self.movingPlayer])
drawTerrainCuttingWire(BoundingBox((x, y, z), (1, 1, 1)))
drawTerrainCuttingWire(BoundingBox((x, y - 1, z), (1, 1, 1)))
#drawTerrainCuttingWire( BoundingBox((x,y-2,z), (1,1,1)) )
GL.glDisable(GL.GL_DEPTH_TEST)
markerLevel = None
def drawToolMarkers(self):
if self.markerLevel != self.editor.level:
self.markerList.invalidate()
self.markerLevel = self.editor.level
self.markerList.call(self._drawToolMarkers)
def _drawToolMarkers(self):
GL.glColor(1.0, 1.0, 1.0, 0.5)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glMatrixMode(GL.GL_MODELVIEW)
for player in self.editor.level.players:
try:
pos = self.editor.level.getPlayerPosition(player)
yaw, pitch = self.editor.level.getPlayerOrientation(player)
dim = self.editor.level.getPlayerDimension(player)
if dim != self.editor.level.dimNo:
continue
self.playerPos[pos] = player
self.revPlayerPos[player] = pos
if player != "Player":
self.playerTexture[player] = loadPNGTexture(version_utils.getPlayerSkin(player, force=False))
x, y, z = pos
GL.glPushMatrix()
GL.glTranslate(x, y, z)
GL.glRotate(-yaw, 0, 1, 0)
GL.glRotate(pitch, 1, 0, 0)
GL.glColor(1, 1, 1, 1)
self.drawCharacterHead(0, 0, 0, (x,y,z))
GL.glPopMatrix()
# GL.glEnable(GL.GL_BLEND)
drawTerrainCuttingWire(FloatBox((x - .5, y - .5, z - .5), (1, 1, 1)),
c0=(0.3, 0.9, 0.7, 1.0),
c1=(0, 0, 0, 0),
)
#GL.glDisable(GL.GL_BLEND)
except Exception, e:
print repr(e)
continue
GL.glDisable(GL.GL_DEPTH_TEST)