// Produce a RendererConfig based on current state of all the RendererComponents. public Orrb.RendererConfig GetConfig() { Orrb.RendererConfig config = new Orrb.RendererConfig(); foreach (ComponentInstance component_instance in components_) { Orrb.RendererComponent component_item = new Orrb.RendererComponent(); component_item.Name = component_instance.name; component_item.Type = component_instance.type; component_item.Path = component_instance.path; component_item.Config = component_instance.renderer_component.GetConfig(); config.Components.Add(component_item); } return(config); }
void Update() { switch (current_state_) { case State.Init: current_state_ = State.MainLoop; local_scene_instance_ = scene_manager_.CreateSceneInstance(); Orrb.RendererConfig renderer_config = LoadConfig(renderer_config_path_); // If the renderer config contains model and mapping paths, use them. if (renderer_config.ModelXmlPath.Length > 0) { model_xml_path_ = renderer_config.ModelXmlPath; } if (renderer_config.ModelMappingPath.Length > 0) { model_mapping_path_ = renderer_config.ModelMappingPath; } local_scene_instance_.Initialize(model_xml_path_, model_mapping_path_, asset_basedir_); foreach (Orrb.RendererComponent renderer_component in renderer_config.Components) { local_scene_instance_.GetComponentManager().AddComponent( renderer_component.Type, renderer_component.Name, renderer_component.Path, renderer_component.Config, mode_ == Mode.Server // Enable by default in server mode. ); } if (mode_ == Mode.Server) { // In server mode: resize the useless window, start the GRPC // server and turn on capture. Screen.SetResolution(50, 50, false); render_server_.Initialize(recorder_, local_scene_instance_); recorder_.Initialize(render_server_); } else { // In interactive mode: load state from files, set up active // cameras. local_scene_instance_.GetStateLoader().InitializeStateStream(model_state_path_); scene_cameras_ = local_scene_instance_.GetCameras(); ToggleCamera(current_camera_); } if (parent_pid_ != -1) { // If parent pid was provided start a parent watchdog coroutine. StartCoroutine(ParentProcessWatch()); } break; case State.MainLoop: default: if (mode_ == Mode.Server) { render_server_.ProcessRequests(); } else { local_scene_instance_.GetComponentManager().RunComponents(new RendererComponent.NullOutputContext()); } break; } }
void OnGUI() { if (current_state_ != State.MainLoop || mode_ == Mode.Server) { return; } GUI.skin.toggle.fontSize = 12; GUI.skin.label.fontSize = 12; local_scene_instance_.GetComponentManager().DrawSceneGUI(); local_scene_instance_.GetStateLoader().DrawSceneGUI(); GUILayout.BeginArea(new Rect(anchor_left_ ? 10 : Screen.width - 410, 10, 400, Screen.height - 20)); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (!anchor_left_) { GUILayout.FlexibleSpace(); } if (GUILayout.Button(show_ui_ ? "-" : "+", GUILayout.Width(20))) { show_ui_ = !show_ui_; } if (GUILayout.Button(anchor_left_ ? ">" : "<", GUILayout.Width(20))) { anchor_left_ = !anchor_left_; } if (anchor_left_) { GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(3); if (show_ui_) { GUILayout.BeginHorizontal(); config_save_path_ = GUILayout.TextField(config_save_path_, GUILayout.Width(310)); if (GUILayout.Button("Save config", GUILayout.Width(80))) { Orrb.RendererConfig config = local_scene_instance_.GetComponentManager().GetConfig(); JsonFormatter formatter = new JsonFormatter(JsonFormatter.Settings.Default); File.WriteAllText(config_save_path_, formatter.Format(config)); } GUILayout.EndHorizontal(); GUILayout.Space(3); GUILayout.BeginHorizontal(); if (GUILayout.Button(" < ", GUILayout.Width(20))) { PreviousCamera(); } if (GUILayout.Button(" > ", GUILayout.Width(20))) { NextCamera(); } GUILayout.Space(10); GUILayout.Label(scene_cameras_.Count > current_camera_ ? scene_cameras_[current_camera_].name : "-", GUILayout.Width(300)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(3); local_scene_instance_.GetStateLoader().DrawEditorGUI(); GUILayout.Space(3); local_scene_instance_.GetComponentManager().DrawEditorGUI(); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndArea(); }