def __init__(self, mounted_on_desk, *args, **kwargs): super().__init__(*args, **kwargs) # Remove current exit key (make it available for customised setting) # HACK: There is no 'NONE_KEY' defined, so setting the escape key to 0 # could cause undefined behaviour, as it is undocomunted. During # the tests, this setting did not activate any of the keys, so it # is a working work-around. (At least on Arch Linux) bge.logic.setExitKey(0) # Place the window window_command = ['sleep 1'] window_command.append('wmctrl -r :ACTIVE: ' '-e 0,{},{},{},{}'.format(WINDOW_DISPLAY_X, WINDOW_DISPLAY_Y, WINDOW_RESOLUTION_X, WINDOW_RESOLUTION_Y)) if WINDOW_FULL_SCREEN: window_command.append('wmctrl -r :ACTIVE: -b add,fullscreen') Popen(args = ' && '.join(window_command), shell = True, stdin = PIPE, stderr = PIPE, universal_newlines=True) # Create folder structures if they don't exists yet makedirs(INT_TEMPORARY_FOLDER, exist_ok=True) makedirs(INT_PERMANENT_FOLDER, exist_ok=True) makedirs(INT_TEMP_SAVE_FOLDER, exist_ok=True) makedirs(INT_AUTO_SAVE_FOLDER, exist_ok=True) ## Start input-daemon #self._lines_queue = Queue() #def get_input(): # print('start') # for line in iter(stdin.readline, ''): # print('try') # self._lines_queue.put(line) # print('stop') # stdin.close() #Thread(name = 'inputd', # target = get_input).start() #self._should_restart = False #self._should_shut_down = False try: # Create connection self._connection = Connection(this_host=COMM_THIS_HOST, this_port=COMM_THIS_PORT, buffer_size=BUFFER_SIZE, device=COMM_DEVICE_NAME) self._connection.connect(other_host=COMM_OTHER_HOST, other_port=COMM_OTHER_PORT) # If connection is not imported except NameError: pass # Create a new instance of the leap-motion controller self._leap_controller = leap_controller = Leap.Controller() # Create a new instance of the oculus-rift controller self._rift_controller = oculus.OculusRiftDK2(head_factor =RIFT_MULTIPLIER, head_shift_y=RIFT_POSITION_SHIFT_Y, head_shift_z=RIFT_POSITION_SHIFT_Z) # Enable HMD optimisation if MOUNTED_ON_HEAD: leap_controller.set_policy(Leap.Controller.POLICY_OPTIMIZE_HMD) ## Enable circle gesture #leap_controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE) ## Configure circle gesture #leap_controller.config.set("Gesture.Circle.MinRadius", 100.0) #leap_controller.config.set("Gesture.Circle.MinArc", radians(359)) ## Configure swipe gesture #leap_controller.config.set("Gesture.Swipe.MinLength", 200.0) #leap_controller.config.set("Gesture.Swipe.MinVelocity", 750) #leap_controller.config.save() # Create a reference to the blender scene self._blender_scene = blender_scene = bge.logic.getCurrentScene() bge.logic.addScene(OBJ_HUD_SCENE, 1) # HUD scene has to be set up self._preprocess = True # Make references to blender objects self._camera = blender_scene.active_camera self._origo = blender_scene.objects[OBJ_GLOBAL] # Create hands self._hands = Hands(self._prototype_creator(OBJ_PROTOTYPE_FINGER)) # Create surface blender object from prototype and # store its reference inside a Surface instance # HACK: Surface arguments should be protoype_creator methods, instead of # actual objects, but right now, prototyping the surface object # with its armature and all bones are not copying.. or something # like that.. self._surface = Surface(blender_scene.objects[OBJ_PROTOTYPE_SURFACE], blender_scene.objects[OBJ_PROTOTYPE_VERTEX_ALL], COLOR_GEOMETRY_DARK) # TODO: fake casted shadow with negative lamp: # https://www.youtube.com/watch?v=iJUlqwKEdVQ # HACK: yuck.. this is getting out of hands now :(:(:( self._vertex_origo = blender_scene.objects[OBJ_PROTOTYPE_VERTEX_ALL] # EXPERIMENTAL self._armature_control = blender_scene.objects[OBJ_ARMATURE_CONTROL] self._armature = blender_scene.objects[OBJ_ARMATURE] self._geometry = blender_scene.objects[OBJ_GEOMETRY] # EXPERIMENTAL # Set position setter # If DESK if mounted_on_desk: self._positioner = self._positioner_on_desk self._selector = self._select_right_hand_on_desk # If HEAD else: self._positioner = self._positioner_on_head self._selector = self._select_right_hand_on_head # Last time saved self._auto_save_time = self._origo[PROP_TEXT_TIMER]