本文整理汇总了Python中frame.Frame.elevate方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.elevate方法的具体用法?Python Frame.elevate怎么用?Python Frame.elevate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frame.Frame
的用法示例。
在下文中一共展示了Frame.elevate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import elevate [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)
#.........这里部分代码省略.........