/// Called by code that captures save icons without user intervention. public void ProgrammaticCaptureSaveIcon(Vector3 pos, Quaternion rot) { bool wasActive = CameraRig.gameObject.activeSelf; CameraRig.gameObject.SetActive(true); var state = new SaveIconTool.CameraRigState(); state.SetLossyTransform(pos, rot); var prev = CurrentCameraRigState; CurrentCameraRigState = state; // TODO XXX: Why is this Render() necessary? m_SaveIconScreenshotManager.LeftEye.Render(); //snapshot the current scene and push it to the preview window RenderWrapper wrapper = m_SaveIconScreenshotManager.gameObject.GetComponent <RenderWrapper>(); float ssaaRestore = wrapper.SuperSampling; wrapper.SuperSampling = m_superSampling; m_SaveIconScreenshotManager.RenderToTexture( SaveLoadScript.m_Instance.GetSaveIconRenderTexture()); // save off camera transform from the position we took the snapshot wrapper.SuperSampling = ssaaRestore; m_LastSaveCameraRigState = CurrentCameraRigState; CurrentCameraRigState = prev; CameraRig.gameObject.SetActive(wasActive); }
override public void UpdateTool() { base.UpdateTool(); bool bCanTakePicture = m_CurrentState == State.WaitingForPicture; if (bCanTakePicture && !m_EatInput && !m_ToolHidden && InputManager.m_Instance.GetCommandDown(InputManager.SketchCommands.Activate)) { //snapshot the current scene and push it to the preview window RenderWrapper wrapper = m_SaveIconScreenshotManager.gameObject.GetComponent <RenderWrapper>(); float ssaaRestore = wrapper.SuperSampling; wrapper.SuperSampling = m_superSampling; m_SaveIconScreenshotManager.RenderToTexture( SaveLoadScript.m_Instance.GetSaveIconRenderTexture()); wrapper.SuperSampling = ssaaRestore; // save off camera transform from the position we took the snapshot m_LastSaveCameraRigState = CurrentCameraRigState; AudioManager.m_Instance.PlaySaveSound(InputManager.Brush.m_Position); SketchControlsScript.m_Instance.IssueGlobalCommand(SketchControlsScript.GlobalCommands.SaveNew); m_CurrentState = State.Off; m_RequestExit = true; } else if (InputManager.m_Instance.GetCommandDown(InputManager.SketchCommands.MenuContextClick)) { m_RequestExit = true; } //repeated buzz on wand controller to notify user the dialog has popped up if (m_HapticCounterWand < m_HapticCountTotal) { m_HapticTimerWand -= Time.deltaTime; if (m_HapticTimerWand <= 0.0f) { ++m_HapticCounterWand; m_HapticTimerWand = m_HapticInterval; InputManager.m_Instance.TriggerHaptics(InputManager.ControllerName.Wand, m_HapticBuzzLength); } } if (m_HapticCounterBrush < m_HapticCountTotal) { m_HapticTimerBrush -= Time.deltaTime; if (m_HapticTimerBrush <= 0.0f) { ++m_HapticCounterBrush; m_HapticTimerBrush = m_HapticInterval; InputManager.m_Instance.TriggerHaptics(InputManager.ControllerName.Brush, m_HapticBuzzLength); } } }
static public bool StartVideoCapture(string filePath, VideoRecorder recorder, UsdPathSerializer usdPathSerializer, bool offlineRender = false) { // Only one video at a time. if (m_ActiveVideoRecording != null) { return(false); } // Don't start recording unless there is enough space left. if (!FileUtils.InitializeDirectoryWithUserError( Path.GetDirectoryName(filePath), "Failed to start video capture")) { return(false); } // Vertical video is disabled. recorder.IsPortrait = false; // Start the capture first, which may fail, so do this before toggling any state. // While the state below is important for the actual frame capture, starting the capture process // does not require it. int sampleRate = 0; if (AudioCaptureManager.m_Instance.IsCapturingAudio) { sampleRate = AudioCaptureManager.m_Instance.SampleRate; } if (!recorder.StartCapture(filePath, sampleRate, AudioCaptureManager.m_Instance.IsCapturingAudio, offlineRender, offlineRender ? App.UserConfig.Video.OfflineFPS : App.UserConfig.Video.FPS)) { OutputWindowScript.ReportFileSaved("Failed to start capture!", null, OutputWindowScript.InfoCardSpawnPos.Brush); return(false); } m_ActiveVideoRecording = recorder; // Perform any necessary VR camera rendering optimizations to reduce CPU & GPU workload // Debug reduce quality for capture. // XXX This should just be ADAPTIVE RENDERING if (m_DebugVideoCaptureQualityLevel != -1) { m_PreCaptureQualityLevel = QualityControls.m_Instance.QualityLevel; QualityControls.m_Instance.QualityLevel = m_DebugVideoCaptureQualityLevel; } App.VrSdk.SetHmdScalingFactor(m_VideoCaptureResolutionScale); // Setup SSAA RenderWrapper wrapper = recorder.gameObject.GetComponent <RenderWrapper>(); m_PreCaptureSuperSampling = wrapper.SuperSampling; wrapper.SuperSampling = m_SuperSampling; #if USD_SUPPORTED // Read from the Usd serializer if we're recording offline. Write to it otherwise. m_UsdPathSerializer = usdPathSerializer; if (!offlineRender) { m_UsdPath = SaveLoadScript.m_Instance.SceneFile.Valid ? Path.ChangeExtension(filePath, "usda") : null; m_RecordingStopwatch = new System.Diagnostics.Stopwatch(); m_RecordingStopwatch.Start(); if (!m_UsdPathSerializer.StartRecording(m_UsdPath)) { UnityEngine.Object.Destroy(m_UsdPathSerializer); m_UsdPathSerializer = null; } } else { recorder.SetCaptureFramerate(Mathf.RoundToInt(App.UserConfig.Video.OfflineFPS)); m_UsdPath = null; if (m_UsdPathSerializer.Load(App.Config.m_VideoPathToRender)) { m_UsdPathSerializer.StartPlayback(); } else { UnityEngine.Object.Destroy(m_UsdPathSerializer); m_UsdPathSerializer = null; } } #endif return(true); }