def __init__(self): ShowBase.__init__(self) self.decisions = [] self.isReady = False self.red = 0 self.messageNode = TextNode("Message") self.choiceOneNode = TextNode("ChoiceOne") self.choiceTwoNode = TextNode("ChoiceTwo") self.instructionsNode = TextNode("Instructions") self.messageNode.setText('"Antigone, stop screaming!"') self.choiceOneNode.setText("[stop]") self.choiceTwoNode.setText("[scream louder]") self.instructionsNode.setText("Use the arrow keys to make a choice.") base.setBackgroundColor(self.red, 0, 0) base.disableMouse() props = WindowProperties() props.setTitle("Antigo Me") base.win.requestProperties(props) self.textDisplay() self.showText() self.isReady = True self.accept("arrow_left", self.decision, [0]) self.accept("arrow_right", self.decision, [1])
def activate(self, position = Vec3(5.0, 5.0, 5.0)): print "Activating FreeLook Camera" # No moar cursor! wp = WindowProperties() wp.setCursorHidden(True) # does not exist panda 1.3.2 / but is reqired for osx-mouse movement try: wp.setMouseMode(WindowProperties.MAbsolute) except: pass base.win.requestProperties(wp) # initialize camera base.camLens.setFov(70) # field of view base.camera.reparentTo(base.render) # attach it to the render ## set position base.camera.setPos(position) base.camera.setR(0) # initialize mouse controls ## walking and stopping if input is lost self.accept("s" , self.set_walk, [self.BACK]) self.accept("s-up" , self.set_walk, [self.STOP]) self.accept("w" , self.set_walk, [self.FORWARD]) self.accept("w-up" , self.set_walk, [self.STOP]) self.accept("d" , self.set_strafe, [self.RIGHT]) self.accept("d-up" , self.set_strafe, [self.STOP]) self.accept("a" , self.set_strafe, [self.LEFT]) self.accept("a-up" , self.set_strafe, [self.STOP]) # initialize camera task base.taskMgr.add(self.update, "update_camera_task")
def resize_panda_window(self, widget, request): props = WindowProperties().getDefault() props = WindowProperties(self.base.win.getProperties()) props.setOrigin(0, 0) props.setSize(request.width, request.height) props.setParentWindow(widget.window.xid) self.base.win.requestProperties(props)
def focus(self, window_id=None): """Bring Panda3d to foreground, so that it gets keyboard focus. Also send a message to wx, so that it doesn't render a widget focused. We also need to say wx that Panda now has focus, so that it can notice when to take focus back. If window_id is given, that window will be focused, otherwise the one the pointer hovers upon. If the pointer doesn't hover over a window, a random window is taken. If there is no window, this function does nothing. """ if window_id is None: window_id = self.getWindowUnderPointer() if window_id is None: for win in self.windows.values(): window_id = win break if window_id is None: return wp = WindowProperties() wp.setForeground(True) self.windows[window_id].requestProperties(wp) # We request focus (and probably already have keyboard focus), so make wx # set it officially. This prevents other widgets from being rendered focused. self.messageclient.unicast(self.name + " gui", FocusWindowRequest(window_id))
def absolute(self): props = WindowProperties() props.setMouseMode(WindowProperties.M_absolute) base.win.requestProperties(props) if self.relative_requested: self.relative_requested = False
def __init__(self): ShowBase.__init__(self) self.disableMouse() props = WindowProperties() props.setTitle('Test') self.win.requestProperties(props) # self.render.setAntiAlias(AntialiasAttrib.MAuto) self.transitions = Transitions(self.loader) self.transitions.setFadeColor(0, 0, 0) self.filters = CommonFilters(self.win, self.cam) # self.filters.setCartoonInk() self.filters.setBlurSharpen(1) # self.filters.setVolumetricLighting(self.render) # self.buffer = self.win.makeTextureBuffer("Post-processing buffer", self.win.getXSize(), self.win.getXSize()) # print self.buffer.getYSize() # self.texture = self.buffer.getTexture() # self.buffer.setSort(-100) # # self.originalCamera = self.camera # self.offScreenCamera = self.makeCamera(self.buffer) # self.camera = self.offScreenCamera # # self.img = OnscreenImage(image=self.texture, pos=(0, 0, 0.5)) self.scene = None self.channel = Channel()
def __init__(self): base.disableMouse() self.keyMap = {"FORWARD":0, "BACK":0, "RIGHT":0, "LEFT":0, "Mouse3":0, "LSHIFT":0, "UPWARDS":0, "DOWNWARDS":0} self.accept("w", self.setKey, ["FORWARD",1]) self.accept("w-up", self.setKey, ["FORWARD",0]) self.accept("s", self.setKey, ["BACK",1]) self.accept("s-up", self.setKey, ["BACK",0]) self.accept("d", self.setKey, ["RIGHT",1]) self.accept("d-up", self.setKey, ["RIGHT",0]) self.accept("a", self.setKey, ["LEFT",1]) self.accept("a-up", self.setKey, ["LEFT",0]) self.accept("q", self.setKey, ["UPWARDS",1]) self.accept("q-up", self.setKey, ["UPWARDS",0]) self.accept("e", self.setKey, ["DOWNWARDS",1]) self.accept("e-up", self.setKey, ["DOWNWARDS",0]) self.accept("mouse3", self.setKey, ["Mouse3",1]) self.accept("mouse3-up", self.setKey, ["Mouse3",0]) self.accept("lshift", self.setKey, ["LSHIFT",1]) self.accept("lshift-up", self.setKey, ["LSHIFT",0]) self.accept("wheel_up", self.CamSpeed, [1.1]) self.accept("wheel_down", self.CamSpeed, [0.9]) self.SpeedCam = 0.1 # —корость перемещени¤ камеры self.SpeedRot = 0.05 # —корость врашени¤ камеры self.SpeedMult = 5 # ћножитель скорости камеры при нажатии lshift self.textSpeed = OnscreenText(pos = (0.9, -0.9), scale = 0.1) self.CursorOffOn = 'On' self.props = WindowProperties() taskMgr.add(self.CamControl, 'CamControl') #менеджер дл¤ запуска функции
def buildInGameMenu(self): props = WindowProperties() props.setCursorHidden(False) base.win.requestProperties(props) resume_button = DirectButton(text = "Resume", scale = .1, command = (lambda: self.switchGameMode(PLAY)), rolloverSound=None) main_menu_button = DirectButton(text = "Main Menu", scale = .1, command = self.b, rolloverSound=None) options_button = DirectButton(text = "Options", scale = .1, command = self.b, rolloverSound=None) exit_button = DirectButton(text = "Exit", scale = .1, command = exit, rolloverSound=None) BUTTON_SPACING = .2 BUTTON_HEIGHT = resume_button.getSy() button_positions = self.evenButtonPositions(BUTTON_SPACING, BUTTON_HEIGHT, 4) resume_button.setPos(Vec3(0, 0, button_positions[0])) main_menu_button.setPos(Vec3(0, 0, button_positions[1])) options_button.setPos(Vec3(0, 0, button_positions[2])) exit_button.setPos(Vec3(0, 0, button_positions[3])) self.gui_elements.append(resume_button) self.gui_elements.append(main_menu_button) self.gui_elements.append(options_button) self.gui_elements.append(exit_button)
def toggleMouseLook(): global _MOUSELOOK _MOUSELOOK = not _MOUSELOOK props = WindowProperties() props.setCursorHidden(_MOUSELOOK) base.win.requestProperties(props) return _MOUSELOOK
class Renderer(ShowBase): def __init__(self): super(Renderer, self).__init__() self.props = WindowProperties() self.props.setTitle( 'Simulation Viewer' ) self.GUI = MainGUI() base.win.requestProperties(self.props) def updateCoordinates(self, x, y): self.GUI.coords.setText('coords: x= {0} y= {1}'.format(x, y)) def updateTime(self, date): self.GUI.time.setText('time: {0[0]}, {0[1]}, {0[2]}, {0[3]}'.format(date)) def updateMapView(self, source): shape = (2, self.GUI.mapView.xRange, self.GUI.mapView.yRange) for x in range(shape[1]): xM = x + self.GUI.mapView.origin[0] for y in range(shape[2]): yM = y + self.GUI.mapView.origin[1] if source[0][1][xM, yM] != 0 or source[0][1][xM, yM] != 0.: self.GUI.mapView.panels[x][y].setText(str(source[0][1][xM, yM])[:4]) else: self.GUI.mapView.panels[x][y].setText(' ') if source[0][1][xM, yM] >= source[1]: self.GUI.mapView.panels[x][y].setCardColor(0.22/2, 0.24/2, 0.32/2, 1) else: if source[2] is not None: self.GUI.mapView.panels[x][y].setCardColor(source[2][1, xM, yM]) else: self.GUI.mapView.panels[x][y].setCardColor(self.GUI.mapView.colorSpace[x, y])
def toggle_mouse(self, capture=True): win_props = WindowProperties() win_props.setCursorHidden(capture) base.win.requestProperties(win_props) self.capture_mouse = capture win_x, win_y = base.win.getXSize(), base.win.getYSize() base.win.movePointer(0, win_x // 2, win_y // 2)
def onSize(self, evt): """Invoked when the viewport is resized.""" if self.win != None: wp = WindowProperties() wp.setOrigin(0, 0) wp.setSize(self.ClientSize.GetWidth(), self.ClientSize.GetHeight()) self.win.requestProperties(wp)
def __init__(self): ShowBase.__init__(self) ########## Window configuration ######### wp = WindowProperties() wp.setSize(1024, 860) self.win.requestProperties(wp) ########## Gameplay settings ######### self.GAME_MODE = PLAY self.play_mode = SPACE self.level = 1.5 self.mode_initialized = False ######### Camera ######### self.disableMouse() self.mainCamera = Camera(self.camera) self.mainCamera.camObject.setHpr(0, 0, 0) #Trigger game chain self.loadLevel(LEVEL) ######### Events ######### self.taskMgr.add(self.gameLoop, "gameLoop", priority = 35) self.keys = {"w" : 0, "s" : 0, "a" : 0, "d" : 0, "space" : 0} self.accept("w", self.setKey, ["w", 1]) self.accept("w-up", self.setKey, ["w", 0]) self.accept("s", self.setKey, ["s", 1]) self.accept("s-up", self.setKey, ["s", 0]) self.accept("a", self.setKey, ["a", 1]) self.accept("a-up", self.setKey, ["a", 0]) self.accept("d", self.setKey, ["d", 1]) self.accept("d-up", self.setKey, ["d", 0]) self.accept("space", self.setKey, ["space", 1]) self.accept("space-up", self.setKey, ["space", 0]) self.accept("wheel_up", self.zoomCamera, [-1]) self.accept("wheel_down", self.zoomCamera, [1]) self.accept("escape", self.switchGameMode, [IN_GAME_MENU]) self.accept("window-event", self.handleWindowEvent) self.accept("playerGroundRayJumping-in", self.avatar.handleCollisionEvent, ["in"]) self.accept("playerGroundRayJumping-out", self.avatar.handleCollisionEvent, ["out"]) ######### GUI ######### self.gui_elements = []
def __init__(self): """ Initialisiert die Kamera, die Runtime und den Eventhandler. Ladet die Planeten und startet das Programm """ props = WindowProperties() props.setTitle('Solarsystem') base.win.requestProperties(props) base.setBackgroundColor(0, 0, 0) # The global variables we used to control the speed and size of objects self.yearscale = 60 self.dayscale = self.yearscale / 365.0 * 5 self.orbitscale = 10 self.sizescale = 0.6 self.skySize = 80 self.runtime = RuntimeHandler() self.camera = Camera(render, self.skySize) self.loadLuminaries() self.runtime.rotateLuminaries() self.eventHandler = EventHandler(self.runtime, self.camera, self.runtime.getLuminary('sun'))
def __init__(self, useJOD=None): """ @keyword useJOD: connected to actual drumpads and spinners to read from (default: read from config.prc) @type useJOD: bool """ self.configPath = Filename("/c/jamoconfig.txt") self.logPath = Filename("/c/jamoconfig.log") self.clearConfig() self.simulate() self.log = sys.stdout self.configMissing = 0 self.hardwareChanged = 0 if (useJOD==None): useJOD = base.config.GetBool("want-jamodrum", True) self.useJOD = useJOD if (useJOD): self.setLog(self.logPath) self.devindices = range(1,base.win.getNumInputDevices()) self.readConfigFile(self.configPath) self.prepareDevices() props = WindowProperties() props.setCursorHidden(1) if (sys.platform == "win32"): props.setZOrder(WindowProperties.ZTop) base.win.requestProperties(props) self.setLog(None)
def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1): """ Low-level buffer creation. Not intended for public use. """ winprops = WindowProperties() winprops.setSize(xsize, ysize) props = FrameBufferProperties(self.win.getFbProperties()) props.setBackBuffers(0) props.setRgbColor(1) props.setDepthBits(depthbits) depthtex, colortex, auxtex0, auxtex1 = texgroup if (auxtex0 != None): props.setAuxRgba(1) if (auxtex1 != None): props.setAuxRgba(2) buffer=base.graphicsEngine.makeOutput( self.win.getPipe(), name, -1, props, winprops, GraphicsPipe.BFRefuseWindow | GraphicsPipe.BFResizeable, self.win.getGsg(), self.win) if (buffer == None): return buffer if (depthtex): buffer.addRenderTexture(depthtex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) if (colortex): buffer.addRenderTexture(colortex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) if (auxtex0): buffer.addRenderTexture(auxtex0, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) if (auxtex1): buffer.addRenderTexture(auxtex1, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) buffer.setSort(self.nextsort) buffer.disableClears() self.nextsort += 1 return buffer
def OnResize( self, event ): """When the wx-panel is resized, fit the panda3d window into it.""" frame_size = event.GetSize() wp = WindowProperties() wp.setOrigin( 0, 0 ) wp.setSize( frame_size.GetWidth(), frame_size.GetHeight() ) self._win.requestProperties( wp )
def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1): """ Low-level buffer creation. Not intended for public use. """ winprops = WindowProperties() winprops.setSize(xsize, ysize) props = FrameBufferProperties() props.setRgbColor(1) props.setDepthBits(depthbits) depthtex, colortex, auxtex0, auxtex1 = texgroup if (auxtex0 != None): props.setAuxRgba(1) if (auxtex1 != None): props.setAuxRgba(2) buffer=base.graphicsEngine.makeOutput( self.win.getPipe(), name, -1, props, winprops, GraphicsPipe.BFRefuseWindow | GraphicsPipe.BFResizeable, self.win.getGsg(), self.win) if (buffer == None): return buffer if (depthtex): buffer.addRenderTexture(depthtex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) if (colortex): buffer.addRenderTexture(colortex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) if (auxtex0): buffer.addRenderTexture(auxtex0, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) if (auxtex1): buffer.addRenderTexture(auxtex1, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) buffer.setSort(self.nextsort) buffer.disableClears() buffer.getDisplayRegion(0).disableClears() self.nextsort += 1 return buffer
def buildMainMenu(self): props = WindowProperties() props.setCursorHidden(False) base.win.requestProperties(props) start_game_button = DirectButton(text = "Start", scale = .1, command = self.b) select_level_button = DirectButton(text = "Select Level", scale = .1, command = self.b) game_options_button = DirectButton(text = "Options", scale = .1, command = self.b) exit_button = DirectButton(text = "Exit", scale = .1, command = exit) BUTTON_SPACING = .2 BUTTON_HEIGHT = start_game_button.getSy() button_positions = self.evenButtonPositions(BUTTON_SPACING, BUTTON_HEIGHT) start_game_button.setPos(Vec3(0, 0, button_positions[0])) select_level_button.setPos(Vec3(0, 0, button_positions[1])) game_options_button.setPos(Vec3(0, 0, button_positions[2])) exit_button.setPos(Vec3(0, 0, button_positions[3])) self.gui_elements.append(start_game_button) self.gui_elements.append(select_level_button) self.gui_elements.append(game_options_button) self.gui_elements.append(exit_button)
def p3dSurfaceFocus(self): '''re-gain keyboard focus NOT ''' wp=WindowProperties() wp.setForeground(True) base.win.requestProperties(wp) print ">>>p3d surface try to re-gain focus - do keyboard events still work?"
def _init_graphics(self): base.disableMouse() props = WindowProperties() props.setCursorHidden(True) base.win.requestProperties(props) base.setFrameRateMeter(True) render.setShaderAuto() render.setAntialias(AntialiasAttrib.MAuto)
def onSize(self, event): wp = WindowProperties() wp.setOrigin(0, 0) x,y = self.GetClientSize() wp.setSize(x,y) base.camLens.setAspectRatio(1.0*y/x) base.win.requestProperties(wp) event.Skip()
def __exitWheel(self, event): # Window properties props = WindowProperties() props.setCursorHidden(False) base.win.requestProperties(props) # Stop tracking our mouse pointer taskMgr.remove('MATColorWheel-mouse')
def resize_panda_window(widget, request): """ Connected to resize event of the widget Panda is draw on so that the Panda window update its size """ props = WindowProperties().getDefault() props = WindowProperties(base.win.getProperties()) props.setOrigin(0, 0) props.setSize(request.width, request.height) props.setParentWindow(widget.window.xid) base.win.requestProperties(props)
def p3dSurfaceFocus(self): '''re-gain keyboard focus NOT ''' wp = WindowProperties() wp.setForeground(True) base.win.requestProperties(wp) print ">>>p3d surface try to re-gain focus - do keyboard events still work?"
def hide_cursor(): """set the Cursor invisible""" props = WindowProperties() props.setCursorHidden(True) # somehow the window gets undecorated after hiding the cursor # so we reset it here to the value we need #props.setUndecorated(settings.fullscreen) base.win.requestProperties(props)
def show_cursor(): props = WindowProperties() props.setCursorHidden(False) # set the filename to the mouse cursor # at the time the realization is valid for Windows only win = "assets/gui/Cursor.cur" props.setCursorFilename(win) base.win.requestProperties(props)
def disable_rot(self): if self.free_look_task is not None: taskMgr.remove(self.free_look_task) # show the mouse cursor again. props = WindowProperties() props.setCursorHidden(False) base.win.requestProperties(props)
def relative(self): if self.mouse.hasMouse(): props = WindowProperties() props.setMouseMode(WindowProperties.M_relative) base.win.requestProperties(props) self.relative_requested = False else: self.relative_requested = True
def __clearWindowProperties(self): """ Clears the windowPrc file that was created in a previous call to setupWindow(), if any. """ if self.windowPrc: unloadPrcFile(self.windowPrc) self.windowPrc = None WindowProperties.clearDefault()
def init_wp(window_type, size): """ Initial / default WindowProperties """ if window_type == 'onscreen': wp = WindowProperties.getDefault() wp.setSize(size[0], size[1]) elif window_type == 'offscreen': wp = WindowProperties.size(size[0], size[1]) return wp
def set_defaults(self): """Sets some environment defaults that might be overridden by the modules.""" font = loader.loadFont('arial.ttf', textureMargin=5) font.setPixelsPerUnit(128) base.win.setClearColorActive(True) base.win.setClearColor((0.3, 0.3, 0.3, 1)) winprops = WindowProperties() winprops.setTitle('SNAP') base.win.requestProperties(winprops)
def set_defaults(self): """Sets some environment defaults that might be overridden by the modules.""" font = loader.loadFont('arial.ttf',textureMargin=5) font.setPixelsPerUnit(128) base.win.setClearColorActive(True) base.win.setClearColor((0.3, 0.3, 0.3, 1)) winprops = WindowProperties() winprops.setTitle('SNAP') base.win.requestProperties(winprops)
def resizeWindow(self, window_id, width, height): """window_id is an index of a window from base.winList.""" window = self.windows[window_id] old_wp = window.getProperties() if old_wp.getXSize() == width and old_wp.getYSize() == height: return wp = WindowProperties() wp.setOrigin(0, 0) wp.setSize(width, height) window.requestProperties(wp)
def resetWindowProperties(self, pipe, properties): if base.win: currentProperties = WindowProperties(base.win.getProperties()) gsg = base.win.getGsg() else: currentProperties = WindowProperties.getDefault() gsg = None newProperties = WindowProperties(currentProperties) newProperties.addProperties(properties) if base.pipe != pipe: gsg = None if gsg == None or currentProperties.getFullscreen() != newProperties.getFullscreen() or currentProperties.getParentWindow() != newProperties.getParentWindow(): self.notify.debug('window properties: %s' % properties) self.notify.debug('gsg: %s' % gsg) base.pipe = pipe if not base.openMainWindow(props=properties, gsg=gsg, keepCamera=True): self.notify.warning('OPEN MAIN WINDOW FAILED') return 0 self.notify.info('OPEN MAIN WINDOW PASSED') base.graphicsEngine.openWindows() if base.win.isClosed(): self.notify.warning('Window did not open, removing.') base.closeWindow(base.win) return 0 base.disableShowbaseMouse() if 'libotp' in sys.modules: from libotp import NametagGlobals NametagGlobals.setCamera(base.cam) NametagGlobals.setMouseWatcher(base.mouseWatcherNode) else: self.notify.debug('Adjusting properties') base.win.requestProperties(properties) base.graphicsEngine.renderFrame() return 1
def togglePause(self): print ("pause pressed") if MyApp.paused: self.makeMouseRelative() MyApp.paused = False else: props = WindowProperties() # initiates window node props.setCursorHidden(False) # cursor shows props.setMouseMode(WindowProperties.M_absolute) # cursor moves self.win.requestProperties(props) # window accepts changes MyApp.paused = True
def setPlanar(): for citizen in citizenIndex: location = citizen.getLocation() citizen.glide(location) global mode mode = 1 LerpPosInterval(base.camera, 1, VBase3(0, 0, 75), fluid = 1).start() LerpHprInterval(base.camera, 1, VBase3(0, -90, 0), fluid = 1).start() #base.camera.setPosHpr(0, 0, 75, 0, -90, 0) props = WindowProperties() props.setCursorHidden(False) base.win.requestProperties(props)
def __init__(self, game): self.game = game self.SpeedCam = 0.05 self.sleep = 0.01 self.fly_mod = 0.01 self.SpeedMult = 3 self.isMoving = False self.fly = True self.CursorOffOn = 'On' taskMgr.setupTaskChain('avatar_move', numThreads = 1, frameSync = False, threadPriority = TPUrgent, timeslicePriority = False) self.props = WindowProperties()
def beginGame(self): self.textObject.destroy() self.imageObject.destroy() self.b.destroy() props = WindowProperties() props.setCursorHidden(True) base.win.requestProperties(props) self.taskMgr.add(self.moveForward, "MoveForward") self.accept("mouse1",self.jump) self.textScore = OnscreenText(text = '\1red\1\1slant\1Score : 0', pos = (-0.8, 0.8), scale = 0.1) self.textTimer = OnscreenText(text = '\1red\1\1slant\1Time Left : 2:00', pos = (-0.8, 0.7), scale = 0.1) print 'GameBegin'
def makeGameEngine(self): ''' Creates a new game engine based on settings in GameSettings. Information for this came from here http://panda3d.org/phpbb2/viewtopic.php?t=2848''' LOG.debug("[GXMgr] Building game engine") # Temporary # TODO: Fix this props = WindowProperties() props.setFullscreen(False) props.setUndecorated(False) #screenx = int(base.pipe.getDisplayWidth()/2) - (int(self.ScreenWidth)/2) #screeny = int(base.pipe.getDisplayHeight()/2) - (int(self.ScreenHeight)/2) #self.TempScreenSizeRX = int(self.ScreenWidth) #self.TempScreenSizeRY = int(self.ScreenHeight) props.setOrigin(100,100) props.setSize(1024,768) base.win.requestProperties(props) # This was the old way that no longer works - I don't know why ## Create a new FrameBufferProperties object using our settings #fbProps = FrameBufferProperties() #fbProps.addProperties(FrameBufferProperties.getDefault()) #fbProps.setMultisamples(GameSettings().antiAlias) #fbProps.setAlphaBits(GameSettings().alphaBits) #fbProps.setDepthBits(GameSettings().colorDepth) #fbProps.setColorBits(24) # ## Create a WindowProperties object #winProps = WindowProperties( base.win.getProperties() ) #winProps.setFullscreen(GameSettings().fullscreen) #winProps.setUndecorated(GameSettings().fullscreen) #winProps.setSize(GameSettings().xRes,GameSettings().yRes) #winProps.setTitle('PSG - Project Space Game: Alpha') # ## Create the engine #base.graphicsEngine.makeOutput(base.pipe, # GraphicsPipe # 'mainGameOutput', # Name # 0, # Sort # fbProps, # FrameBufferProperties # winProps, # WindowProperties # GraphicsPipe.BFRequireWindow | GraphicsPipe.BFFbPropsOptional, # Flags # base.win.getGsg()) # GraphicsStateGaurdian ##base.openMainWindow(props=winProps, gsg=base.win.getGsg(), keepCamera=1) #base.openMainWindow() #base.graphicsEngine.openWindows() #base.win.requestProperties(winProps) ## The following code should proabably be moved somewhere else #showFPS = GameSettings().showFPS #base.setFrameRateMeter(showFPS)
def __init__(self): ShowBase.__init__(self) # initializes Panda window from ShowBase # change window name from "panda" to app name properties = WindowProperties() properties.setTitle("Shinsai-Simulator") base.win.requestProperties(properties) # adds algorithm to render closer objects first binManager = CullBinManager.getGlobalPtr() binManager.addBin("ftb", CullBinManager.BTFrontToBack, 1) # base.setFrameRateMeter(True) self.tName = None # name of terrain self.magnitude = None # magnitude of earthquake self.titleScreen()
def show_cursor(): """set the Cursor visible again""" props = WindowProperties() props.setCursorHidden(False) # set the filename to the mouse cursor #x11 = os.path.join("data", "Cursor.x11") #win = os.path.join("data", "Cursor.ico") #if sys.platform.startswith("linux"): # props.setCursorFilename(x11) #else: # props.setCursorFilename(win) #props.setUndecorated(settings.fullscreen) base.win.requestProperties(props)
def start_map(self): try: self.r_region.setActive(0) self.ih_node.detach_node() except: # probably self.r_region isn't set because # we never loaded it (map arg on cmd line) pass self.lp = LocalPlayer(self.map, self.showbase) taskMgr.add(self.map.world.update, 'worldUpdateTask') props = WindowProperties() props.setCursorHidden(True) self.win.requestProperties(props) print self.render.analyze()
def setCubic(): for citizen in citizenIndex: color = citizen.getColor() position = VBase3((color[0]-0.5)*50, (color[1]-0.5)*50, (color[2]-0.5)*50) citizen.glide(position) global mode mode = 4 #base.camera.setPos(VBase3(0, -50, 0)) LerpPosInterval(base.camera, 1, VBase3(0, -100, 0), fluid = 1).start() LerpHprInterval(base.camera, 1, VBase3(0, 0, 0), fluid = 1).start() #base.camera.lookAt((0, 0, 0)) props = WindowProperties() props.setCursorHidden(True) base.win.requestProperties(props)
def resize_panda_window(self, widget, request) : props = WindowProperties().getDefault() props = WindowProperties(self.base.win.getProperties()) props.setOrigin(0, 0) props.setSize(request.width, request.height) props.setParentWindow(widget.window.xid) self.base.win.requestProperties(props)
def launch_panda_window(panda_widget, size): """ Configure and create Panda window Connect to the gtk widget resize event Load a panda """ props = WindowProperties().getDefault() props.setOrigin(0, 0) props.setSize(*size) props.setParentWindow(panda_widget.window.xid) base.openDefaultWindow(props=props) # == panda_widget.connect("size_allocate", resize_panda_window) # == panda = loader.loadModel("panda") panda.reparentTo(render) panda.setPos(0, 40, -5) pl = render.attachNewNode(PointLight("redPointLight")) pl.node().setColor(Vec4(.9, .8, .8, 1)) render.setLight(pl) pl.node().setAttenuation(Vec3(0, 0, 0.05)) slight = Spotlight('slight') slight.setColor(VBase4(1, 1, 1, 1)) lens = PerspectiveLens() slight.setLens(lens) slnp = render.attachNewNode(slight) slnp.setPos(2, 20, 0) mid = PandaNode('mid') panda.attachNewNode(mid) # slnp.lookAt(mid) render.setLight(slnp)
def initialize(self): self.Update() wp = WindowProperties() wp.setOrigin(0, 0) wp.setSize(self.ClientSize.GetWidth(), self.ClientSize.GetHeight()) assert self.GetHandle() != 0 wp.setParentWindow(self.GetHandle()) # initializing panda window base.windowType = "onscreen" props = WindowProperties.getDefault() props.addProperties(wp) self.win = base.openWindow(props=props, gsg=ViewportManager.gsg) if self.win: self.cam2d = base.makeCamera2d(self.win) self.cam2d.node().setCameraMask(LE_CAM_MASKS[self.name]) if ViewportManager.gsg == None: ViewportManager.gsg = self.win.getGsg() self.cam = base.camList[-1] self.camera = render.attachNewNode(self.name) #self.camera.setName(self.name) #self.camera.reparentTo(render) self.cam.reparentTo(self.camera) self.camNode = self.cam.node() self.camNode.setCameraMask(LE_CAM_MASKS[self.name]) self.bt = base.setupMouse(self.win, True) self.bt.node().setPrefix('_le_%s_' % self.name[:3]) mw = self.bt.getParent() mk = mw.getParent() winCtrl = WindowControls(self.win, mouseWatcher=mw, cam=self.camera, camNode=self.camNode, cam2d=None, mouseKeyboard=mk, grid=self.grid) base.setupWindowControls(winCtrl) self.initialized = True if self.lens != None: self.cam.node().setLens(self.lens) if self.camPos != None: self.camera.setPos(self.camPos) if self.camLookAt != None: self.camera.lookAt(self.camLookAt) self.camLens = self.camNode.getLens() if self.name in ['top', 'front', 'left']: x = self.ClientSize.GetWidth() * 0.1 y = self.ClientSize.GetHeight() * 0.1 self.camLens.setFilmSize(x, y) self.Bind(wx.EVT_SIZE, self.onSize)
def __init__(self, scene_file, pedestrian_file, dir, mode): ShowBase.__init__(self) self.globalClock = ClockObject.getGlobalClock() self.globalClock.setMode(ClockObject.MSlave) self.directory = dir self.model = Model(dir) self.loadScene(scene_file) self.loadPedestrians(pedestrian_file) self.cam_label = OST("Top Down", pos=(0, 0.95), fg=(1, 1, 1, 1), scale=0.05, mayChange=True) self.time_label = OST("Time: 0.0", pos=(-1.3, 0.95), fg=(1, 1, 1, 1), scale=0.06, mayChange=True, align=TextNode.ALeft) self.accept("arrow_right", self.changeCamera, [1]) self.accept("arrow_left", self.changeCamera, [-1]) self.accept("escape", self.exit) self.accept("aspectRatioChanged", self.setAspectRatio) self.accept("window-event", self.windowChanged) #base.disableMouse() lens = OrthographicLens() lens.setFilmSize(1550, 1000) self.display_region = base.win.makeDisplayRegion() self.default_camera = render.attachNewNode(Camera("top down")) self.default_camera.node().setLens(lens) self.default_camera.setPosHpr(Vec3(-75, 0, 2200), Vec3(0, -90, 0)) self.setCamera(0) self.controller = Controller(self, mode) self.taskMgr.add(self.updateCameraModules, "Update Camera Modules", 80) self.globalClock.setFrameTime(0.0) self.width = WIDTH self.height = HEIGHT props = WindowProperties() props.setTitle('Virtual Vision Simulator') base.win.requestProperties(props)
def __init__(self): ShowBase.__init__(self) self.keys = ReadKeys() self.wp = WindowProperties() self.wp.setFullscreen(1) self.wp.setSize(RESOLUTION) self.openMainWindow() self.win.requestProperties(self.wp) self.graphicsEngine.openWindows() self.setBackgroundColor(0, 0, 0) self.disableMouse() self.props = WindowProperties() self.props.setCursorHidden(True) self.win.requestProperties(self.props) self.title()