Exemplo n.º 1
0
    //Orientation of spherical interpolation
    public Vector3 SphereInterpolation(int currentKeyFrame, int currentFrame)
    {
        var totalKeyframe = downsamplePixelBlend.Count;
        var l = currentKeyFrame - nowBeginKeyFrame;
        var r = l + 1;
        var chosenPath = nowSmoothPath;
        var originSize = new Vector2(videoPlayer.targetTexture.width, videoPlayer.targetTexture.height);
        int downsampleWidth, downsampleHeight;

        opticalFlowCamerasController.GetDownsampleSize(out downsampleWidth, out downsampleHeight);
        var al = panelVideoController.PixelToAngle(opticalFlowCamerasController.PixelToOriginPixelIntValue(chosenPath[l], new Vector2(downsampleWidth, downsampleHeight), originSize));
        var tl = (float)(l + nowBeginKeyFrame) / totalKeyframe;
        var w  = Vector3.zero;

        if (r == chosenPath.Count)//Only the view of the last camera is left

        {
            w = panelVideoController.PixelToVector3(opticalFlowCamerasController.PixelToOriginPixelIntValue(chosenPath[l], new Vector2(downsampleWidth, downsampleHeight), originSize));
        }
        else
        {
            var ar         = panelVideoController.PixelToAngle(opticalFlowCamerasController.PixelToOriginPixelIntValue(chosenPath[r], new Vector2(downsampleWidth, downsampleHeight), originSize));
            var tr         = (float)(r + nowBeginKeyFrame) / totalKeyframe;
            var u          = panelVideoController.EulerAngleToVector3(panelVideoController.AngleToEulerAngle(al));
            var v          = panelVideoController.EulerAngleToVector3(panelVideoController.AngleToEulerAngle(ar));
            var percentage = (float)currentFrame / videoPlayer.frameCount;
            var tmp        = (percentage - tl) / (tr - tl);
            tmp = Mathf.Clamp(tmp, 0, 1);
            var theta = Vector3.Angle(u, v) * tmp * Mathf.Deg2Rad;
            w = Vector3.RotateTowards(u, v, theta, 1);
        }
        return(w);
    }
Exemplo n.º 2
0
    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;
    }