public void UpdatePips() { var nextSavedTime = DateTime.Now.Ticks; //Debug.Log("time between two UpdatePips: " + (nextSavedTime - savedTime) / 1e7); savedTime = DateTime.Now.Ticks; if (!isReady || pipList == null || (!canPauseUpdate && !videoPlayer.isPlaying)) { return; } int camNum = panelVideoController.cameraGroupNum; for (int camId = 0; camId < camNum; camId++) { var subCam = panelVideoController.cameraNFOVs[camId]; //UpdateCamera(smoothPath[camId], subCam); var mainCameraAngle = panelVideoController.EulerAngleToAngle(mainCamera.transform.eulerAngles); var subCamAngle = panelVideoController.EulerAngleToAngle(subCam.transform.eulerAngles); var deltaAngle = opticalFlowCamerasController.GetVector2Of2Pixels(mainCameraAngle, subCamAngle, 360); if (Mathf.Abs(deltaAngle.x) <= minHorizentalAngle && Mathf.Abs(deltaAngle.y) <= minVerticalAngle) { UpdatePipShowStatus(camId, true); } else { UpdatePipShowStatus(camId, false); //change pos var pipCenterPos = UpdatePipPos(subCam, pipList[camId]); //change rotation var alpha = UpdatePipRotation(subCam, pipList[camId], pipCenterPos); var rt = pipList[camId].GetComponent <RectTransform>(); //change tilt UpdatePipTilt(subCam, pipList[camId], pipCenterPos, alpha); //change depth UpdatePipDepth(subCam, pipList[camId]); } } }
//Limit the maximum moving speed to prevent the window from shaking too much public Vector3 ApplyMaxSpeedLimit(Vector3 fa, Vector3 fb, float t) { if (fa.Equals(fb)) { return(fa); } var originSize = new Vector2(videoPlayer.targetTexture.width, videoPlayer.targetTexture.height); int downsampleWidth, downsampleHeight; opticalFlowCamerasController.GetDownsampleSize(out downsampleWidth, out downsampleHeight); var cameraCalculate = manager.cameraCalculate; cameraCalculate.transform.forward = fa; var ea = cameraCalculate.transform.eulerAngles; var pa = panelVideoController.EulerAngleToPixel(ea); pa = opticalFlowCamerasController.PixelToOriginPixelFloatValue(pa, originSize, new Vector2(downsampleWidth, downsampleHeight)); cameraCalculate.transform.forward = fb; var eb = cameraCalculate.transform.eulerAngles; var pb = panelVideoController.EulerAngleToPixel(eb); pb = opticalFlowCamerasController.PixelToOriginPixelFloatValue(pb, originSize, new Vector2(downsampleWidth, downsampleHeight)); var v = opticalFlowCamerasController.GetVector2Of2Pixels(pa, pb, downsampleWidth); if (v.magnitude == 0) { return(fa); } v = v / v.magnitude * Mathf.Min(maxSpeed * t, v.magnitude); Debug.Log("ApplyMaxSpeedLimit"); Debug.Log(string.Format("t:{0}, v: {1}", t, v)); var p = pa + v; OpticalFlowCamerasController.NormalizePixelInRange(ref p.x, ref p.y, downsampleWidth, downsampleHeight); return(panelVideoController.PixelToVector3(opticalFlowCamerasController.PixelToOriginPixelFloatValue(p, new Vector2(downsampleWidth, downsampleHeight), originSize))); }