本文整理汇总了Python中Scene.Scene.render方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.render方法的具体用法?Python Scene.render怎么用?Python Scene.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene.Scene
的用法示例。
在下文中一共展示了Scene.render方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import render [as 别名]
def render(self, visibility, topMost):
if self.gameStarted:
return
if self.items == []:
return
Scene.render(self, visibility, topMost)
self.engine.view.setOrthogonalProjection(normalize = True)
self.engine.view.setViewport(1,0)
w, h = self.engine.view.geometry[2:4]
if self.img_background:
self.engine.drawImage(self.img_background, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = 3)
try:
if self.mode == 0:
self.renderSetlist(visibility, topMost)
if self.moreInfoTime > 0:
self.engine.theme.setlist.renderMoreInfo(self)
if self.miniLobbyTime > 0:
self.engine.theme.setlist.renderMiniLobby(self)
# I am unsure how I want to handle this for now. Perhaps as dialogs, perhaps in SCS.
elif self.mode == 1:
self.renderSpeedSelect(visibility, topMost)
elif self.mode == 2:
self.renderTimeSelect(visibility, topMost)
finally:
self.engine.view.resetProjection()
示例2: setUp
# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import render [as 别名]
def setUp(self):
'''
Create a scene with a camera placed at [0, 0, 4] and looking at the
world origin.
'''
scene = Scene()
self.scene = scene
#Camera
camera = Camera({'from':np.array([1.,4.,-2.]),
'to':np.array([1.,-2.,4]),
'up':GT.normalize(np.array([-1.,1.,0.])),
'fov':45,
'width':10001, 'height':10001}) # choose very high dimension to avoid rounding error
render = Render({'camera':camera})
scene.render = render
示例3: Simulation
# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import render [as 别名]
class Simulation(object):
def __init__(self, width, height):
# create pyglet window
self.window = pyglet.window.Window(resizable=True)
self.window.on_draw = self.on_draw
self.window.on_key_press = self.on_key_press
self.window.on_key_release = self.on_key_release
self.window.on_mouse_press = self.on_mouse_press
self.window.on_mouse_release = self.on_mouse_release
self.window.on_mouse_drag = self.on_mouse_drag
self.window.width = width
self.window.height = height
self.menu_window = False
self.gen_entity = 'SQUARE'
self.gen_size = 50
self.gen_mass = 500
self.key_pressed = []
self.clicked_object = None
self.clicked_dx = 0
self.clicked_dy = 0
# create fps display
self.fps_display = pyglet.clock.ClockDisplay()
self.clock = 0
# sync clock
pyglet.clock.schedule_interval(self.tick, 1.0/60.0)
pyglet.clock.set_fps_limit(60)
# create world
world_width = 3000
world_height = 3000
self.world = World(world_width, world_height)
# create scene- match dimensions of the app window
self.scene = Scene(width=width, height=height, background_width=world_width, background_height=world_height)
#self.demo_1(world_width, world_height)
#self.demo_2(world_width, world_height)
#self.demo_3(world_width, world_height)
# initialize background music
self.music = Music()
self.music.play_bg()
# Making the player here (testing)
mag = 40000
offset = 400
player_type = Triangle(size=20, position=Vector2(x=offset, y=offset))
self.scene.entities.append(player_type)
self.player = Player(entity=player_type, mass=100)
self.world.add_body(self.player)
def tick(self, dt):
# update physics
self.world.update(dt)
self.player.translate(dt, self.key_pressed)
# move scene
if key.LEFT in self.key_pressed:
self.scene.translate_x(-10)
if key.RIGHT in self.key_pressed:
self.scene.translate_x(10)
if key.UP in self.key_pressed:
self.scene.translate_y(-10)
if key.DOWN in self.key_pressed:
self.scene.translate_y(10)
if key.M in self.key_pressed:
self.music.pause_bg()
self.key_pressed.remove(key.M)
self.clock += 1
def on_draw(self):
# clear window
self.window.clear()
# redraw scene
self.scene.render()
# draw fps clock
self.fps_display.draw()
self.player.draw(self.scene)
# draw foreground/ui ? in here or scene
def on_key_press(self, symbol, modifiers):
if symbol == key.ESCAPE:
if not self.menu_window:
# self.tick, self.tick_stub = self.tick_stub, self.tick
pyglet.clock.unschedule(self.tick)
self.menu_window = True
self.menu_window = Menu(self, width=500, height=500)
return pyglet.event.EVENT_HANDLED
else:
self.key_pressed.append(symbol)
def on_key_release(self, symbol, modifiers):
if symbol in self.key_pressed:
self.key_pressed.remove(symbol)
#.........这里部分代码省略.........
示例4: App
# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import render [as 别名]
class App(object):
def __init__(self):
self.render_asap = False;
self.app_should_exit = False
self.root = Tk()
self.scene = None
self.lastUpdateMoment = 0
self.renderingTechniq = RENDER_ON_MAINLOOP
def setAppExit(self):
self.app_should_exit = TRUE
def initialize(self):
speller = GazeSpeller()
tracker = self._ckeckAvailableTracker()
canvas = self._initializeCanvas()
if isinstance(tracker,MouseTracker):
canvas.bind('<Motion>',tracker.onMotion) # use this to let the tracker get updates from the mouse event without actual get knowledge of the GUIs
# it's named "inversion of control"
self.scene = Scene(canvas, tracker, speller)
self.scene.initialize(1)
def startRendering(self):
if self.renderingTechniq == RENDER_ON_MAINLOOP:
self.runOnTkInterMainLoop()
if self.renderingTechniq == RENDER_ON_TIMER_TICK:
self.runOnExpectedFixedFramerate()
sys.exit(0)
def _ckeckAvailableTracker(self):
#TODO check if tracker available if not use mouse
return MouseTracker(self.root)
def _initializeCanvas(self):
self.root.attributes("-fullscreen", True)
self.root.protocol("WM_DELETE_WINDOW", self.setAppExit)
canvas = Canvas(self.root)
canvas.pack(fill=BOTH, expand=YES)
return canvas
def _processRenderLoop(self, deltaTime, CallTkUpdates = False):
self.scene.update(deltaTime)
self.scene.render()
if CallTkUpdates:
self.root.update_idletasks() # render / drawing
self.root.update() # perform processing of key events etc
def _estimateFrameTime(self):
currentMoment = time()
deltaTime = currentMoment - self.lastUpdateMoment
self.lastUpdateMoment = currentMoment
return deltaTime
# example rendering A
def runOnExpectedFixedFramerate(self):
self.lastUpdateMoment = time()
while not self.app_should_exit:
deltaTime = self._estimateFrameTime()
self._processRenderLoop(deltaTime, CallTkUpdates = True)
if not self.render_asap:
sleep(self.scene.getExpectedUpdateTime())
#example rendering B
def runOnTkInterMainLoop(self):
self._callUpdatingOnAfterCall();
self.root.mainloop()
def _callUpdatingOnAfterCall(self):
deltaTime = self._estimateFrameTime()
self._processRenderLoop(deltaTime)
# uses a scheduler from tkinter GUI Mainloop - test
# self.scene.getExpectedUpdateTime()
self.root.after(1, self._callUpdatingOnAfterCall)