• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python gl.glRotatef函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: transform

    def transform(self):
        """
        Apply ModelView transformations.

        You will most likely want to wrap calls to this function with
        ``glPushMatrix()``/``glPopMatrix()``
        """
        x, y = director.get_window_size()

        if not(self.grid and self.grid.active):
            # only apply the camera if the grid is not active
            # otherwise, the camera will be applied inside the grid
            self.camera.locate()

        gl.glTranslatef(self.position[0], self.position[1], 0)
        gl.glTranslatef(self.transform_anchor_x, self.transform_anchor_y, 0)

        if self.rotation != 0.0:
            gl.glRotatef(-self._rotation, 0, 0, 1)

        if self.scale != 1.0 or self.scale_x != 1.0 or self.scale_y != 1.0:
            gl.glScalef(self._scale * self._scale_x, self._scale * self._scale_y, 1)

        if self.transform_anchor != (0, 0):
            gl.glTranslatef(
                -self.transform_anchor_x,
                -self.transform_anchor_y,
                0)
开发者ID:1414648814,项目名称:cocos,代码行数:28,代码来源:cocosnode.py


示例2: paint

 def paint(self, peg):
     batch = self.get_batch()
     glPushMatrix()
     glTranslatef(peg.x, peg.y, 0)
     glRotatef(peg.angle, 0, 0, 1)
     batch.draw()
     glPopMatrix()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:shapes.py


示例3: draw

    def draw(self):
        self.loadStartPosition()
        gl.glRotatef(90.0, 0.0, 0.0, 1.0)
        gl.glBegin(gl.GL_QUADS)
        gl.glColor3f(1.0, 1.0, 0.0)
        tenth = math.pi * 2.0 / 10.0
        for z in [-0.1, 0.1]:
            for i in xrange(5):
                a = float(i) * tenth * 2.0
                gl.glVertex3f(0.0, 0.0, z)
                gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), z)
                gl.glVertex3f(math.cos(a), math.sin(a), z)
                gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), z)
        for i in xrange(5):
            a = float(i) * tenth * 2.0
            gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
            gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), -0.1)
            gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
            gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
            gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), -0.1)
        gl.glEnd()

        self.loadStartPosition()
        gl.glTranslatef(0.0, 0.0, 0.1)
        gl.glScalef(0.01, 0.01, 0.0)
        self.label.draw()

        gl.glLoadIdentity()
开发者ID:benatkin,项目名称:pyglet-stuff,代码行数:31,代码来源:goldstar.py


示例4: rotate

def rotate(p, state, kwargs):
    x, y = p.x, p.y
    xp = x + (p.width / 2)
    yp = y + (p.height / 2)
    gl.glTranslatef(xp, yp, 0)
    gl.glRotatef(kwargs['angle'], 0.0, 0.0, 1.0)
    gl.glTranslatef(-xp, -yp, 0)
开发者ID:lidavidm,项目名称:apheleia,代码行数:7,代码来源:transform.py


示例5: render_cylinder

    def render_cylinder(self, base_radius, height, slices, stacks,
                        top_radius=None):
        """ Generate the polygons for a cylinder

        :param base_radius: The radius of the bottom of the cylinder.
        :type base_radius: float
        :param height: The cylinder's height
        :type height: float
        :param slices: The number of longitudinal lines
        :type slices: int
        :param stacks: The number of latitudinal lines
        :type stacks: int
        :param top_radius: The radius of the top of the cylinder. If undefined,
         the top radius will be the same as the base radius
        :type top_radius: float
        """
        # rotate the cylinder so that it is drawn along the VPython axis
        # convention
        gl.glRotatef(90, 0, 1, 0)
        if top_radius is None:
            gl.glu.gluCylinder(self.quadric, base_radius, base_radius,
                               height, slices, stacks)
        else:
            gl.glu.gluCylinder(self.quadric, base_radius, top_radius,
                               height, slices, stacks)
        gl.glRotatef(-90, 0, 1, 0)
开发者ID:encukou,项目名称:pyglet_helper,代码行数:26,代码来源:quadric.py


示例6: draw_objects

    def draw_objects(self):
        '''called in the middle of ondraw after the buffer has been cleared'''
        self.create_objects()

        glPushMatrix()
        if self.orthographic:
            glTranslatef(0, 0, -3 * self.dist)  # Move back
        else:
            glTranslatef(0, 0, -self.dist)  # Move back
        # Rotate according to trackball
        glMultMatrixd(build_rotmatrix(self.basequat))
        # Move origin to bottom left of platform
        platformx0 = -self.build_dimensions[3] - self.parent.platform.width / 2
        platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
        glTranslatef(platformx0, platformy0, 0)

        for obj in self.parent.objects:
            if not obj.model \
               or not obj.model.loaded \
               or not obj.model.initialized:
                continue
            glPushMatrix()
            glTranslatef(*(obj.offsets))
            glTranslatef(*(obj.centeroffset))
            glRotatef(obj.rot, 0.0, 0.0, 1.0)
            glScalef(*obj.scale)

            obj.model.display()
            glPopMatrix()
        glPopMatrix()
开发者ID:faustreg,项目名称:Printrun,代码行数:30,代码来源:gcview.py


示例7: draw_ents

 def draw_ents(self, ents):
     for ent in ents:
         glPushMatrix()
         glTranslatef(ent.body.position.x, ent.body.position.y, 0)
         glRotatef(ent.body.angle * 180 / pi, 0, 0, 1)
         ent.batch.draw()
         glPopMatrix()
开发者ID:tartley,项目名称:sole-scion,代码行数:7,代码来源:renderer.py


示例8: draw_objects

    def draw_objects(self):
        '''called in the middle of ondraw after the buffer has been cleared'''
        self.create_objects()

        glPushMatrix()
        # Rotate according to trackball
        glMultMatrixd(build_rotmatrix(self.basequat))
        # Move origin to bottom left of platform
        platformx0 = -self.build_dimensions[3] - self.parent.platform.width / 2
        platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
        glTranslatef(platformx0, platformy0, 0)

        light_z = max(self.parent.platform.width, self.parent.platform.depth)
        glLightfv(GL_LIGHT0, GL_POSITION, vec(0,
                                              self.parent.platform.depth / 2,
                                              light_z, 0))
        glLightfv(GL_LIGHT1, GL_POSITION, vec(self.parent.platform.width,
                                              self.parent.platform.depth / 2,
                                              light_z, 0))

        for obj in self.parent.objects:
            if not obj.model \
               or not obj.model.loaded \
               or not obj.model.initialized:
                continue
            glPushMatrix()
            glTranslatef(*(obj.offsets))
            glTranslatef(*(obj.centeroffset))
            glRotatef(obj.rot, 0.0, 0.0, 1.0)
            glScalef(*obj.scale)

            obj.model.display()
            glPopMatrix()
        glPopMatrix()
开发者ID:brodykenrick,项目名称:Printrun,代码行数:34,代码来源:gcview.py


示例9: render

    def render(self):
        gl.glPushMatrix()

        gl.glTranslatef(self.x + self.width / 2, self.y + self.height / 2, 0)
        gl.glRotatef(self.angle, 0, 0, 1)
        gl.glTranslatef(-self.x - self.width / 2, -self.y - self.height / 2, 0)

        self.batch.draw()

        gl.glPopMatrix()

        gl.glPushMatrix()

        cx, cy, cw, ch = cannon_rects[0]

        gl.glTranslatef(self.x + cx + cw / 2, self.y + cy + ch / 2, 0)
        gl.glRotatef(self.cannon_angle - 90, 0, 0, 1)
        gl.glTranslatef(-self.x - cx - cw / 2, -self.y - cy, 0)

        self.cannon_batch.draw()

        gl.glPopMatrix()

        self.batch = pyglet.graphics.Batch()
        self.cannon_batch = pyglet.graphics.Batch()
开发者ID:anden3,项目名称:Python,代码行数:25,代码来源:Tanks.py


示例10: rotate

 def rotate(self,ang,rx,ry,rz):
     glPushMatrix()
     glLoadIdentity()
     glRotatef(ang,rx,ry,rz)
     glMultMatrixf(self.matrix)
     self.matrix=get_model_matrix()
     glPopMatrix()
开发者ID:fos,项目名称:fos-legacy,代码行数:7,代码来源:camera.py


示例11: set_3d

    def set_3d(self):
        """ Configure OpenGL to draw in 3d.

        """
        width, height = self.get_size()

        gl.glEnable(gl.GL_DEPTH_TEST)

        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.gluPerspective(65.0, width / float(height), 0.1, DIST)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        x, y = self.rotation
        gl.glRotatef(x, 0, 1, 0)
        gl.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
        x, y, z = self.position
        gl.glTranslatef(-x, -y, -z)

        gl.glEnable(gl.GL_LIGHTING)
        gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, GLfloat4(0.05,0.05,0.05,1.0))
        gl.glEnable(gl.GL_COLOR_MATERIAL)
        gl.glColorMaterial(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE)
        #gl.glLightfv(gl.GL_LIGHT1,gl.GL_SPOT_DIRECTION, GLfloat3(0,0,-1))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, GLfloat4(0.5,0.5,0.5,1.0))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, GLfloat4(1.0,1.0,1.0,1.0))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, GLfloat4(0.35,1.0,0.65,0.0))
        #gl.glLightfv(gl.GL_LIGHT0,gl.GL_SPECULAR, GLfloat4(1,1,1,1))
        gl.glDisable(gl.GL_LIGHT0)
        gl.glEnable(gl.GL_LIGHT1)
开发者ID:spillz,项目名称:minepy,代码行数:32,代码来源:main.py


示例12: drawSpace

    def drawSpace(self, window):

        gl.glPushMatrix()

        # GL matrices are applied last-added-first, so this *is* the right
        # order for pushing them.
        gl.glTranslatef(-self.viewportOrigin[0], -self.viewportOrigin[1], 0.0)

        if self.shake is not None:
            # We want to rotate around the center of the current viewport
            # vpc = view port center
            vpc_x = self.viewportOrigin[0] + self.windowProps.windowWidth//2
            vpc_y = self.viewportOrigin[1] + self.windowProps.windowHeight//2
            
            gl.glTranslatef(vpc_x, vpc_y, 0.0)
            gl.glRotatef(self.shake.getAngle(), 0, 0, 1)
            gl.glTranslatef(-vpc_x, -vpc_y, 0.0)
        
        ge = self.gameElements

        ge.starField.draw()
        ge.swarm.draw()

        if not self.explodedMarker.done():
            ge.ship.draw()

        if self.endGame and not self.drawFrameMarker.done():
            self.endGame.draw(window)

        for shot in ge.shots:
            if shot.alive:
                shot.draw()
        
        gl.glPopMatrix()
开发者ID:sergio-py2,项目名称:meteor,代码行数:34,代码来源:gamephase.py


示例13: rotate

def rotate(f,
           angle,
           x=0.0, y=0.0, z=1.0):
    push()
    gl.glRotatef(angle * 180 / pi,
                 x, y, z)
    f()
    pop()
开发者ID:dsqmoore,项目名称:pineal,代码行数:8,代码来源:effects.py


示例14: on_draw

 def on_draw():
     window.clear()
     gl.glLoadIdentity()
     gl.gluLookAt(0, 8, 8, 0, 0, 0, 0, 1, 0)
     gl.glRotatef(rot, 1, 0, 0)
     gl.glRotatef(rot/2, 0, 1, 0)
     batch.draw()
     gl.glFinish()
开发者ID:pennomi,项目名称:banneret,代码行数:8,代码来源:obj_batch.py


示例15: draw

 def draw(self):
     glPushMatrix()
     glRotatef(self.angle, 0., 0., 1.)
     glScalef(self.scale, 1., 1.)
     glTranslatef(0., -common_res.ray.height/2, 0.)
     glColor4f(1., 1., 1., self.alpha)
     common_res.ray.blit(0, 0)
     glPopMatrix()
开发者ID:AojiaoZero,项目名称:thbattle,代码行数:8,代码来源:game_controls.py


示例16: draw

 def draw(self, scale=1):
     gl.glPushMatrix()
     gl.glEnable(gl.GL_TEXTURE_2D)
     gl.glTranslatef(*self.position)
     gl.glRotatef(self.angle, 0, 0, 1)
     gl.glScalef(scale, scale, scale)
     self.batch.draw()
     gl.glPopMatrix()
开发者ID:pennomi,项目名称:banneret,代码行数:8,代码来源:pieces.py


示例17: paint

 def paint(self):
     if self.batch is None:
         self.get_batch()
     glPushMatrix()
     glTranslatef(self.peg.x, self.peg.y, self.peg.z)
     glRotatef(self.peg.angle, 0, 0, 1)
     self.batch.draw()
     glPopMatrix()
     print'.',
开发者ID:msarch,项目名称:py,代码行数:9,代码来源:shapes.py


示例18: draw_at

 def draw_at(self, x, y):
     draw.set_color(1,1,1,1)
     for unit in self.units:
         ix, iy = x-unit.offset[1], y+unit.offset[0]
         gl.glPushMatrix()
         gl.glTranslatef(ix,iy,0)
         gl.glRotatef(unit.local_angle-90,0,0,-1)
         unit.image.blit(0,0)
         gl.glPopMatrix()
开发者ID:irskep,项目名称:Gluball,代码行数:9,代码来源:body.py


示例19: draw

    def draw(self, win=None):
        
        #set the window to draw to
        if win==None: win=self.win
        if win.winType=='pyglet': win.winHandle.switch_to()
        
        #work out next default depth
        if self.depth==0:
            thisDepth = self.win._defDepth
            self.win._defDepth += _depthIncrements[self.win.winType]
        else:
            thisDepth=self.depth

        GL.glPushMatrix()

        #scale and rotate
        prevScale = self.win.setScale(self._winScale)
        GL.glTranslatef(self._posRendered[0],self._posRendered[1],thisDepth)#NB depth is set already
        GL.glRotatef(self.ori,0.0,0.0,1.0)
        self.win.setScale('pix',None, prevScale)
        
        if self._useShaders: #then rgb needs to be set as glColor
            #setup color
            desiredRGB = (self.rgb*self.contrast+1)/2.0#RGB in range 0:1 and scaled for contrast
            if numpy.any(desiredRGB**2.0>1.0):
                desiredRGB=[0.6,0.6,0.4]
            GL.glColor4f(desiredRGB[0],desiredRGB[1],desiredRGB[2], self.opacity)
        else: #color is set in texture, so set glColor to white
            GL.glColor4f(1,1,1,1)

        GL.glDisable(GL.GL_DEPTH_TEST) #should text have a depth or just on top?
        #update list if necss and then call it
        if self.win.winType=='pyglet':
            
            #and align based on x anchor
            if self.alignHoriz=='right':
                GL.glTranslatef(-self.width,0,0)#NB depth is set already
            if self.alignHoriz in ['center', 'centre']:
                GL.glTranslatef(-self.width/2,0,0)#NB depth is set already
                
            #unbind the mask texture regardless
            GL.glActiveTexture(GL.GL_TEXTURE1)
            GL.glEnable(GL.GL_TEXTURE_2D)
            GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
            #unbind the main texture
            GL.glActiveTexture(GL.GL_TEXTURE0)
            GL.glEnable(GL.GL_TEXTURE_2D)
            #then allow pyglet to bind and use texture during drawing
            
            self.glyphStr.draw()            
            GL.glDisable(GL.GL_TEXTURE_2D) 
        else: 
            #for pygame we should (and can) use a drawing list   
            if self.needUpdate: self._updateList()
            GL.glCallList(self._listID)
        GL.glEnable(GL.GL_DEPTH_TEST)                   # Enables Depth Testing
        GL.glPopMatrix()
开发者ID:RSharman,项目名称:psychopy,代码行数:57,代码来源:slowText.py


示例20: zoomAndRotate

	def zoomAndRotate(self):
		"""Performs zooming and rotation. Suggested to use with pan during displazing the scene:
		1.cam.zoomAndRotate()
		2.cam.pan()
		3.draw(some 3D objects)
		"""
		glTranslatef(0, 0, -self.radius)
		glRotatef(self.psi - 90, 1, 0, 0)
		glRotatef(self.fi, 0, 0, 1)
开发者ID:Ryu-CZ,项目名称:pyglet-lidar-viewer,代码行数:9,代码来源:controls.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glScalef函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glPushMatrix函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap