當前位置: 首頁>>代碼示例>>Python>>正文


Python GL.glTranslate方法代碼示例

本文整理匯總了Python中OpenGL.GL.glTranslate方法的典型用法代碼示例。如果您正苦於以下問題:Python GL.glTranslate方法的具體用法?Python GL.glTranslate怎麽用?Python GL.glTranslate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenGL.GL的用法示例。


在下文中一共展示了GL.glTranslate方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: drawArrays

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def drawArrays(self, chunkPosition, showRedraw):
        cx, cz = chunkPosition
        y = 0
        if hasattr(self, 'y'):
            y = self.y
        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glTranslate(cx << 4, y, cz << 4)

            if showRedraw:
                GL.glColor(1.0, 0.25, 0.25, 1.0)

            self.drawVertices() 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:14,代碼來源:renderer.py

示例2: drawCeiling

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def drawCeiling(self):
        GL.glMatrixMode(GL.GL_MODELVIEW)
        # GL.glPushMatrix()
        x, y, z = self.cameraPosition
        x -= x % 16
        z -= z % 16
        y = self.editor.level.Height
        GL.glTranslate(x, y, z)
        self.ceilingList.call(self._drawCeiling)
        GL.glTranslate(-x, -y, -z) 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:12,代碼來源:camera.py

示例3: setup_modelview

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def setup_modelview(self):
        x, y, z = self.cameraPosition

        GL.glRotate(90.0, 1.0, 0.0, 0.0)
        GL.glTranslate(-x, 0, -z) 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:7,代碼來源:chunk.py

示例4: drawArrays

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def drawArrays(self, chunkPosition, showRedraw):
        cx, cz = chunkPosition
        y = getattr(self, "y", 0)
        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glTranslate(cx << 4, y, cz << 4)

            if showRedraw:
                GL.glColor(1.0, 0.25, 0.25, 1.0)

            self.drawVertices() 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:12,代碼來源:renderer.py

示例5: paintGL

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def paintGL(self, p, opt, widget):
        p.beginNativePainting()
        import OpenGL.GL as gl
        
        ## set clipping viewport
        view = self.getViewBox()
        if view is not None:
            rect = view.mapRectToItem(self, view.boundingRect())
            #gl.glViewport(int(rect.x()), int(rect.y()), int(rect.width()), int(rect.height()))
            
            #gl.glTranslate(-rect.x(), -rect.y(), 0)
            
            gl.glEnable(gl.GL_STENCIL_TEST)
            gl.glColorMask(gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE) # disable drawing to frame buffer
            gl.glDepthMask(gl.GL_FALSE)  # disable drawing to depth buffer
            gl.glStencilFunc(gl.GL_NEVER, 1, 0xFF)  
            gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)  
            
            ## draw stencil pattern
            gl.glStencilMask(0xFF)
            gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
            gl.glBegin(gl.GL_TRIANGLES)
            gl.glVertex2f(rect.x(), rect.y())
            gl.glVertex2f(rect.x()+rect.width(), rect.y())
            gl.glVertex2f(rect.x(), rect.y()+rect.height())
            gl.glVertex2f(rect.x()+rect.width(), rect.y()+rect.height())
            gl.glVertex2f(rect.x()+rect.width(), rect.y())
            gl.glVertex2f(rect.x(), rect.y()+rect.height())
            gl.glEnd()
                       
            gl.glColorMask(gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE)
            gl.glDepthMask(gl.GL_TRUE)
            gl.glStencilMask(0x00)
            gl.glStencilFunc(gl.GL_EQUAL, 1, 0xFF)
            
        try:
            x, y = self.getData()
            pos = np.empty((len(x), 2))
            pos[:,0] = x
            pos[:,1] = y
            gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
            try:
                gl.glVertexPointerf(pos)
                pen = fn.mkPen(self.opts['pen'])
                color = pen.color()
                gl.glColor4f(color.red()/255., color.green()/255., color.blue()/255., color.alpha()/255.)
                width = pen.width()
                if pen.isCosmetic() and width < 1:
                    width = 1
                gl.glPointSize(width)
                gl.glEnable(gl.GL_LINE_SMOOTH)
                gl.glEnable(gl.GL_BLEND)
                gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
                gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
                gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
            finally:
                gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        finally:
            p.endNativePainting() 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:61,代碼來源:PlotCurveItem.py

示例6: draw

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def draw(self):
        self.needsRedraw = False
        if not self.level:
            return
        if not self.chunkCalculator:
            return
        if not self.render:
            return

        if self.level.materials.name in ("Pocket", "Alpha"):
            GL.glMatrixMode(GL.GL_TEXTURE)
            GL.glScalef(1 / 2., 1 / 2., 1 / 2.)

        with gl.glPushMatrix(GL.GL_MODELVIEW):
            dx, dy, dz = self.origin
            GL.glTranslate(dx, dy, dz)

            GL.glEnable(GL.GL_CULL_FACE)
            GL.glEnable(GL.GL_DEPTH_TEST)

            self.level.materials.terrainTexture.bind()
            GL.glEnable(GL.GL_TEXTURE_2D)
            GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)

            offset = DepthOffset.PreviewRenderer if self.isPreviewer else DepthOffset.Renderer
            GL.glPolygonOffset(offset, offset)
            GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)

            self.createMasterLists()
            try:
                self.callMasterLists()

            except GL.GLError, e:
                if self.errorLimit:
                    self.errorLimit -= 1
                    traceback.print_exc()
                    print e

            GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
                
            GL.glDisable(GL.GL_CULL_FACE)
            GL.glDisable(GL.GL_DEPTH_TEST)

            GL.glDisable(GL.GL_TEXTURE_2D)
            GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
            # if self.drawLighting:
            self.drawLoadableChunkMarkers() 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:49,代碼來源:renderer.py

示例7: _drawToolMarkers

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
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():
                    self.playerTexture[player] = loadPNGTexture(self.playercache.getPlayerSkin(player, force_download=False))
                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 repr(e)
                continue 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:44,代碼來源:player.py

示例8: draw

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
def draw(self):
        self.needsRedraw = False
        if not self.level:
            return
        if not self.chunkCalculator:
            return
        if not self.render:
            return

        if self.level.materials.name in ("Pocket", "Alpha"):
            GL.glMatrixMode(GL.GL_TEXTURE)
            GL.glScalef(1 / 2., 1 / 2., 1 / 2.)

        with gl.glPushMatrix(GL.GL_MODELVIEW):
            dx, dy, dz = self.origin
            GL.glTranslate(dx, dy, dz)

            GL.glEnable(GL.GL_CULL_FACE)
            GL.glEnable(GL.GL_DEPTH_TEST)

            self.level.materials.terrainTexture.bind()
            GL.glEnable(GL.GL_TEXTURE_2D)
            GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)

            offset = DepthOffset.PreviewRenderer if self.isPreviewer else DepthOffset.Renderer
            GL.glPolygonOffset(offset, offset)
            GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)

            self.createMasterLists()
            try:
                self.callMasterLists()

            except GL.GLError as e:
                if self.errorLimit:
                    self.errorLimit -= 1
                    traceback.print_exc()
                    print e

            GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
                
            GL.glDisable(GL.GL_CULL_FACE)
            GL.glDisable(GL.GL_DEPTH_TEST)

            GL.glDisable(GL.GL_TEXTURE_2D)
            GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
            self.drawLoadableChunkMarkers()

        if self.level.materials.name in ("Pocket", "Alpha"):
            GL.glMatrixMode(GL.GL_TEXTURE)
            GL.glScalef(2., 2., 2.) 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:52,代碼來源:renderer.py

示例9: _drawToolMarkers

# 需要導入模塊: from OpenGL import GL [as 別名]
# 或者: from OpenGL.GL import glTranslate [as 別名]
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 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:50,代碼來源:player.py


注:本文中的OpenGL.GL.glTranslate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。