本文整理汇总了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()
示例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)
#.........这里部分代码省略.........