def __init__(self, fps=DEFAULT_FPS, sim_settings=None, sync_sim=True, sim_dt=DEFAULT_SIM_DT): self.maxfps = fps self.sim_dt = sim_dt self.interval = 1.0 / self.maxfps if sim_settings is None: sim_settings = dict() self.sim_settings = sim_settings sim = None if constants.activate_simulation: self.sim_settings["auto_disable"] = False if "engine" not in self.sim_settings: self.sim_settings["engine"] = "ode" self.sim_settings["add_ground"] = True sim = SimWorld(**self.sim_settings) self.scene = Scene(False, sim=sim) self.keyboard_handler = dict() self.last_time = time.perf_counter() self.next_time = self.last_time + self.interval self.scene.global_vars["step"] = 0 self.scene.global_vars["fps"] = self.maxfps self.synchronize_updates = True self.synchronize_simulation = sync_sim and self.scene.sim is not None self.is_running = False self.visualize = False self.fixed_dt = False
def init_scenes(self): sim = None if constants.activate_simulation: sim_settings = dict() sim_settings["auto_disable"] = False sim_settings["engine"] = "ode" sim_settings["add_ground"] = True sim = SimWorld(**sim_settings) self.scene = EditorScene(self.visualize, sim) self.scene.added_scene_object.connect(self.relayAddedSceneObject) self.scene.reached_end_of_animation.connect(self.relayEndOfAnimation) self.scene.deleted_scene_object.connect(self.relayDeletedSceneObject) self.scene.update_scene_object.connect(self.relayUpdateSceneObject) self.scene.updated_animation_frame.connect(self.relayUpdateAnimationFrame) self.interaction.set_scene(self.scene) for view in self.views: view.mouse_click.connect(self.on_mouse_click) view.mouse_move.connect(self.on_mouse_move) view.mouse_release.connect(self.on_mouse_release) print("init scene")
def __init__(self, fps=60.0, sim_settings=None, sync_sim=True): self.maxfps = fps self.sim_dt = 1 / 200 self.interval = 1.0 / self.maxfps if sim_settings is None: sim_settings = dict() sim = None if constants.activate_simulation: sim_settings["auto_disable"] = False sim_settings["engine"] = "ode" sim_settings["add_ground"] = True sim = SimWorld(**sim_settings) self.scene = Scene(False, sim=sim) self.keyboard_handler = dict() self.current_time = time.perf_counter() self.last_time = self.current_time self.last_fps_update_time = self.current_time self.next_time = self.current_time + self.interval self.scene.global_vars["step"] = 0 self.scene.global_vars["fps"] = self.maxfps self.synchronize_simulation = sync_sim and self.scene.sim is not None self.isRunning = False
def __init__(self, width, height, setup_scene=None, title="PyGameApp", console_scale=0.5, camera_pose=None, draw_plot=False, sim_settings=None, sim_delta_time=SIM_DELTA_TIME, fps=DEFAULT_FPS): self.maxfps = fps self.interval = 1000.0 / self.maxfps #self.interval = 1 / self.maxfps self.width = width self.height = height self.aspect = float(width) / float(height) pygame.init() pygame.display.set_caption(title) self.surface = pygame.display.set_mode( (width, height), pygame.OPENGL | pygame.DOUBLEBUF, 16) self.graphics_context = GraphicsContext(width, height) self.console = Console([0, 0], scale=console_scale) self.plot_manager = PlotManager(self.width, self.height) sim = None if constants.activate_simulation: if sim_settings is None: sim_settings = dict() sim_settings["auto_disable"] = False sim_settings["engine"] = "ode" #self.sim_settings["engine"] = "bullet" sim_settings["add_ground"] = True sim = SimWorld(**sim_settings) self.scene = EditorScene(True, sim) self.scene._create_visual_reference_frame() self.scene.sim_delta_time = sim_delta_time if sim_settings is not None and "delta_time" in sim_settings: self.scene.sim_delta_time = sim_settings["delta_time"] #self.camera = OrbitingCamera() self.camera_controller = CameraController(self.graphics_context.camera, camera_pose) glClearColor(0.0, 0.0, 0.0, 1.0) self.reshape() self.keyboard_handler = dict() self.mouse_move_handler = dict() self.mouse_click_handler = dict() self.mouse_move_handler["camera_mouse"] = ( self.camera_controller.mouse_move, None) self.mouse_click_handler["camera_zoom"] = (self.camera_controller.zoom, None) self.draw_plot = draw_plot self.scene.global_vars["step"] = 0 if setup_scene is not None: setup_scene(app=self) self.last_time = pygame.time.get_ticks() self.next_time = self.last_time + self.interval
def __init__(self, width, height, title="GLUTApp", console_scale=0.5, camera_pose=None, maxfps=60, sim_settings=None, sync_sim=True, clear_color=DEFAULT_CLEAR_COLOR): self.maxfps = maxfps self.interval = 1.0 / self.maxfps self.width = width self.height = height self.aspect = float(width) / float(height) glutInit(sys.argv) pygame.init() # Create a double-buffer RGBA window glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) glutInitWindowSize(width, height) glutCreateWindow(str.encode(title)) glutReshapeFunc(self.reshape) glutDisplayFunc(self.update) glutKeyboardFunc(self.keyboard) glutMouseFunc(self.mouse) glutMotionFunc(self.mouse_motion) glutPassiveMotionFunc(self.passive_mouse_motion) glutMouseWheelFunc(self.mouse_wheel) glutKeyboardFunc(self.keyboard) self.shader_manager = ShaderManager() self.shader_manager.initShaderMap() self.primitive_manager = PrimitiveManager() self.console = IMGUIConsole([0, 0], scale=console_scale) self.show_console = True if sim_settings is None: sim_settings = dict() self.sim_settings = sim_settings sim = None if constants.activate_simulation: self.sim_settings["auto_disable"] = False self.sim_settings["engine"] = "ode" self.sim_settings["add_ground"] = True sim = SimWorld(**self.sim_settings) self.scene = EditorScene(True, sim=sim) self.main_renderer = MainRenderer() self.camera = OrbitingCamera() self.camera_controller = CameraController(self.camera, camera_pose) glClearColor(0.0, 0.0, 0.0, 1.0) self.keyboard_handler = dict() self.last_time = time.perf_counter() self.next_time = self.last_time + self.interval self.scene.global_vars["step"] = 0 self.scene.global_vars["fps"] = self.maxfps self.synchronize_simulation = sync_sim self.last_click_position = np.zeros(3) self.mutex = threading.Lock() self.synchronize_updates = True self.plot_manager = PlotManager(self.width, self.height) self.draw_plot = True self.fixed_dt = True self.clear_color = clear_color imgui.create_context() self.imgui_renderer = ProgrammablePipelineRenderer() self.io = imgui.get_io() self.io.display_size = width, height self.reshape(width, height)
def __init__(self, width, height, title="GLUTApp", console_scale=0.5, camera_pose=None, maxfps=60, sim_settings=None, sync_sim=True, use_shadows=True, use_frame_buffer=True, clear_color=DEFAULT_CLEAR_COLOR, sim_dt=1.0 / 200): self.maxfps = maxfps self.sim_dt = sim_dt self.interval = 1.0 / self.maxfps self.width = width self.height = height self.aspect = float(width) / float(height) glutInit(sys.argv) # needed for the console which uses font functions of pygame pygame.init() # Create a double-buffer RGBA window. glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) glutInitWindowSize(width, height) glutCreateWindow(str.encode(title)) #wglSwapIntervalEXT(0) disable vsync glutReshapeFunc(self.reshape) glutDisplayFunc(self.update) glutKeyboardFunc(self.keyboard) glutKeyboardFunc(self.keyboard) if sim_settings is None: sim_settings = dict() self.sim_settings = sim_settings self.graphics_context = GraphicsContext(width, height) self.console = Console([0, 0], scale=console_scale) sim = None if constants.activate_simulation: self.sim_settings["auto_disable"] = False self.sim_settings["engine"] = "ode" self.sim_settings["add_ground"] = True sim = SimWorld(**self.sim_settings) self.scene = EditorScene(True, sim=sim) self.camera_controller = CameraController(self.graphics_context.camera, camera_pose) glutMouseFunc(self.mouse_click) glutMotionFunc(self.mouse_motion) glutMouseWheelFunc(self.mouse_wheel) glClearColor(0.0, 0.0, 0.0, 1.0) self.keyboard_handler = dict() self.last_time = time.perf_counter() self.next_time = self.last_time + self.interval self.scene.global_vars["step"] = 0 self.scene.global_vars["fps"] = self.maxfps self.synchronize_simulation = sync_sim and self.scene.sim is not None self.last_click_position = np.zeros(3) self.mutex = threading.Lock() self.synchronize_updates = True self.enable_object_selection = False self.clear_color = clear_color self.use_shadows = use_shadows self.use_frame_buffer = use_frame_buffer self.reshape(width, height)