Beispiel #1
0
    private void Start()
    {
        objectController.objectTouched.AddListener(OnVirtualButtonClicked);

        _child1 = imageGutterCanvasGameObject.transform.GetChild(0);
        _child2 = imageGutterCanvasGameObject.transform.GetChild(1);

        _localScale = _child1.localScale;

        _wikitudeCamera = FindObjectOfType <WikitudeCamera>();
    }
Beispiel #2
0
    private IEnumerator Restart()
    {
        /* Destroy the existing ImageTracker and WikitudeCamera before creating them again. */
        Destroy(CurrentImageTracker.gameObject);
        Destroy(Camera.gameObject);

        /* Wait a frame before recreating everything again. */
        yield return(null);

        Camera = GameObject.Instantiate(WikitudeCameraPrefab).GetComponent <WikitudeCamera>();
        CurrentImageTracker = GameObject.Instantiate(ImageTrackerPrefab).GetComponent <ImageTracker>();
        GameObject.Instantiate(WikitudeEyePrefab).transform.SetParent(CurrentImageTracker.transform.GetChild(0));
    }
    private IEnumerator Restart()
    {
        Destroy(CurrentImageTracker.gameObject);
        Destroy(Camera.gameObject);

        // Wait a frame before recreating everything again
        yield return(null);

        // WikitudeCamera prefab has Camera 1 API enabled by default
        // If that were not the case, it could be changed on the prefab,
        // before creating the actual GameObject
        Camera = GameObject.Instantiate(WikitudeCameraPrefab).GetComponent <WikitudeCamera>();
        CurrentImageTracker = GameObject.Instantiate(ImageTrackerPrefab).GetComponent <ImageTracker>();
        GameObject.Instantiate(WikitudeEyePrefab).transform.SetParent(CurrentImageTracker.transform.GetChild(0));
    }
    void Awake()
    {
        // Initialize Wikitude Camera as Front Facing
        ArCam = GetComponent <WikitudeCamera>();
        ArCam.DevicePosition = CaptureDevicePosition.Front;
        Debug.Log("Using front facing camera");
        Vector2 exposurepoint = new Vector2(0.15f, 0.2f);

        ArCam.ExposeAtPointOfInterest(exposurepoint, CaptureExposureMode.ContinuousAutoExpose);
                #if UNITY_IOS
        MiraiOSBridge.ForceBrightness();
                #endif

        Screen.orientation = ScreenOrientation.LandscapeLeft;
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        if (SceneManager.GetActiveScene().name == "yiyou")
        {
            CameraDevice.Instance.SetFocusMode(Vuforia.CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
        }
        else
        {
#if UNITY_ANDROID
            WikitudeCamera wikitudeCamera = GameObject.FindObjectOfType <WikitudeCamera>();

            wikitudeCamera.FocusMode = CaptureFocusMode.ContinuousAutoFocus;
#endif
        }
    }
Beispiel #6
0
        /// <summary>
        ///Manges the Handoff between states TrackingFound -> TrackigLost..
        /// </summary>
        /// <param name="notSpectator">If set to <c>true</c> not spectator.</param>
        /// <param name="isRotationalOnly">If set to <c>true</c> is rotational only.</param>
        private void SetParenting(bool notSpectator, bool isRotationalOnly)
        {
            // Regular AR Cam rig
            if (notSpectator)
            {
                // Set Correct headPivot offsets and transforms
                cameraRig.transform.rotation = MiraArController.Instance.cameraRig.transform.rotation;
                cameraRig.transform.SetParent(MiraArController.Instance.cameraRig.transform);

                if (!isRotationalOnly)
                {
                    WikitudeCamera wikiCamera = FindObjectOfType <WikitudeCamera>();
                    if (wikiCamera.StaticCamera)
                    {
                        wikiCamera.transform.SetParent(cameraRig.transform);
                        wikiCamera.transform.position = MiraArController.Instance.transform.position;
                        wikiCamera.transform.rotation = MiraArController.Instance.transform.rotation;
                    }
                }
                cameraRig.transform.SetParent(null);
            }
            else
            {
                if (!isRotationalOnly)
                {
                    WikitudeCamera wikiCamera = FindObjectOfType <WikitudeCamera>();
                    cameraRig.transform.rotation = wikiCamera.transform.rotation;
                    cameraRig.transform.SetParent(wikiCamera.transform);
                    cameraRig.transform.localPosition = Vector3.zero;

                    MiraArController.Instance.transform.SetParent(cameraRig.transform);
                    MiraArController.Instance.transform.localPosition = Vector3.zero;
                    MiraArController.Instance.transform.localRotation = Quaternion.identity;
                }
            }

            if (notSpectator)
            {
                cameraRig.transform.SetParent(MiraArController.Instance.transform);

                // Create AR Cam
                if (Left_Eye == null)
                {
                    Right_Eye = CreateCameraforEachEye(CameraNames.Right_Camera);
                    Left_Eye  = CreateCameraforEachEye(CameraNames.Left_Camera);
                }
            }
        }
Beispiel #7
0
        private void Start()
        {
            WikitudeCamera wikiCam = MiraWikitudeManager.Instance.ArCam;

            if (wikiCam)
            {
                bool isStaticCamera = wikiCam.StaticCamera;

                if (isStaticCamera)
                {
                    // Deactivate handoff for Static Camera
                    MiraArController.Instance.cameraRig.GetComponent <CamGyro>().camGyroActive = true;
                    GetComponent <InverseGyroController>().enabled = false;
                    this.enabled = false;
                }
            }

            InitializeEvents();
            // Reference the main Camera
            mainCamera = MiraWikitudeManager.Instance.gameObject.transform;
            // Initialize the positionBuffer
            positionBuffer = new Queue <Vector3>(bufferSize);
            // Initialize the rotationBuffer
            rotationBuffer = new Queue <Quaternion>(bufferSize);

            // Initialize Rotational Setup
            StartCoroutine(RotationalSetup());
            // Initialize Start Position
            camRigStartPosition *= (1 / MiraArController.scaleMultiplier);
            // Initialize head pivot
            CamGyro[] sceneCamGyros = GameObject.FindObjectsOfType <CamGyro>();
            if (sceneCamGyros.Length > 1)
            {
                foreach (CamGyro camGyro in sceneCamGyros)
                {
                    if (camGyro.gameObject.name == "HeadPivotContainer")
                    {
                        cameraRig = camGyro.gameObject.transform;
                    }
                }
            }

            cameraRig   = GameObject.FindObjectOfType <CamGyro>().transform;
            isSpectator = MiraArController.Instance.isSpectator;
        }
    public void Start()
    {
        scaleMultiplier = 1 / MiraArController.scaleMultiplier;
        ArCam           = gameObject.GetComponent <WikitudeCamera>();

        if (MiraArController.Instance.isSpectator == false)
        {
            ArCam.DevicePosition = CaptureDevicePosition.Front;
            Debug.Log("Using front facing camera");
            Vector2 exposurepoint = new Vector2(0.15f, 0.2f);
            ArCam.ExposeAtPointOfInterest(exposurepoint, CaptureExposureMode.ContinuousAutoExpose);

            rotationalOffset = Quaternion.Euler(-30, 0, 0);
            // positionalOffset = new Vector3(-5.2f, -0.93599f, -5.0f) * scaleMultiplier;
            positionalOffset = new Vector3(-6.006f, -2.846f, -3.689f) * scaleMultiplier;
        }
        else
        {
            Camera specCam = gameObject.AddComponent <Camera> ();

            ArCam.DevicePosition  = CaptureDevicePosition.Back;
            specCam.nearClipPlane = MiraArController.Instance.nearClipPlane * (1 / MiraArController.scaleMultiplier);

            //ArCam.EnableCameraRendering = true;
            positionalOffset = Vector3.zero;
            rotationalOffset = Quaternion.identity;
            ArCam.enabled    = true;

            imageTracker.AutoToggleVisibility = true;
        }



        InstaiateRotationalHandoffManager();



        SanityCheck();
    }
Beispiel #9
0
 public void Awake()
 {
     ArCam = gameObject.GetComponent <WikitudeCamera>();
     //	Instance.InstantiateWikitudeCamera ();
     InstaiateRotationalHandoffManager();
 }
Beispiel #10
0
 private void Awake()
 {
     _camera = FindObjectOfType <WikitudeCamera>();
 }
    private void Update()
    {
        if (_wikitudeCamera == null)
        {
            _wikitudeCamera = _sceneCamera.GetComponent <WikitudeCamera>();
        }

        if (LoadingIndicator.activeSelf)
        {
            /* The tracker is currently loading the target. */
            return;
        }

        _alignmentCamera.transform.position = _sceneCamera.transform.position;
        _alignmentCamera.transform.rotation = _sceneCamera.transform.rotation;

        if (Drawable.AlignmentDrawableAlignedWithTarget)
        {
            if (_alignmentInactive != true)
            {
                _alignmentCamera.enabled = false;
                _sceneCamera.enabled     = true;

                UIInteractionHint.SetActive(false);
                if (ZoomSlider != null)
                {
                    ZoomSlider.transform.parent.gameObject.SetActive(false);
                }
                _alignmentInactive = true;
            }

            return;
        }

        /* The alignment drawables have to be notified, if the scene camera FOV changes. */
        if (!Mathf.Approximately(_alignmentCamera.fieldOfView, _sceneCamera.fieldOfView))
        {
            _alignmentCamera.fieldOfView = _sceneCamera.fieldOfView;
            float changeInFOV = _initialFieldOfView / _alignmentCamera.fieldOfView;
            Drawable.AdjustZoom(changeInFOV);
        }

        if (_alignmentInactive)
        {
            _alignmentCamera.enabled = true;
            _sceneCamera.enabled     = false;

            UIInteractionHint.SetActive(true);
            if (ZoomSlider != null)
            {
                ZoomSlider.transform.parent.gameObject.SetActive(true);
            }
            _alignmentInactive = false;
        }


        /* If the view is mirrored in case of using a mirrored webcam or the remote front camera
         * for live preview, the rotation gestures also have to be mirrored correctly. */
        float flipHorizontalValue = _wikitudeCamera.FlipHorizontal ? -1f : 1f;

        /* Skip gestures if the zoom slider is interacted with. */
        if (ZoomSliderIsDragged == false)
        {
            /* Interaction logic for handling two-finger scale and rotation gestures. */
            if (Input.touchCount >= 2 && (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved))
            {
                Touch touchIdZero = Input.GetTouch(0);
                Touch touchIdOne  = Input.GetTouch(1);

                Vector2 prevTouchIdZero = touchIdZero.position - touchIdZero.deltaPosition;
                Vector2 prevTouchIdOne  = touchIdOne.position - touchIdOne.deltaPosition;

                float prevTouchDistance   = (prevTouchIdZero - prevTouchIdOne).magnitude;
                float touchDistance       = (touchIdZero.position - touchIdOne.position).magnitude;
                float touchDistancesDelta = touchDistance - prevTouchDistance;

                Drawable.AddZoom(touchDistancesDelta / Mathf.Min(Screen.width, Screen.height));

                if (ZoomSlider != null)
                {
                    ZoomSlider.value = Drawable.GetZoom();
                }

                float rotation           = Vector2.SignedAngle(prevTouchIdZero - prevTouchIdOne, touchIdZero.position - touchIdOne.position);
                float rotationMultiplier = 180f / Mathf.Min(Screen.width, Screen.height);
                Drawable.AddRotation(new Vector3(0f, 0f, flipHorizontalValue * rotation * rotationMultiplier));

                /* In case one finger gets lifted, the last mouse position has to be invalidated. */
                _lastMousePosition = Vector2.zero;
            }
            else if (Input.touchCount < 2)
            {
                /* The mouse input works for both, the mouse input and single finger input. */
                if (Input.GetMouseButtonDown(0))
                {
                    _lastMousePosition = Input.mousePosition;
                }
                else if (Input.GetMouseButton(0))
                {
                    /* This condition is met if a finger during two-finger gestures is lifted. */
                    if (_lastMousePosition.Equals(Vector2.zero))
                    {
                        _lastMousePosition = Input.mousePosition;
                    }
                    else
                    {
                        Vector2 mousePosition      = Input.mousePosition;
                        Vector2 deltaMousePosition = mousePosition - _lastMousePosition;
                        _lastMousePosition = mousePosition;

                        float rotationMultiplier = 180f / Mathf.Min(Screen.width, Screen.height);

                        Drawable.AddRotation(new Vector3(deltaMousePosition.y * rotationMultiplier, -flipHorizontalValue * deltaMousePosition.x * rotationMultiplier, 0f));
                    }
                }
            }
        }
    }