本文整理汇总了Python中Camera.Camera.set_mode方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.set_mode方法的具体用法?Python Camera.set_mode怎么用?Python Camera.set_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.set_mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LivePlot
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import set_mode [as 别名]
#.........这里部分代码省略.........
glPointSize(10)
glDisable(GL_DEPTH_TEST)
self.batch.draw()
self.camera.postrender()
def render_2d(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
w,h = self.get_size()
glOrtho(0, w, 0, h, -1.0, 2.0)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
## Draw Text
glDisable(GL_DEPTH_TEST)
self.fps_display.draw()
self.camera_mode_display.draw()
glEnable(GL_DEPTH_TEST)
glPopMatrix()
glMatrixMode(GL_PROJECTION)
glPopMatrix()
## Events -----------------------------------------------------------------
## Input events
def on_key_press(self, symbol, modifiers):
pass
def on_key_release(self, symbol, modifiers):
if symbol == key.ESCAPE:
self.close()
elif symbol == key.F:
if not self.fullscreen:
pos = self.get_location()
screens = pyglet.window.get_platform().get_default_display().get_screens()
for s in screens:
if pos[0] >= s.x and \
pos[0] < s.x + s.width and \
pos[1] >= s.y and \
pos[1] < s.y + s.height:
screen = s
break
self.set_fullscreen(True, screen)
else:
self.set_fullscreen(False)
elif symbol == key._1:
self.camera.set_mode(Camera.FREE)
self.set_exclusive_mouse(True)
elif symbol == key._2:
self.camera.set_mode(Camera.FOLLOW)
self.set_exclusive_mouse(False)
elif symbol == key._3:
self.camera.set_mode(Camera.XY)
self.set_exclusive_mouse(False)
elif symbol == key._4:
self.camera.set_mode(Camera.FIXED)
self.set_exclusive_mouse(False)
elif symbol == key.SPACE:
self.camera.next_view()
def on_mouse_motion(self, x, y, dx, dy):
self.camera.rotate(-dx/700, dy/700)
## Window events
def on_resize(self, width, height):
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
fov = 50
aspect = width / height
if width < height:
fov = 360/math.pi * math.atan(math.tan(fov * math.pi/360) / aspect)
gluPerspective(fov, aspect, 0.1, 200000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
# Update text labels
self.camera_mode_display.x = width - 5
return pyglet.event.EVENT_HANDLED
def on_draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
self.render()
self.render_2d()