Example #1
0
 public void Start()
 {
     fadeObject = new fGameObject(GameObject.CreatePrimitive(PrimitiveType.Sphere), FGOFlags.NoFlags);
     //fadeObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     fadeObject.SetMaterial(MaterialUtil.CreateFlatMaterial(Color.black, 0.0f), true);
     fadeObject.SetName("fade_sphere");
     UnityUtil.ReverseMeshOrientation(fadeObject.GetMesh());
     fadeObject.SetParent(UseCamera.GameObject(), false);
     fadeObject.SetLayer(FPlatform.HUDLayer);
 }
Example #2
0
        IEnumerator SmoothOrbitTo(float azimuth, float altitude, float duration)
        {
            yield return(null);

            var      manip  = UseCamera.Manipulator();
            Vector2f target = new Vector2f(azimuth, altitude);

            DOTween.To(() => { return(new Vector2f(manip.TurntableAzimuthD, manip.TurntableAltitudeD)); },
                       (v) => { manip.SceneOrbit(UseScene, UseCamera, v.x, v.y, true); },
                       target, duration);
        }
Example #3
0
        /// <summary>
        /// Animate camera so that centerPt moves to center of camera, and height is visible.
        /// Camera target is also set to centerPt
        /// </summary>
        public void AnimateFitHeightToView(Vector3f centerPt, float height, CoordSpace eSpace, float duration)
        {
            if (eSpace != CoordSpace.WorldCoords)
            {
                height = UseScene.ToWorldDimension(height);
            }
            float    fFitDistW   = UseCamera.Manipulator().GetFitHeightCameraDistance(height);
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? centerPt : UseScene.ToWorldP(centerPt);

            AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
        }
        public UCScanBook(MainForm mainForm, UCMainUserMeniu ucMainUserMeniu)
        {
            camera = new UseCamera();

            InitializeComponent();
            this.mainForm        = mainForm;
            this.ucMainUserMeniu = ucMainUserMeniu;

            recognition = new BarcodeRecognition(cameraBox, camera);
            recognition.OnBarcodeRecognised += Recognition_OnBarcodeRecognised;
        }
Example #5
0
        public UCLogin(MainForm mainForma)
        {
            InitializeComponent();
            mainForm = mainForma;

            faceRecognition = new FaceRecognition();
            camera          = new UseCamera();

            if (faceRecognition.usersIds.Count == 0)
            {
                btnTakePicture.Enabled = false;
            }
        }
Example #6
0
        // set view position and target location explicitly, during a dip-to-black transition
        public void Teleport(Vector3f vMoveToLocation, Vector3f vNewTargetLocation)
        {
            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f newPos = vMoveToLocation;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothDipToBlack(0.75f));
            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, 0.75f));
            StartCoroutine(
                SmoothMoveTarget(vNewTargetLocation + delta, 0.1f));
        }
Example #7
0
        public void PanFocus(Vector3f v)
        {
            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f curDir = UseCamera.GetWorldFrame().Z;
            float    fDist  = Vector3.Dot((v - curPos), curDir);
            Vector3f newPos = v - fDist * curDir;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, 0.5f));
            StartCoroutine(
                SmoothMoveTarget(v + delta, 0.1f));
        }
    public void DoAlignToCanvas()
    {
        if (UseCamera.orthographic &&
            Mathfx.Approximately(UseCamera.orthographicSize, 0))
        {
            return;
        }

        var screenSize = GetGameViewSize();
        var bottomLeft = UseCamera.ScreenToWorldPoint(new Vector3(0, 0, UseCamera.nearClipPlane));
        var topRight   = UseCamera.ScreenToWorldPoint(new Vector3(screenSize.x, screenSize.y, UseCamera.farClipPlane));

        if (Boundaries == null)
        {
            return;
        }

        switch (HorizontalAlign)
        {
        case HorizontalAlignType.Left:
            _offsetX = bottomLeft.x + transform.lossyScale.x * (-Boundaries.center.x + Boundaries.size.x / 2);
            break;

        case HorizontalAlignType.Right:
            _offsetX = topRight.x + transform.lossyScale.x * (-Boundaries.center.x - Boundaries.size.x / 2);
            break;

        case HorizontalAlignType.Center:
            _offsetX = (topRight.x + bottomLeft.x) / 2 + transform.lossyScale.x * -Boundaries.center.x;
            break;
        }

        switch (VerticalAlign)
        {
        case VerticalAlignType.Bottom:
            _offsetY = bottomLeft.y + transform.lossyScale.x * (-Boundaries.center.y + (Boundaries.size.y / 2));
            break;

        case VerticalAlignType.Top:
            _offsetY = topRight.y + transform.lossyScale.x * (-Boundaries.center.y - (Boundaries.size.y / 2));
            break;

        case VerticalAlignType.Center:
            _offsetY = (topRight.y + bottomLeft.y) / 2 + transform.lossyScale.x * -Boundaries.center.y;
            break;
        }

        transform.position = new Vector3(_offsetX, _offsetY, transform.position.z);
    }
Example #9
0
        public UCRegister(MainForm mainForma)
        {
            InitializeComponent();
            mainForm = mainForma;

            camera           = new UseCamera();
            faceRegistration = new FaceRegistration(imageCountPerPerson);

            if (camera.Camera == null)
            {
                camera.TurnOn();

                faceRegistration.Display(picCamera, camera.Camera);
            }
        }
Example #10
0
        // should not use this anymore...
        public void PanFocus(Vector3f focusPoint, CoordSpace eSpace = CoordSpace.WorldCoords, float duration = 0.5f)
        {
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? focusPoint : UseScene.ToWorldP(focusPoint);

            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f curDir = UseCamera.GetWorldFrame().Z;
            float    fDist  = Vector3.Dot((focusPointW - curPos), curDir);
            Vector3f newPos = focusPointW - fDist * curDir;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, duration));
            StartCoroutine(
                SmoothMoveTarget(focusPointW + delta, duration / 10.0f));
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (UseLidar != false)
            {
                hash ^= UseLidar.GetHashCode();
            }
            if (UseRadar != false)
            {
                hash ^= UseRadar.GetHashCode();
            }
            if (UseCamera != false)
            {
                hash ^= UseCamera.GetHashCode();
            }
            if (TrackerMethod.Length != 0)
            {
                hash ^= TrackerMethod.GetHashCode();
            }
            if (DataAssociationMethod.Length != 0)
            {
                hash ^= DataAssociationMethod.GetHashCode();
            }
            if (GateKeeperMethod.Length != 0)
            {
                hash ^= GateKeeperMethod.GetHashCode();
            }
            hash ^= prohibitionSensors_.GetHashCode();
            if (MaxLidarInvisiblePeriod != 0D)
            {
                hash ^= MaxLidarInvisiblePeriod.GetHashCode();
            }
            if (MaxRadarInvisiblePeriod != 0D)
            {
                hash ^= MaxRadarInvisiblePeriod.GetHashCode();
            }
            if (MaxCameraInvisiblePeriod != 0D)
            {
                hash ^= MaxCameraInvisiblePeriod.GetHashCode();
            }
            if (MaxCachedFrameNum != 0L)
            {
                hash ^= MaxCachedFrameNum.GetHashCode();
            }
            return(hash);
        }
Example #12
0
        /// <summary>
        /// Animate camera so that centerPt moves to center of camera, and width is visible.
        /// Camera target is also set to centerPt
        /// </summary>
        public void AnimateFitWidthToView(Vector3f centerPt, float width, CoordSpace eSpace, float duration)
        {
            if (eSpace != CoordSpace.WorldCoords)
            {
                width = UseScene.ToWorldDimension(width);
            }
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? centerPt : UseScene.ToWorldP(centerPt);

            if (UseCamera.IsOrthographic)
            {
                float targetHeight = UseCamera.AspectRatio * width;
                AnimatePanZoomFocusOrtho(focusPointW, CoordSpace.WorldCoords, targetHeight, duration);
            }
            else
            {
                float fFitDistW = UseCamera.Manipulator().GetFitWidthCameraDistance(width);
                AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
            }
        }
Example #13
0
        /// <summary>
        /// Ortho variant of Turntable-rotate to set azimuth/altitude, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateOrbitZoomFocusToOrtho(float toAzimuth, float toAltitude, float targetHeight, Vector3f toTargetS, float duration = 0.25f)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

            Vector3f startTargetS     = UseScene.ToSceneP(UseCamera.GetTarget());
            float    startAltitude    = UseCamera.Manipulator().TurntableAltitudeD;
            float    startAzimuth     = UseCamera.Manipulator().TurntableAzimuthD;
            float    startOrthoHeight = UseCamera.OrthoHeight;

            Action <float> tweenF = (t) => {
                Vector3f newTargetS = Vector3f.Lerp(startTargetS, toTargetS, t);
                //Vector3f newTargetW = UseScene.ToWorldP(newTargetS);
                //UseCamera.Manipulator().ScenePanFocus(UseScene, UseCamera, newTargetW, false);
                UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);

                float alt = MathUtil.Lerp(startAltitude, toAltitude, t);
                float az  = MathUtil.Lerp(startAzimuth, toAzimuth, t);
                UseCamera.Manipulator().SceneOrbit(UseScene, UseCamera, az, alt, true);

                float curHeight = UseCamera.OrthoHeight;
                float toHeight  = MathUtil.Lerp(startOrthoHeight, targetHeight, t);
                float dh        = toHeight - curHeight;
                UseCamera.Manipulator().SceneZoom(UseScene, UseCamera, -dh);
            };

            if (duration > 0)
            {
                TweenAnimator anim = new TweenAnimator(tweenF, duration)
                {
                    OnCompletedF = () => { UseCamera.SetTargetVisible(false); }
                };
                UseScene.ObjectAnimator.Register(anim);
            }
            else
            {
                tweenF(1.0f);
            }
        }
Example #14
0
        IEnumerator Teleport_Level_Helper(Vector3 vMoveToLocation, Vector3 vNewTargetLocation, Vector3 vPivotAround, float fLevelRotateAngle, float duration)
        {
            yield return(null);

            Sequence mySequence = DOTween.Sequence();

            mySequence.Append(
                fadeObject.GetComponent <MeshRenderer>().material.DOFade(1.0f, duration / 3.0f).OnComplete(() => {
                GameObject sceneGO = UseScene.RootGameObject;

                // set target to new target location explicitly, then reset orbit altitude.
                // now we are level with ground but not at location
                CameraTarget = vPivotAround;
                UseCamera.Manipulator().ResetSceneOrbit(UseScene, false, true, true);

                // add planar rotation if we need it
                if (fLevelRotateAngle != 0)
                {
                    UseCamera.Manipulator().SceneOrbit(UseScene, UseCamera, fLevelRotateAngle, 0.0f);
                }

                // figure out the pan that we would apply to camera, opposite is pan to scene
                Vector3 delta = UseCamera.transform.position - vMoveToLocation;
                sceneGO.transform.position += delta;
                // also have to shift scene target pos
                CameraTarget = vNewTargetLocation + delta;

                UseCamera.gameObject.GetComponent <CameraTarget>().ShowTarget = true;
            }));
            mySequence.AppendInterval(duration / 3.0f);
            mySequence.Append(
                fadeObject.GetComponent <MeshRenderer>().material.DOFade(0.0f, duration / 3.0f));

            // add a delay before we hide target
            mySequence.AppendInterval(1.0f);
            mySequence.OnComplete(() => {
                UseCamera.gameObject.GetComponent <CameraTarget>().ShowTarget = false;
            });
        }
Example #15
0
        /// <summary>
        /// Ortho variant of Tumble scene to given orientation, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateTumbleZoomFocusToOrtho(Quaternionf toOrientation, float targetHeight, Vector3f toTargetS, float duration = 0.25f)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

            Vector3f startTargetS     = UseScene.ToSceneP(UseCamera.GetTarget());
            Frame3f  startF           = UseScene.SceneFrame;
            float    startOrthoHeight = UseCamera.OrthoHeight;

            Action <float> tweenF = (t) => {
                Vector3f newTargetS = Vector3f.Lerp(startTargetS, toTargetS, t);
                UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);

                Quaternionf rot = Quaternion.Slerp(startF.Rotation, toOrientation, t);
                UseScene.RootGameObject.SetLocalRotation(rot);

                float curHeight = UseCamera.OrthoHeight;
                float toHeight  = MathUtil.Lerp(startOrthoHeight, targetHeight, t);
                float dh        = toHeight - curHeight;
                UseCamera.Manipulator().SceneZoom(UseScene, UseCamera, -dh);
            };

            if (duration > 0)
            {
                TweenAnimator anim = new TweenAnimator(tweenF, duration)
                {
                    OnCompletedF = () => { UseCamera.SetTargetVisible(false); }
                };
                UseScene.ObjectAnimator.Register(anim);
            }
            else
            {
                tweenF(1.0f);
            }
        }