Esempio n. 1
0
 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
Esempio n. 2
0
    def writeSettingToFile(self, setting, value, jsonfile, apply=0):
        info = open(jsonfile)

        jsonInfo = json.load(info)
        if setting == "fullscreen":
            jsonInfo["settings"][setting] = value[0]
        else:
            jsonInfo["settings"][setting] = value

        jsonFile = open(jsonfile, "w+")
        jsonFile.write(json.dumps(jsonInfo))
        jsonFile.close()

        if apply:
            if setting == "resolution":
                width, height = value
                wp = WindowProperties()
                wp.setSize(width, height)
                base.win.requestProperties(wp)
            elif setting == "fullscreen":
                wp = WindowProperties()
                wp.setFullscreen(value[0])
                base.win.requestProperties(wp)

        info.close()
Esempio n. 3
0
def medit_focus_task(task, medit_win: GraphicsWindow):
    # print(medit_win.getProperties().getForeground())

    base_props = app.base.win.getProperties()
    medit_props = medit_win.getProperties()

    base_foreground = not base_props.getForeground()
    medit_foreground = not medit_props.getForeground()

    print("base_foreground : {}".format(base_foreground))
    print("base minimized : {}".format(base_props.minimized))
    print("medit_foreground : {}".format(medit_foreground))

    if base_foreground and medit_foreground:
        properties = WindowProperties()
        properties.setZOrder(WindowProperties.Z_normal)
        properties.setMinimized(True)
        medit_win.request_properties(properties)
        print("minimize")
    elif not base_foreground and medit_props.minimized:
        properties = WindowProperties()
        properties.setZOrder(WindowProperties.Z_top)
        properties.setMinimized(False)
        medit_win.request_properties(properties)
        print("maximize")

    if not medit_win.getProperties().getOpen():
        return task.done

    return task.cont
Esempio n. 4
0
 def set(self, pipe, width, height, fullscreen, embedded):
     self.notify.debugStateCall(self)
     state = False
     self.notify.info('SET')
     if self.restrict_to_embedded:
         fullscreen = 0
         embedded = 1
     if embedded:
         if base.appRunner.windowProperties:
             width = base.appRunner.windowProperties.getXSize()
             height = base.appRunner.windowProperties.getYSize()
     self.current_pipe = base.pipe
     self.current_properties = WindowProperties(base.win.getProperties())
     properties = self.current_properties
     self.notify.debug('DISPLAY PREVIOUS:')
     self.notify.debug('  EMBEDDED:   %s' % bool(properties.getParentWindow()))
     self.notify.debug('  FULLSCREEN: %s' % bool(properties.getFullscreen()))
     self.notify.debug('  X SIZE:     %s' % properties.getXSize())
     self.notify.debug('  Y SIZE:     %s' % properties.getYSize())
     self.notify.debug('DISPLAY REQUESTED:')
     self.notify.debug('  EMBEDDED:   %s' % bool(embedded))
     self.notify.debug('  FULLSCREEN: %s' % bool(fullscreen))
     self.notify.debug('  X SIZE:     %s' % width)
     self.notify.debug('  Y SIZE:     %s' % height)
     if self.current_pipe == pipe and bool(self.current_properties.getParentWindow()) == bool(embedded) and self.current_properties.getFullscreen() == fullscreen and self.current_properties.getXSize() == width and self.current_properties.getYSize() == height:
         self.notify.info('DISPLAY NO CHANGE REQUIRED')
         state = True
     else:
         properties = WindowProperties()
         properties.setSize(width, height)
         properties.setFullscreen(fullscreen)
         properties.setParentWindow(0)
         if embedded:
             if base.appRunner.windowProperties:
                 properties = base.appRunner.windowProperties
         original_sort = base.win.getSort()
         if self.resetWindowProperties(pipe, properties):
             self.notify.debug('DISPLAY CHANGE SET')
             properties = base.win.getProperties()
             self.notify.debug('DISPLAY ACHIEVED:')
             self.notify.debug('  EMBEDDED:   %s' % bool(properties.getParentWindow()))
             self.notify.debug('  FULLSCREEN: %s' % bool(properties.getFullscreen()))
             self.notify.debug('  X SIZE:     %s' % properties.getXSize())
             self.notify.debug('  Y SIZE:     %s' % properties.getYSize())
             if bool(properties.getParentWindow()) == bool(embedded) and properties.getFullscreen() == fullscreen and properties.getXSize() == width and properties.getYSize() == height:
                 self.notify.info('DISPLAY CHANGE VERIFIED')
                 state = True
             else:
                 self.notify.warning('DISPLAY CHANGE FAILED, RESTORING PREVIOUS DISPLAY')
                 self.restoreWindowProperties()
         else:
             self.notify.warning('DISPLAY CHANGE FAILED')
             self.notify.warning('DISPLAY SET - BEFORE RESTORE')
             self.restoreWindowProperties()
             self.notify.warning('DISPLAY SET - AFTER RESTORE')
         base.win.setSort(original_sort)
         base.graphicsEngine.renderFrame()
         base.graphicsEngine.renderFrame()
     return state
Esempio n. 5
0
def test_winprops_copy_ctor():
    props = WindowProperties()
    props.set_size(1, 2)

    props2 = WindowProperties(props)
    assert props == props2
    assert props2.get_size() == (1, 2)

    with pytest.raises(TypeError):
        WindowProperties(None)
Esempio n. 6
0
    def __init__(self):
        ShowBase.__init__(self)  #class initialization

        #setting window size
        properties = WindowProperties()
        properties.setSize(1000, 750)
        self.win.requestProperties(properties)

        self.disableMouse()  #disables mouse camera movement

        #load environment model
        self.environment = loader.loadModel(
            "models/zebrafishEnviron17_100contrast.egg")
        self.environment.reparentTo(
            render)  #attaches environment to render environment

        self.camera.setPos(0, 0, 5)  #sets model at eye-level
        self.camLens.setFov(40)  #camera FOV setting, needs testing

        #TV object for displaying images in foreground
        self.tex1 = loader.loadTexture("models/VRE_autoPA_bigFish.avi")
        self.TV1 = loader.loadModel("models/zebrafishEnviron4TV3.egg")
        self.TV1.reparentTo(render)
        self.TV1.setTexture(self.tex1, 1)
        self.TV1.setH(180)
        self.TV1.setPos(0, 20.3, 0)

        # hide mouse cursor
        props = WindowProperties()
        props.setCursorHidden(True)
        self.win.requestProperties(props)

        #keymap for keyboard inputs
        self.keyMap = {
            "up": False,
            "down": False,
            "left": False,
            "right": False,
            "shoot": False
        }

        #event listeners for keyboard inputs
        self.accept("w", self.updateKeyMap, ["up", True])
        self.accept("w-up", self.updateKeyMap, ["up", False])
        self.accept("s", self.updateKeyMap, ["down", True])
        self.accept("s-up", self.updateKeyMap, ["down", False])
        self.accept("a", self.updateKeyMap, ["left", True])
        self.accept("a-up", self.updateKeyMap, ["left", False])
        self.accept("d", self.updateKeyMap, ["right", True])
        self.accept("d-up", self.updateKeyMap, ["right", False])

        #adds camera inputs to task manager
        self.updateTask = taskMgr.add(self.update, "update")
Esempio n. 7
0
    def enableMovement(self, startTask=True):
        if self.disabledByChat:
            self.enableOnChatExit = True
            return

        if self.player_node is None or self.enabled:
            return

        self.enableOnChatExit = False

        props = WindowProperties()
        props.setCursorHidden(True)
        props.setMouseMode(WindowProperties.MConfined)
        base.win.requestProperties(props)
        self.acceptOnce(base.inputStore.ToggleGTAControls,
                        self.disableMovement)
        self.accept(base.win.getWindowEvent(), self.__handleWindowEvent)

        self.player_node.setHpr(0, 0, 0)

        # Re-center the mouse.
        base.win.movePointer(0,
                             base.win.getXSize() / 2,
                             base.win.getYSize() / 2)

        camera.reparentTo(self.player_node)

        if startTask:
            taskMgr.add(self.cameraMovement, "TPMM.enableMovement", sort=-40)

        self.enabled = True
Esempio n. 8
0
    def capture_mouse(self):
        props = WindowProperties()
        props.set_cursor_hidden(True)
        props.set_mouse_mode(WindowProperties.M_confined)
        base.win.request_properties(props)

        self.capturing_mouse = True
Esempio n. 9
0
    def release_mouse(self):
        props = WindowProperties()
        props.set_cursor_hidden(False)
        props.set_mouse_mode(WindowProperties.M_absolute)
        base.win.request_properties(props)

        self.capturing_mouse = False
Esempio n. 10
0
    def create_buffer(self, name, texture, width, height, fbprops):
        """
        Create a render buffer with the given properties.
        """

        winprops = WindowProperties()
        winprops.set_size(width, height)
        props = FrameBufferProperties(FrameBufferProperties.get_default())
        props.set_back_buffers(0)
        props.set_rgb_color(1)
        if fbprops is not None:
            props.add_properties(fbprops)

        buffer = self.base.win.make_texture_buffer(name,
                                                   width,
                                                   height,
                                                   to_ram=False,
                                                   fbp=props)
        if buffer is not None:
            buffer.clear_render_textures()
            buffer.set_sort(self.nextsort)
            self.nextsort += 1
            buffer.add_render_texture(texture, GraphicsOutput.RTMBindOrCopy,
                                      GraphicsOutput.RTPColor)
        else:
            print("COULD NOT CREATE BUFFER")
        return buffer
 def applySettings(self, jsonfile):
     if not jsonfile:
         raise IOError('no file specified!')
     info = open(jsonfile, 'r')
     jsonInfo = json.load(info)
     settings = jsonInfo['settings']
     width, height = settings['resolution']
     fs = settings['fullscreen']
     music = settings['music']
     sfx = settings['sfx']
     tex_detail = settings['texture-detail']
     model_detail = settings['model-detail']
     aa = settings['aa']
     af = settings.get('af', None)
     if af == None:
         self.writeSettingToFile('af', 'off', 'settings.json')
     base.enableMusic(music)
     base.enableSoundEffects(sfx)
     if aa == 'on':
         render.set_antialias(AntialiasAttrib.MMultisample)
         aspect2d.set_antialias(AntialiasAttrib.MMultisample)
     else:
         render.clear_antialias()
     ts = TextureStage('ts')
     if tex_detail == 'high':
         pass
     else:
         if tex_detail == 'low':
             loadPrcFileData('', 'compressed-textures 1')
     wp = WindowProperties()
     wp.setSize(width, height)
     wp.setFullscreen(fs)
     base.win.requestProperties(wp)
     info.close()
     return
 def disableMouse(self, startTask=True):
     if startTask:
         taskMgr.add(self.cameraMovement, 'moveCamera')
     props = WindowProperties()
     props.setCursorHidden(True)
     base.win.requestProperties(props)
     self.acceptOnce('escape', self.enableMouse)
Esempio n. 13
0
    def __init__(self):
        ShowBase.__init__(self)
        props = WindowProperties( )
        props.setTitle( 'Differentiable Physics Engine' )
        self.win.requestProperties( props )
        self.t = 0
        self.starttime = time.time()
        #self.setFrameRateMeter(True)
        cour = self.loader.loadFont('cmtt12.egg')
        self.textObject = OnscreenText(font= cour, text = 'abcdefghijklmnopqrstuvwxyz', pos=(0, -0.045), parent = self.a2dTopCenter, bg=(0,0,0,1), fg =(1,1,1,1), scale = 0.07, mayChange=True)
        cm = CardMaker("ground")
        cm.setFrame(-2000, 2000, -2000, 2000)
        cm.setUvRange(Point2(-2000/5,-2000/5),Point2(2000/5,2000/5))

        tmp = self.render.attachNewNode(cm.generate())
        tmp.reparentTo(self.render)

        tmp.setPos(0, 0, 0)
        tmp.lookAt((0, 0, -2))
        tmp.setColor(1.0,1.0,1.0,1)
        tmp.setTexScale(TextureStage.getDefault(), 1, 1)
        tex = self.loader.loadTexture('textures/grid2.png')

        tex.setWrapU(Texture.WMRepeat)
        tex.setWrapV(Texture.WMRepeat)
        tmp.setTexture(tex,1)
        self.setBackgroundColor(0.0, 191.0/255.0, 1.0, 1.0) #color of the sky

        ambientLight = AmbientLight('ambientLight')
        ambientLight.setColor(Vec4(0.2, 0.2, 0.2, 1))
        ambientLightNP = self.render.attachNewNode(ambientLight)
        self.render.setLight(ambientLightNP)

        # Directional light 01
        directionalLight = DirectionalLight('directionalLight')
        directionalLight.setColor(Vec4(0.8, 0.8, 0.8, 1))
        directionalLightNP = self.render.attachNewNode(directionalLight)
        # This light is facing backwards, towards the camera.
        directionalLightNP.setHpr(-60, -50, 0)
        directionalLightNP.node().setScene(self.render)
        directionalLightNP.node().setShadowCaster(True)
        directionalLightNP.node().getLens().setFov(40)
        directionalLightNP.node().getLens().setNearFar(10, 100)
        self.render.setLight(directionalLightNP)

        # Add the spinCameraTask procedure to the task manager.
        self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")


        # Load the environment model.
        self.objects = dict()
        self.names = []
        data = pickle.load(open("../PhysXVids/state-dump-exp15.pkl","rb"))

        self.json = json.loads(data["json"]) # json.loads(data["json"])
        self.states = data["states"]
        self.load_robot_model()
        self.dt = self.json["integration_parameters"]["time_step"]
        self.setupKeys()
        self.robot_id = 0
Esempio n. 14
0
    def _configure_window(self):
        """Configure the game window.

        Set title, fullscreen mode and the given resolution.

        Returns:
            panda3d.core.WindowProperties: The main window properties object.
        """
        props = WindowProperties()

        props.setTitle("Forward Only Game")
        props.setFullscreen(True)

        x, z = self.game_config.resolution.split("x")
        props.setSize(int(x), int(z))
        props.setCursorFilename(
            Filename.binaryFilename("GUI/pointers/normal.ico"))

        globalClock.setMode(ClockObject.MLimited)  # noqa: F82
        globalClock.setFrameRate(self.game_config.fps_limit)  # noqa: F82

        self.openDefaultWindow(props=props)
        if self.game_config.fps_meter:
            self.setFrameRateMeter(True)

        return props
Esempio n. 15
0
 def setFullscreen():
     """Helper function to set the window fullscreen
     with width and height set to the screens size"""
     # set window properties
     # clear all properties not previously set
     base.win.clearRejectedProperties()
     # setup new window properties
     props = WindowProperties()
     # Fullscreen
     props.setFullscreen(True)
     # set the window size to the screen resolution
     props.setSize(self.dispWidth, self.dispHeight)
     # request the new properties
     base.win.requestProperties(props)
     # Set the config variables so we correctly store the
     # new size and fullscreen setting later
     winSize = ConfigVariableString("win-size")
     winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight))
     fullscreen = ConfigVariableBool("fullscreen")
     fullscreen.setValue(True)
     # Render a frame to make sure the fullscreen is applied
     # before we do anything else
     self.taskMgr.step()
     # make sure to propagate the new aspect ratio properly so
     # the GUI and other things will be scaled appropriately
     aspectRatio = self.dispWidth / self.dispHeight
     self.adjustWindowAspectRatio(aspectRatio)
Esempio n. 16
0
def test_winprops_ctor_kwargs():
    props = WindowProperties(size=(1, 2), origin=3)

    assert props.has_size()
    assert props.get_size() == (1, 2)

    assert props.has_origin()
    assert props.get_origin() == (3, 3)

    # Invalid property should throw
    with pytest.raises(TypeError):
        WindowProperties(swallow_type="african")

    # Invalid value should throw
    with pytest.raises(TypeError):
        WindowProperties(size="invalid")
Esempio n. 17
0
    def __init__(self, parentChar, keyMap):
        assert isinstance(parentChar, Character)
        base.disableMouse()
        self.char = parentChar
        self.keyMap = keyMap
        print 'keymap is', keyMap
        parentChar.node.rotationallyImmune = True

        self.floater = NodePath('floater')
        self.floater.reparentTo(parentChar.node)
        self.floater.setPos(1, 0, 2)

        base.camera.reparentTo(self.floater)
        base.camera.setPos(0, -5, 0)
        base.camera.setH(0)

        print base.camera.getPos(render)

        props = WindowProperties()
        props.setCursorHidden(True)
        base.win.requestProperties(props)

        taskMgr.add(self.controlCamera, 'camera-task')
        self.h = parentChar.node.getH()
        self.p = parentChar.node.getP()
Esempio n. 18
0
    def setupWindow(self, windowType, x, y, width, height,
                    parent):
        """ Applies the indicated window parameters to the prc
        settings, for future windows; or applies them directly to the
        main window if the window has already been opened.  This is
        called by the browser. """

        if self.started and base.win:
            # If we've already got a window, this must be a
            # resize/reposition request.
            wp = WindowProperties()
            if x or y or windowType == 'embedded':
                wp.setOrigin(x, y)
            if width or height:
                wp.setSize(width, height)
            if windowType == 'embedded':
                wp.setParentWindow(parent)
            wp.setFullscreen(False)
            base.win.requestProperties(wp)
            self.windowProperties = wp
            return

        # If we haven't got a window already, start 'er up.  Apply the
        # requested setting to the prc file, and to the default
        # WindowProperties structure.

        self.__clearWindowProperties()

        if windowType == 'hidden':
            data = 'window-type none\n'
        else:
            data = 'window-type onscreen\n'

        wp = WindowProperties.getDefault()

        wp.clearParentWindow()
        wp.clearOrigin()
        wp.clearSize()

        wp.setFullscreen(False)
        if windowType == 'fullscreen':
            wp.setFullscreen(True)

        if windowType == 'embedded':
            wp.setParentWindow(parent)

        if x or y or windowType == 'embedded':
            wp.setOrigin(x, y)

        if width or height:
            wp.setSize(width, height)

        self.windowProperties = wp
        self.windowPrc = loadPrcFileData("setupWindow", data)
        WindowProperties.setDefault(wp)

        self.gotWindow = True

        # Send this call to the main thread; don't call it directly.
        messenger.send('AppRunner_startIfReady', taskChain = 'default')
Esempio n. 19
0
    def mouseTask (self, task):
        mw = base.mouseWatcherNode
        wp = WindowProperties()

        hasMouse = mw.hasMouse() 
        if hasMouse and mw.is_button_down(MouseButton.one()):
            x, y = mw.getMouseX(), mw.getMouseY()
            
            if not self.scrolling :
                    self.lastMouseX, self.lastMouseY = x, y
                    self.scrolling = True
            
            if self.lastMouseX is not None:
                
                dx, dy = x - self.lastMouseX, y - self.lastMouseY

            else:
                dx, dy = 0, 0

            self.lastMouseX, self.lastMouseY = x, y
            
        else:
            x, y, dx, dy, self.lastMouseX, self.lastMouseY = 0, 0, 0, 0, 0, 0
            self.scrolling = False
        
        if self.scrolling :
            self.rotateX += dx * 10 * self.mouseMagnitude
            self.rotateY -= dy * 10 * self.mouseMagnitude

            self.camera.setH(self.rotateX)
            self.camera.setP(self.rotateY)

        return Task.cont
Esempio n. 20
0
    def __init__(self):
        ShowBase.__init__(self)
        pman.shim.init(self)

        info = self.pipe.getDisplayInformation()
        for idx in range(info.getTotalDisplayModes()):
            width = info.getDisplayModeWidth(idx)
            height = info.getDisplayModeHeight(idx)
            bits = info.getDisplayModeBitsPerPixel(idx)
        width = 1240
        height = 720
        print(width, height)
        wp = WindowProperties()
        #wp.set_undecorated(False)
        wp.set_size(width, height)
        base.win.requestProperties(wp)

        self.win.set_clear_color((0, 0, 0, 0))
        self.accept('escape', sys.exit)
        add_device_listener(
            config_file='keybindings.toml',
            assigner=SinglePlayerAssigner(),
        )
        self.load_sound()
        self.font = loader.loadFont("font/Stanislav.otf")
        self.font.setPixelsPerUnit(120)
        self.start_game()
 def enterFrozen(self):
     self.loadIceCube()
     base.playSfx(self.iceFormSfx)
     base.cr.playGame.getPlace().fsm.request('stop', [0])
     base.localAvatar.stop()
     base.playSfx(choice(self.frozenSfxArray))
     self.iccsIval = LerpColorScaleInterval(
         self.iceCube,
         duration=0.5,
         colorScale=VBase4(0.76, 0.76, 1.0, 1.0),
         startColorScale=self.iceCube.getColorScale(),
         blendType='easeInOut')
     self.iccsIval.start()
     props = WindowProperties()
     props.setCursorHidden(True)
     base.win.requestProperties(props)
     self.frame = DirectFrame(pos=(0, 0, 0.7))
     self.powerBar = DirectWaitBar(frameColor=(1, 1, 1, 1),
                                   range=100,
                                   value=0,
                                   scale=(0.4, 0.5, 0.25),
                                   parent=self.frame,
                                   barColor=(0.55, 0.7, 1.0, 1.0))
     self.label = OnscreenText(text="SHAKE MOUSE",
                               shadow=(0, 0, 0, 1),
                               fg=(0.55, 0.7, 1.0, 1.0),
                               pos=(0, -0.1, 0),
                               parent=self.frame)
     taskMgr.add(self.__watchMouseMovement, 'BRWater-watchMouseMovement')
     taskMgr.add(self.__lowerPowerBar, 'BRWater-lowerPowerBar')
     mw = base.mouseWatcherNode
     if mw.hasMouse():
         self.lastMouseX = mw.getMouseX()
Esempio n. 22
0
 def __init__(self):
     ShowBase.__init__(self)
     pman.shim.init(self)
     info = self.pipe.getDisplayInformation()
     for idx in range(info.getTotalDisplayModes()):
         width = info.getDisplayModeWidth(idx)
         height = info.getDisplayModeHeight(idx)
         bits = info.getDisplayModeBitsPerPixel(idx)
     wp = WindowProperties()
     wp.set_size(width, height)
     base.win.requestProperties(wp)
     self.win.set_clear_color((0.03,0.03,0.03,1))
     add_device_listener(
         config_file='keybindings.toml',
         assigner=SinglePlayerAssigner(),
     )
     base.disableMouse() 
     self.dt = globalClock.get_dt()
     self.transition = Transitions(loader)
     self.font = loader.load_font("probe.ttf")
     self.load_sounds()
     self.base_fov = 35
     base.camLens.set_fov(self.base_fov)
     self.interface = Interface()
     self.sequence = None
     self.sequence_end = Func(self.end_sequence)
     #self.interface.test()
     taskMgr.add(self.update)
    def exitFrozen(self, avatar):
        """ This is expecting a valid avatar object, either fetched from base.cr.doId2do#get() or passed directly """
        self.__resetAvatarIvalAndUnloadIceCube(avatar)
        if avatar == base.localAvatar:
            # Let's make our cursor visible again.
            props = WindowProperties()
            props.setCursorHidden(False)
            base.win.requestProperties(props)

            # Let's remove our tasks
            taskMgr.remove(self.LowerPowerBarTaskName)
            taskMgr.remove(self.WatchMouseMovementTaskName)

            # Let's destroy all of our UI elements.
            if self.frame:
                self.label.destroy()
                self.label = None
                self.powerBar.destroy()
                self.powerBar = None
                self.frame.destroy()
                self.frame = None
            self.lastMouseX = 0

            base.cr.playGame.getPlace().fsm.request('walk')
            base.localAvatar.b_setAnimState('neutral')
        else:
            avatar.loop('neutral')
Esempio n. 24
0
 def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1):
     winprops = WindowProperties()
     winprops.setSize(xsize, ysize)
     props = FrameBufferProperties(FrameBufferProperties.getDefault())
     props.setBackBuffers(0)
     props.setRgbColor(1)
     props.setDepthBits(depthbits)
     props.setStereo(self.win.isStereo())
     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
Esempio n. 25
0
 def set_origin(self, origin: np.ndarray):
     """
     :param origin: 1x2 np array describe the left top corner of the window
     """
     win_props = WindowProperties()
     win_props.setOrigin(origin[0], origin[1])
     self.win.requestProperties(win_props)
Esempio n. 26
0
    def __init__(self,
                 gameEngine,
                 screen_number,
                 shuttle_angle=0,
                 shift_x=0,
                 shift_y=0.0):
        self.gameEngine = gameEngine

        self.props = WindowProperties()
        self.screen = screen_number
        # hard-coded to avoid detection problems
        self.res = [1920, 1080]

        self.props.set_size(800, 600)
        self.props.set_origin(100 + self.screen * self.res[0], 100)
        self.props.set_undecorated(True)
        self.props.set_foreground(False)

        self.window = self.gameEngine.openWindow(props=self.props,
                                                 aspectRatio=float(800 / 600))

        # getting the new camera
        self.camera = self.gameEngine.camList[-1].node()
        self.cam_node = NodePath(self.camera)
        self.cam_node.reparent_to(self.gameEngine.shuttle.frame)
        self.cam_node.set_x(shift_x)
        self.cam_node.set_y(shift_y)
        self.lens = self.camera.getLens()
        self.lens.setFov(self.gameEngine.params("cam_fov"))
        self.lens.setNear(0.1)

        # self.cam_node.set_hpr(0, shuttle_angle, 0)
        self.cam_node.set_hpr(-shuttle_angle, 0, 0)
        print("Opening new screen with h=", -shuttle_angle)
Esempio n. 27
0
 def setupWindow(self):
     wp = WindowProperties()
     wp.setFullscreen(settings.FULLSCREEN)
     wp.setSize(settings.WIDTH, settings.HEIGHT)
     wp.setTitle("GAME")
     base.win.requestProperties(wp)
     base.win.setClearColor(Vec4(0.5, 0.5, 0.8, 1))
Esempio n. 28
0
 def setMouseModeRelative(self, state):
     props = WindowProperties()
     if not state:
         props.setMouseMode(WindowProperties.MAbsolute)
     else:
         props.setMouseMode(WindowProperties.MRelative)
     self.targetWin.requestProperties(props)
Esempio n. 29
0
    def __init__(self):
        ShowBase.__init__(self)

        self.disableMouse()

        properties = WindowProperties()
        properties.setSize(1000, 750)
        self.win.requestProperties(properties)

        mainLight = DirectionalLight("main light")
        self.mainLightNodePath = render.attachNewNode(mainLight)
        self.mainLightNodePath.setHpr(45, -45, 0)
        render.setLight(self.mainLightNodePath)

        ambientLight = AmbientLight("ambient light")
        ambientLight.setColor(Vec4(0.2, 0.2, 0.2, 1))
        self.ambientLightNodePath = render.attachNewNode(ambientLight)
        render.setLight(self.ambientLightNodePath)

        render.setShaderAuto()

        self.environment = loader.loadModel("Models/Misc/environment")
        self.environment.reparentTo(render)

        self.tempActor = Actor("Models/PandaChan/act_p3d_chan",
                               {"walk": "Models/PandaChan/a_p3d_chan_run"})
        self.tempActor.getChild(0).setH(180)
        self.tempActor.reparentTo(render)
        self.tempActor.loop("walk")

        self.camera.setPos(0, 0, 32)
        self.camera.setP(-90)
Esempio n. 30
0
    def __init__(self, experiment_structure, profile_on=False):
        super().__init__()
        self.current_stim_num = 0
        self.stim_classes = experiment_structure['stim_classes']
        self.stim_values = experiment_structure['stim_values']
        self.stim_durations = experiment_structure['stim_durations']
        self.stim_change_times = np.cumsum(
            self.stim_durations)  #times to switch
        self.bgcolor = (1, 1, 1, 1)

        #Set up profiling if desired
        if profile_on:
            PStatClient.connect()

        #Window properties
        self.windowProps = WindowProperties()
        self.windowProps.setSize(512, 512)

        #Create scenegraph
        cm = CardMaker('card')
        cm.setFrameFullscreenQuad()
        self.card = self.aspect2d.attachNewNode(cm.generate())
        self.card.setScale(np.sqrt(8))
        self.card.setColor(self.bgcolor)  #make this an add mode

        #Set initial texture
        self.taskMgr.add(self.set_stim_task, "set_stimulus_class")