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


Python Frame.rotate方法代码示例

本文整理汇总了Python中frame.Frame.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.rotate方法的具体用法?Python Frame.rotate怎么用?Python Frame.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frame.Frame的用法示例。


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

示例1: main

# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import rotate [as 别名]
def main():
    global window, time, light, inc, whichTex, frame, fogEnd
    pygame.init()
    screen = pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF)#|FULLSCREEN)
    pygame.display.set_caption('The Jade Palace')

    screentoggle = False
    clock = pygame.time.Clock()
    time = 0.0
    light = N.array((10,10,10,0), dtype = N.float32)
    inc = 0.05
    whichTex = 0
    init()
    frame = Frame()
    fogEnd = 150.0
    while True:     
        for event in pygame.event.get():
            if event.type == QUIT:
                return
            if event.type == KEYUP and event.key == K_ESCAPE:
                return
            if event.type == KEYDOWN:
                if event.key == K_s:
                    if inc == 0.0:
                        inc = 0.2
                    else:
                        inc = 0.0

        pressed = pygame.key.get_pressed()
        if pressed[K_UP]:
            frame.move(0.25)
        if pressed[K_DOWN]:
            frame.move(-0.25)
        if pressed[K_a]:
            frame.tilt(1.0)
        if pressed[K_z]:
            frame.tilt(-1.0)
        if pressed[K_LEFT]:
            if pressed[K_LSHIFT]:
                frame.strafe(0.25)
            else:
                frame.rotate(1.0)
        if pressed[K_RIGHT]:
            if pressed[K_LSHIFT]:
                frame.strafe(-0.25)
            else:
                frame.rotate(-1.0)
        if pressed[K_f]:
            fogEnd *= 1.1
        if pressed[K_v]:
            fogEnd *= 0.9
            
        clock.tick(30)
        time += inc
        display()
        pygame.display.flip()
开发者ID:chint4,项目名称:csci480,代码行数:58,代码来源:main.py

示例2: main

# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import rotate [as 别名]
def main():
    global theWorld
    pygame.init()
    screen = pygame.display.set_mode((800,800), OPENGL|DOUBLEBUF)
    
    frame = Frame()
    have_joystick = False
    if pygame.joystick.get_count() > 0:
        have_joystick = True
        autoRotation = False
        joystick = pygame.joystick.Joystick(0)
        joystick.init()       
        rot = 0
        fwd = 1
        stf = 2
        tlt = 3

    rotX, rotY, rotZ = 0.0,0.0,0.0
    rotXmatrix = numpy.eye(4, dtype=numpy.float32)
    rotYmatrix = numpy.eye(4, dtype=numpy.float32)
    rotZmatrix = numpy.eye(4, dtype=numpy.float32)
    
    clock = pygame.time.Clock()

    init()
    near = 1.0 
    far = 50.0 
    depth = 2.0
    while True:
        clock.tick(30)
        for event in pygame.event.get():
            if event.type == QUIT:
                return
            if event.type == KEYUP and event.key == K_ESCAPE:
                return
            if event.type == KEYDOWN:
                if event.key == K_SPACE:
                    n = theUniforms.items['showLines']
                    theUniforms.items['showLines'] = (n+1)%2
                if event.key == K_l:
                    if near < 2.0:
                        near = 19.0
                        far = 21.0
                    else:
                        near = 1.0
                        far = 50.0

            if have_joystick:
                if event.type == pygame.JOYBUTTONUP:
                    autoRotation = not(autoRotation)

        # Joystick polling:
        if have_joystick:
            factor = 1.0/30.0
            frame.move(-joy(joystick, fwd))
            frame.rotate(numpy.pi * -joy(joystick, rot))
            frame.strafe(joy(joystick, stf))
            frame.tilt(numpy.pi * joy(joystick, tlt))
            theWorld.Update('translationMatrix',
                             frame.translation)
            theWorld.Update('postRotationMatrix',
                             frame.rotation)
            if autoRotation:
                rotX += 0.005
                rotY += 0.005
                rotZ += 0.005

        # Keyboard polling:
        pressed = pygame.key.get_pressed()

        # observer movement:
        amt = 0.2
        if pressed[K_DOWN]:
            frame.elevate(amt)
        if pressed[K_UP]:
            frame.elevate(-amt)
        if pressed[K_LEFT]:
            frame.strafe(-amt)
        if pressed[K_RIGHT]:
            frame.strafe(amt)
        if pressed[K_PAGEUP]:
            frame.move(amt)
        if pressed[K_PAGEDOWN]:
            frame.move(-amt)
            
        theWorld.Update('translationMatrix', frame.translation)
        theWorld.Update('postRotationMatrix', frame.rotation)

        # world rotation:
        if pressed[K_q]:
            rotZ -= 0.02
        if pressed[K_e]:
            rotZ += 0.02
            
        setRotationZ(rotZmatrix, rotZ)
        mat = numpy.dot(rotYmatrix, rotZmatrix)
        mat = numpy.dot(rotXmatrix, mat)
                            
        theWorld.Update('preRotationMatrix', mat)

#.........这里部分代码省略.........
开发者ID:Zamooor,项目名称:VirtualMicroscope,代码行数:103,代码来源:Test_algae.py


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