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]); } } }
public void OnDrag(PointerEventData data) { ifDragged = true; Vector2 nowPoint = data.position; var oldAngle = panelVideoController.EulerAngleToAngle(camEulerAngle); var delta = (-nowPoint + originPoint) / pixelPerDegree; var newAngle = oldAngle + delta; newAngle = new Vector2(Mo(newAngle.x, 360), Mathf.Min(Mathf.Max(-90, newAngle.y), 90)); mainCamera.transform.eulerAngles = panelVideoController.AngleToEulerAngle(newAngle); ChangedManually(); var dist = (nowPoint - prePointerDragPoint).magnitude; dragDistance += dist; prePointerDragPoint = nowPoint; }
//Update locator display public void UpdateLocator() { if (locatorTexture == null) { return; } var videoWidth = videoPlayer.targetTexture.width; var videoHeight = videoPlayer.targetTexture.height; var width = (int)Mathf.Min(locatorTextureMaxLength, videoWidth * locatorTextureMaxLength / videoHeight); var height = (int)Mathf.Min(locatorTextureMaxLength, videoHeight * locatorTextureMaxLength / videoWidth); var size = new Vector2(width, height); var originSize = new Vector2(videoWidth, videoHeight); var angle = panelVideoController.EulerAngleToAngle(mainNFOVCamera.transform.eulerAngles); var pixel = opticalFlowCamerasController.PixelToOriginPixelFloatValue(panelVideoController.AngleToPixel(angle), originSize, size); int ox = (int)locatorPos.x; int oy = (int)locatorPos.y; int nx = (int)pixel.x; int ny = (int)pixel.y; foreach (var u in locatorShape) { int xx = (int)(ox + u.x); int yy = (int)(oy + u.y); OpticalFlowCamerasController.NormalizePixelInRange(ref xx, ref yy, width, height); locatorTexture.SetPixel(xx, height - 1 - yy, Color.clear); } foreach (var u in locatorShape) { int xx = (int)(nx + u.x); int yy = (int)(ny + u.y); OpticalFlowCamerasController.NormalizePixelInRange(ref xx, ref yy, width, height); locatorTexture.SetPixel(xx, height - 1 - yy, Color.red); } locatorTexture.Apply(); locatorPos = new Vector2(nx, ny); }