Esempio n. 1
0
    def __init__(self, scene, size=(800, 600), zNear=0.1, zFar=1000.0, fov=40.0, shadowing=False, interactive=True,
                 showPosition=False, cameraMask=None):

        super(Viewer, self).__init__()

        self.__dict__.update(scene=scene, size=size, fov=fov, shadowing=shadowing,
                             zNear=zNear, zFar=zFar, interactive=interactive, showPosition=showPosition,
                             cameraMask=cameraMask)

        if cameraMask is not None:
            self.cam.node().setCameraMask(self.cameraMask)
        lens = self.cam.node().getLens()
        lens.setFov(self.fov)
        lens.setNear(self.zNear)
        lens.setFar(self.zFar)

        # Change window size
        wp = WindowProperties()
        wp.setSize(size[0], size[1])
        wp.setTitle("Viewer")
        wp.setCursorHidden(True)
        self.win.requestProperties(wp)

        self.disableMouse()

        self.time = 0
        self.centX = self.win.getProperties().getXSize() / 2
        self.centY = self.win.getProperties().getYSize() / 2

        # key controls
        self.forward = False
        self.backward = False
        self.fast = 1.0
        self.left = False
        self.right = False
        self.up = False
        self.down = False
        self.up = False
        self.down = False

        # sensitivity settings
        self.movSens = 2
        self.movSensFast = self.movSens * 5
        self.sensX = self.sensY = 0.2

        self.cam.setP(self.cam, 0)
        self.cam.setR(0)

        # reset mouse to start position:
        self.win.movePointer(0, int(self.centX), int(self.centY))

        # Reparent the scene to render.
        self.scene.scene.reparentTo(self.render)

        # Task
        self.globalClock = ClockObject.getGlobalClock()
        self.taskMgr.add(self.update, 'viewer-update')

        self._addDefaultLighting()
        self._setupEvents()
Esempio n. 2
0
    def __init__(self, scene, size=(800, 600), zNear=0.1, zFar=1000.0, fov=40.0, shadowing=False, showPosition=False,
                 cameraTransform=None, cameraMask=None):

        ShowBase.__init__(self)
        
        self.__dict__.update(scene=scene, size=size, fov=fov,
                             zNear=zNear, zFar=zFar, shadowing=shadowing, showPosition=showPosition,
                             cameraTransform=cameraTransform, cameraMask=cameraMask)

        # Find agent and reparent camera to it
        self.agent = self.scene.scene.find('**/agents/agent*/+BulletRigidBodyNode')
        self.camera.reparentTo(self.agent)
        if self.cameraTransform is not None:
            self.camera.setTransform(cameraTransform)

        if cameraMask is not None:
            self.cam.node().setCameraMask(self.cameraMask)
        lens = self.cam.node().getLens()
        lens.setFov(self.fov)
        lens.setNear(self.zNear)
        lens.setFar(self.zFar)

        # Change window size
        wp = WindowProperties()
        wp.setSize(size[0], size[1])
        wp.setTitle("Controller")
        wp.setCursorHidden(True)
        self.win.requestProperties(wp)

        self.disableMouse()

        self.time = 0
        self.centX = wp.getXSize() / 2
        self.centY = wp.getYSize() / 2
        self.win.movePointer(0, int(self.centX), int(self.centY))

        # key controls
        self.forward = False
        self.backward = False
        self.fast = 2.0
        self.left = False
        self.right = False

        # sensitivity settings
        self.movSens = 2
        self.movSensFast = self.movSens * 5
        self.sensX = self.sensY = 0.2

        # Reparent the scene to render.
        self.scene.scene.reparentTo(self.render)

        self.render.setAntialias(AntialiasAttrib.MAuto)

        # Task
        self.globalClock = ClockObject.getGlobalClock()
        self.taskMgr.add(self.update, 'controller-update')

        self._addDefaultLighting()
        self._setupEvents()
    def _lock_format(self, task):
        """Forces the window to remain the same size.  Called every tick.

        Returns
        -------
        task function
            Returns a 'continue' message to the task manager running this task, each tick."""

        if self.win.getXSize() != 800 or self.win.getYSize() != 600:
            wp = WindowProperties()
            wp.setSize(800, 600)
            self.win.requestProperties(wp)
        return task.cont
Esempio n. 4
0
    def confirm_command(self):
        # 16:9
        if self.radio_button_var[0] == 0:
            props = WindowProperties()
            props.clearSize()
            props.setTitle('Chess Classic')
            props.setSize(DEFAULT16x9SCREEN_W, DEFAULT16x9SCREEN_H)
            #props.setFixedSize(True)
            self.render_fsm_ref.win.requestProperties(props)

        # 4:3
        if self.radio_button_var[0] == 1:
            props = WindowProperties()
            props.clearSize()
            props.setTitle('Chess Classic')
            props.setSize(DEFAULT4x3SCREEN_W, DEFAULT4x3SCREEN_H)
            #props.setFixedSize(True)
            self.render_fsm_ref.win.requestProperties(props)
Esempio n. 5
0
    def __init__(self):
        ShowBase.__init__(self)

        self.cur_window_width = DEFAULT16x9SCREEN_W
        self.cur_window_height = DEFAULT16x9SCREEN_H

        props = WindowProperties()
        props.clearSize()
        props.setTitle('Chess Classic')
        props.setSize(self.cur_window_width, self.cur_window_height)
        #props.setFixedSize(True)
        self.win.requestProperties(props)

        self.taskMgr.add(self.mouse_task, 'mouseTask')
        self.accept("mouse1", self.mouse_press)
        self.accept("mouse1-up", self.mouse_release)
        self.accept("escape", sys.exit)

        self.cur_state = None

        # user data obtain fucntins
        self.process_login = None
        self.process_find_player = None
        self.process_registration = None
        self.process_skin_select = None
        self.process_confirm_auth = None
        self.process_continue_online_game = None

        self.process_offline_with_firend = None
        self.process_offline_with_computer = None
        self.process_reset_save_data_friend = None
        self.process_reset_save_data_computer = None
        self.on_offline_game_exit = None
        self.process_set_move_player = None

        self.on_application_exit = None

        self.on_press_giveup_button = None
        self.get_hist_movement_manager = None

        self.get_cur_turn_side = None

        self.whiteside_pack_name = None
        self.blackside_pack_name = None

        self.is_client_connected_to_server = False
        self.is_game_played = False

        self.on_update_now = False
        self.is_clearing = False
        self.state_priority = -1
        self.cur_state_key = ""
        self.on_game_exit = None
        self.side = Side.WHITE

        self.login = ''
        self.email = ''

        self.avail_packs = ['pack0']

        # sound
        self.sound = Sound(self)

        # play default
        self.sound.turn(SoundTypes.MAIN, False)
        self.sound.turn(SoundTypes.WIN, False)

        self.check_move_func_for_pawn_swap = None

        self.win_pack = None

        self.prev_render_not_message_state_key = None

        self.message = None

        self.get_loacal_player_rating = None

        self.init_sky_sphere()
        self.camera_m = CameraMenu(base.camera, base.camLens)
        self.taskMgr.add(self.camera_m.update_on_task_rotate, 'camRotTask')
        self.on_match_making_state = None
        self.start_game_by_pairing = None

        self.refresh_matchmaking_pairlist = None
Esempio n. 6
0
 def prepare_window(self):
     """Prepares the window size property"""
     properties = WindowProperties()
     properties.setSize(1700, 700)
     self.win.requestProperties(properties)